Ok, I have read the “Addressing in Defold” article and still have a question.
I have a very simple demo project set up where a sprite stands on a tile map:
Here’s my asset pane:
Here’s my player.go outline:
In my player.script, I have this code:
function on_message(self, message_id, message, sender)
print(message_id, message, "sender", sender, message.other_id)
if sender == hash("player#spearCO") then
print("Test")
end
....
end
Basically, I am trying to determine when my spear contacts a tile, and then programmatically change the tile to something else.
From my print statement, I am getting this response:
DEBUG:SCRIPT: hash: [contact_point_response] table: 0x011b967d20 sender url: [main:/player/player#spearCO] hash: [/level]
So what I was trying to do, is if the sender is the spearCO (spear collision object) and the other_id is the /level then I would post a message to change the tile.
So what I am having trouble with is the url address of the sender:
url: [main:/player/player#spearCO]
Questions:
- what can I put in my if-statement, to get my code to print “Test”.
- Why is the url of the spearCO: main:/player/player#spearCO? Shouldn’t it be main:/player#spearCO? Why is there an extra ‘player’ in there?
Thanks in advance!