I am struggling to find a way to send a “message” with the msg.post() function. I want to send a score to another script using the piece of code "msg.post(“default:/gui#gameOver”, “score”). However, I’m not sure of the way to send the actual numerical score with this piece of code.
So far this is all that I have on the recieving end but I am not sure how to collect the score after its been sent either.
I would be happy to answer any questions and hope that someone can help me.
Thanks man. I actually have that exact tab open right now, I’m just new so sometimes I miss the basics. I tried something like that but couldn’t get it to work, so I just asked on here.
in another area of my code, I have an error where it tells me that I have a “-1 in function post”. I’m not sure where to start debugging since i think there is something in the function post. Do you think that you could help me?
This is the error that I get when I run the program.
ERROR:SCRIPT: main/main.script:50: Could not send message 'score' from 'main:/terminal#main' to 'score:/script#score'.
stack traceback:
[C]:-1: in function post
main/main.script:50: in function <main/main.script:15>
This is hopefully the relevant code:
elseif message_id == hash("show score") then
msg.post(self.live_proxy, "unload")
msg.post("#score_proxy", "load")
self.live_proxy = "#score_proxy"
msg.post("score:/script#score" ,"score", {score = message.score})
end
There is quite a lot score words which is probably confusing but I know that the URL is correct and as for the rest… I can’t seem to figure it out despite reading up on it.
If there is anymore you think i need to add i would be happy to
It looks like you are loading a collection proxy and instantly trying to message an object within it. This will not work, you must ensure the collection proxy is finished loading first.
Once you receive the “proxy_loaded” message, you can safely enable the collection proxy. It will be available the next frame after that.