im making a screen at the end appear when the characters health is equal to zero.
local function player_damage(self)
if self.player_health > 0 then
self.player_health = self.player_health - damage
print(self.player_health)
elseif self.player_health == 0 then
load_endscreen(self)
end
end
and load_endscreen is in my loader script and a global variable
function load_endscreen(self)
msg.post("go#endscreen", "load")
msg.post("go#endscreen", "enable")
end
The error tells you that there is no game object with the id “go” at the same level in the scene graph as the script which is sending the message. What does your collection look like?
If the “go” object is at the root then it should be “/go”
No I don’t think so. Looking at your screenshot it looks like you are sending msg.post("go#endscreen", "load") from main:/hero#heromove.
If it is indeed the heromove.script that sends the message then my recommendation is that you restructure your logic a bit. The heromove.script can send a message to the loader.script (using the full path) and then the loader script takes care of calling “load”, “enable” etc
i have a the code so that when the player dies it does the function
local function player_damage(self)
if self.player_health > 0 then
self.player_health = self.player_health - damage
print(self.player_health)
elseif self.player_health == 0 then
load_endscreen(self)
enable_endscreen(self)
end
But this will post a message to a game object with id “go” in the same collection as the hero? And it doesn’t look like that is the case. Your loader is in another collection so you must specify the collection id as well:
msg.post("foo:/go#loader", "load")
Replace “foo” with the id of the loader collection (select the collection root to see the id/name).
nevermind i got it to work i dont know if its the most efficent
elseif self.player_health == 0 then
msg.post("loader:/go#endscreen", "load")
msg.post("loader:/go#endscreen", "enable")
end
When the screen appears do you know how to make everything else to stop like enemy movement and have a moving floor so how would i make that stop moving