In the game i’m making ive got a timer set that is used to time how long it takes for the player the complete the level, i would then like the time to be displayed on a gui that says level complete with the time.
So i have coded my game to: send the time (self.timer) to the loader script which will then display the gui with the time.
So below is the code that sends the time to the loader script:
msg.post("loader:/go#loader", "game_complete", {timer = self.timer})
This is the code in the loader that sends the time to the gui and gets the gui to run:
if message_id == hash("game_complete") then
unload_game(self)
self.timer = message[timer]
load_level_complete(self)
local function load_level_complete(self)
msg.post("/level_complete#level_complete", "timer", {timer = self.timer})
msg.post("go#level_complete", "load")
msg.post("go#level_complete", "enable")
end
end
I’ve got 2 errors:
the first is caused when i assign self.timer = 0 in the init function of the loader. I’m not sure why it does this nor how i should fix it. (Do i even need to assign self.timer in the init function?)
the second is caused by an improper url when i want to send the time to the gui from the loader. I didn’t see any problem with the URL so i’m not sure what is causing it?