Bear Wilson Posted March 4, 2022 Share Posted March 4, 2022 Error: [00:01:07]: [string "../mods/Timer/modmain.lua"]:20: attempt to index upvalue 'inst' (a nil value) LUA ERROR stack traceback: ../mods/Timer/modmain.lua:20 in (field) fn (Lua) <9-26> scripts/events.lua:46 in (method) HandleEvent (Lua) <42-49> scripts/input.lua:185 in (method) OnRawKey (Lua) <184-191> scripts/input.lua:429 in () ? (Lua) <428-430> I wanted to make a 60 seconds timer and used DoTaskinTime for it. Something went wrong, but i don't know what. I will be happy if you help me Code: local require = GLOBAL.require local ImageButton = require "widgets/imagebutton" require "constants" AddSimPostInit(function(inst) GLOBAL.TheInput:AddKeyHandler( function(key, down) if not down then return end if key == GLOBAL.KEY_R then if GLOBAL.TheWorld.ismastersim then for i = 0, 60 do inst:DoTaskInTime(1.0, function(inst) timer = 0 GLOBAL.c_announce(timer) timer = timer + 1 end) end else GLOBAL.TheNet:SendRemoteExecute("timer = 0") for i = 0, 60 do inst:DoTaskInTime(1.0, function(inst) GLOBAL.TheNet:SendRemoteExecute("c_announce(timer) timer = timer + 1") end) end end end end) end) Link to comment https://forums.kleientertainment.com/forums/topic/137968-what-is-wrong-in-my-code/ Share on other sites More sharing options...
Monti18 Posted March 5, 2022 Share Posted March 5, 2022 AddSimPostInit doesn't receive an entity as an argument, it has no arguments at all. You can run the DoTaskInTime either on ThePlayer or on TheWorld, as those are entities you can call from SimPostInit. Link to comment https://forums.kleientertainment.com/forums/topic/137968-what-is-wrong-in-my-code/#findComment-1545323 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now