custom_entity script and Solarus v1.4.3

Started by Yosha, August 19, 2015, 01:13:25 PM

Previous topic - Next topic
Hello, I didn't work on my project since the last update, but today, when I wanted to test some minor adjustment, I see that some code in my custom_entity script won't work. The custom_entity is an ally and here is the problem: usually when he walks into a hole, he falls like the hero. But today instead of normally fall into the hole, he is blocked ! I tried to add custom_entity:set_can_traverse_ground("hole", true) but it really makes the character traverse the hole!
What's the matter, It worked fine before the update. I see that because I wanted to display water when he walks throught shallow water, but like the hole nothing happens if the set can traverse ground is true...

There is the part of the code :
Code ( lua) Select
function P2:on_ground_below_changed(ground_below)
if ground_below == "hole" then -- Rajouter if not jumping plus tard
game:set_value("P2_state", "falling")
P2_Move:stop()
if P2:get_sprite():get_animation() ~= "falling" then
P1:freeze()
P2:get_sprite():set_animation("falling")
sol.audio.play_sound("hero_falls")
end
local P2_sprite = P2:get_sprite()
function P2_sprite:on_animation_finished(animation)
if animation == "falling" then
game:set_value("P2_state", "free")
P1:unfreeze()
end
end
end
end



Can you add a print or a sound at the beginning of this on_ground_below_changed() function to see if it is still called?


Do you hear the sound when the entity walks on the hole ? For now I just want to know if your event is called.

You need custom_entity:set_can_traverse_ground("hole", true), otherwise it cannot overlap the hole.

When I said nothing change I wanted to say that no sound is played, and of course the line custom_entity:set_can_traverse_ground("hole", true) was added too. So it seems that the function is not called...

I may be able to confirm this. I have a script that creates a custom block (custom entity) that the hero can push. Before the last update, he was able to push the block onto dynamic tiles and holes and it behaved as expected - dynamic tiles were traversable and holes were collision detected correctly (I have a collision test that removed the block). Now the entity will not traverse either even if set_can_traverse("dynamic_tile") is set.

I'm also not sure that the collision tests are detecting coordinates correctly, or probably I need to do more error testing of my script. When the hero pushes or creates a block on top of lava or water, it will freeze the ground below. The only collision test I can get to do anything is "overlapping", and even then if the block is placed on the edge of the dynamic tiles (lava or deep water), it won't freeze as expected. It works if placed more central to the tile.

August 19, 2015, 02:38:41 PM #6 Last Edit: August 19, 2015, 02:44:54 PM by Christopho
Quote from: wrightmat on August 19, 2015, 02:05:19 PM
I may be able to confirm this. I have a script that creates a custom block (custom entity) that the hero can push. Before the last update, he was able to push the block onto dynamic tiles and holes and it behaved as expected - dynamic tiles were traversable and holes were collision detected correctly (I have a collision test that removed the block). Now the entity will not traverse either even if set_can_traverse("dynamic_tile") is set.
The pattern of the tile also has its own traversable property and I think it is applied no matter what you set to set_can_traverse("dynamic_tile"). This is a bug. Unless you are saying that the tile pattern is already traversable, in this case the bug is more severe.
So we might have two bugs: this one and on_ground_below_changed() no longer called.

Each is a "special" type - one being deep water and one being lava, so conditionally traversable? :)

custom_entity:on_ground_below_changed() is now fixed in the dev branch: https://github.com/christopho/solarus/issues/738
It was broken since 1.4.3.

Also, I fixed custom_entity:get_modified_ground() that returned nothing.
And I added unit tests to avoid stupid errors like this in the future.