Ok! I knew it was just a little mistake like that, but I didn't figure what! What a dumb I am ! Well, thank you for this help and another question : what do you think about the code, is there a way to improve it, or I just let it like that ?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#17
Development / one enemy works, but two not...
October 01, 2015, 09:37:49 AM
Hello, I have a problem with an enemy I made. I 've done a Skulltula (like in OoT) falling from the ceiling, turning, etc... and after many days of coding, I finished it. It works as I would, but when I adding a second Skulltula, both of them doesn't work! I had the same problem when I made custom wizzrobe (before the release of ROTH, otherwise I didn't lost my time on it) and I've solved it somehow, but I don't remember how today! I think it's a problem with "self", but not sure! Here is the code. (And if it can help some dev to make a skulltula!)
Code ( lua) Select
local enemy = ...
-- Skulltula :
local fallen = false
local vulnerable = false
local shadow_x, shadow_y, shadow_z = enemy:get_position()
local m = sol.movement.create("straight")
local angle = math.pi/2
local angle_inverse = 3*math.pi/2
function enemy:on_created()
self:set_life(4)
self:set_damage(2)
self:set_optimization_distance(160)
self:set_size(16, 16)
self:set_origin(8, 13)
self:set_can_attack(false)
self:set_pushed_back_when_hurt(false)
self:set_attack_consequence("sword", "custom")
self:set_attack_consequence("hookshot", "ignored")
self:set_attack_consequence("boomerang", "ignored")
self:set_attack_consequence("explosion", "ignored")
self:set_obstacle_behavior("flying")
self:set_layer_independent_collisions(true)
sprite = self:create_sprite("enemies/skulltula")
end
function enemy:on_restarted()
if not fallen then
sprite:set_animation("shadow")
self:check_hero()
else
self:turning()
end
end
function enemy:check_hero()
local hero = self:get_map():get_entity("hero")
local x, y, z = self:get_position()
local hero_x, hero_y, hero_z = hero:get_position()
if self:get_distance(hero) <= 32 then
local direction = self:get_direction4_to(hero)
sprite:set_direction(direction)
if direction == 0 then
angle = 2*math.pi/2
angle_inverse = 0
end
if direction == 1 then
angle = 3*math.pi/2
angle_inverse = math.pi/2
end
if direction == 2 then
angle = 0
angle_inverse = 2*math.pi/2
end
if direction == 3 then
angle = math.pi/2
angle_inverse = 3*math.pi/2
end
self:falling()
end
sol.timer.stop_all(self)
sol.timer.start(self, 500, function() self:check_hero() end)
end
function enemy:falling()
sol.audio.play_sound("jump")
sprite:set_animation("walking")
self:set_position(shadow_x, shadow_y - 120, 2)
self:set_can_attack(true)
m:set_speed(320)
m:set_angle(3*math.pi/2)
m:set_max_distance(120)
m:start(self)
end
function enemy:on_movement_finished()
if fallen == false then
fallen = true
self:set_position(shadow_x, shadow_y, shadow_z)
self:restart()
end
end
function enemy:turn_anim()
if vulnerable == false then
sprite:set_animation("vulnerable")
vulnerable = true
else
sprite:set_animation("walking")
vulnerable = false
end
end
function enemy:turning()
sol.timer.start(self, 2000, function() -- Shaking
if vulnerable == false then
sprite:set_animation("shaking")
else
sprite:set_animation("vulnerable_shaking")
end
sol.timer.start(self, 2000, function() -- Turning
self:turn_anim()
sol.timer.start(self, 2000, function() self:turning() end)
end)
end)
end
function enemy:on_custom_attack_received(attack, sprite)
if fallen == true then
m:set_angle(angle)
m:set_speed(128)
m:start(self)
sol.timer.start(self, 200, function()
m:set_angle(angle_inverse)
sol.timer.start(self, 400, function()
m:set_angle(angle)
sol.timer.start(self, 200, function() m:stop() end)
end)
end)
if vulnerable == false then
sol.audio.play_sound("sword_tapping")
else
sprite:set_animation("hurt")
sol.audio.play_sound("enemy_hurt")
self:remove_life(1)
sol.timer.start(self, 200, function() self:turn_anim() end)
end
end
end
#18
Development / Re: Random...
September 25, 2015, 09:20:00 AM
Ok, thank you !
I use math.randomseed(os.time()) in map:on_started() and I have now a real random number !
I use math.randomseed(os.time()) in map:on_started() and I have now a real random number !
#19
Development / Random...
September 25, 2015, 08:56:23 AM
Hello, I don't know if anyone have already seen this, but I just saw yesterday that when I generate random numbers in a dialog, for each game I played, it was always the same numbers and in the same order...
#20
Development / Re: Question about dynamic tiles
September 05, 2015, 09:22:24 AM
Hello, I had the same idea with footprint on the sand. For now, I just made many sensor (many many !! but I try it with dynamic tiles and it works too!) and when the player overlaps this sensor (or dynamic tiles) the step is draw on the sand but as Christopho said, the map is really polluted (as you can see on the picture). I was hoping that the tile id will be checkable one day and I learn today the it will be possible in the 1.5! Cool, but is it only with dynamic_tile, or normal ones ?
#21
Development / Re: custom_entity script and Solarus v1.4.3
August 19, 2015, 01:53:32 PM
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...
#22
Development / Re: custom_entity script and Solarus v1.4.3
August 19, 2015, 01:37:03 PM
I add a sound, but nothing change...
#23
Development / custom_entity script and Solarus v1.4.3
August 19, 2015, 01:13:25 PM
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 :
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
#24
Zelda Return of the Hylian SE / Re: Some small "bugs"
August 14, 2015, 02:26:12 PM
Sorry to play the trouble maker, but I just dowload the 1.0.3 and I just enter the cave and...
error.txt
Error: In maps/caves/mudora_cave/1f: [string "maps/caves/mudora_cave/1f.lua"]:7: attempt to index global 'close_door_a_sensor' (a nil value)
error.txt
Error: In maps/caves/mudora_cave/1f: [string "maps/caves/mudora_cave/1f.lua"]:7: attempt to index global 'close_door_a_sensor' (a nil value)
#25
Zelda Return of the Hylian SE / Re: Some small "bugs"
August 14, 2015, 12:18:46 PM
Hello, I almost finish the game and it's a good one except the feeling of loneless and that something is missing... And despite of many village !! Well I've found some little bugs and even have an error file!
Error: No such dialog: '_crystal'
Error: In on_key_pressed: [string "scripts/menus/pause_map.lua"]:177: attempt to perform arithmetic on upvalue 'selected_floor' (a nil value)
Error: In on_key_pressed: [string "scripts/menus/pause_map.lua"]:167: attempt to perform arithmetic on upvalue 'selected_floor' (a nil value)
Error: In on_interaction: [string "maps/kakariko/leader_house.lua"]:20: bad argument #1 to start_dialog (No such dialog: 'kakariko.leader_house.go_ganon')
Another one :
Don't read if you don't want to be spoiled !
I'm blocked in the area of the secret dungeon (I've finished it and obtained the Master Sword) but I can't access to the haunted graveyard. I can see the way (already exploded) but it seems to be no teletransporter. And obviously, there no way to go back!
Error: No such dialog: '_crystal'
Error: In on_key_pressed: [string "scripts/menus/pause_map.lua"]:177: attempt to perform arithmetic on upvalue 'selected_floor' (a nil value)
Error: In on_key_pressed: [string "scripts/menus/pause_map.lua"]:167: attempt to perform arithmetic on upvalue 'selected_floor' (a nil value)
Error: In on_interaction: [string "maps/kakariko/leader_house.lua"]:20: bad argument #1 to start_dialog (No such dialog: 'kakariko.leader_house.go_ganon')
Another one :
Don't read if you don't want to be spoiled !
I'm blocked in the area of the secret dungeon (I've finished it and obtained the Master Sword) but I can't access to the haunted graveyard. I can see the way (already exploded) but it seems to be no teletransporter. And obviously, there no way to go back!
#26
Development / Stream and block
July 24, 2015, 07:41:09 AM
Hello, I saw on the Lua API doc that stream could by followed by bombs, but I want to know if it was possible with other entities, like destructible, pickable or block.
My purpose is to push a block on a stream and the block move toward it. Maybe can I use a cutom entity, but it would be useful to have to possibility to make it directly with the engine.
My purpose is to push a block on a stream and the block move toward it. Maybe can I use a cutom entity, but it would be useful to have to possibility to make it directly with the engine.
#28
Development / Re: custom_entity and sprite event
July 16, 2015, 12:13:52 PM
Thank You ! It works now ! And above that, I found out why my Custom entity did only one jump before bugging... I created 2 movement : one for the normal moving (walking and stop), and one for the jump. And after a week of thinking, testing, and headache, I realized that only one was necessary.
However, I have another question about the diagonal jumper : I saw that the overlapping part is not only the blue bar viewed on the editor, but the green square when you select it(i think it's the bounding box) and when I use custom_entity:set_can_traverse([entity_type], traversable) like this example:
the state jumping begins when P2 overlaps the square and not only the jumper (blue bar) itself. So, I wondering if it was a kind of bug from solarus or if it was normal. Therefore I found a solution by changing the P2_state not with the jumper (too bad!) but when the hero state changed. Thanks for all and it the last time I disturb you today !
However, I have another question about the diagonal jumper : I saw that the overlapping part is not only the blue bar viewed on the editor, but the green square when you select it(i think it's the bounding box) and when I use custom_entity:set_can_traverse([entity_type], traversable) like this example:
Code Select
P2:set_can_traverse("jumper", function() game:set_value("P2_state", "jumping") end)
the state jumping begins when P2 overlaps the square and not only the jumper (blue bar) itself. So, I wondering if it was a kind of bug from solarus or if it was normal. Therefore I found a solution by changing the P2_state not with the jumper (too bad!) but when the hero state changed. Thanks for all and it the last time I disturb you today !
#29
Development / Re: custom_entity and sprite event
July 16, 2015, 09:24:21 AM
OK thank you for the quickness! But I tried it and it doesn't work too.
I have another error :
Error: Failed to load script 'entities/P2': [string "entities/P2.lua"]:183: <name> or '...' expected near '"falling"'
Error: In entities/P2: attempt to call a string value
I found a trick but it's not what I want to do, and it would be fine while the animation is no longer that the timer...
I have another error :
Error: Failed to load script 'entities/P2': [string "entities/P2.lua"]:183: <name> or '...' expected near '"falling"'
Error: In entities/P2: attempt to call a string value
I found a trick but it's not what I want to do, and it would be fine while the animation is no longer that the timer...
Code Select
sol.timer.start(1000, function()
function P2:get_sprite():on_animation_finished("falling")
game:set_value("P2_state", "free")
P1:unfreeze()
end)
#30
Development / custom_entity and sprite event
July 16, 2015, 08:45:01 AM
Hello, like many users here, I made a custom entity that follow the hero (it's the main gameplay of my project since many years I'm working on!) but I have some little troubles with it. It moves, throught stairs, hole or whatever, and I can change the sprite animation, but when I want to came back to normal, after the animation finished, I have an error.
Here is an example : P1 is the hero and P2 the follower
Now there's the error :
Error: Failed to load script 'entities/P2': [string "entities/P2.lua"]:220: unexpected symbol near ':'
Error: In entities/P2: attempt to call a string value
The problem seems to be : function P2:get_sprite():on_animation_finished("falling")
I have another problem with the jump (it works once and doesn't work after) but we'll see that later !
Thanks for the help!
Here is an example : P1 is the hero and P2 the follower
Code Select
function P2:on_ground_below_changed(ground_below)
if ground_below == "hole" then
game:set_value("P2_state", "falling")
P2_Move:stop()
if P2:get_sprite():get_animation() ~= "falling" then
P2:get_sprite():set_animation("falling")
P1:freeze()
end
function P2:get_sprite():on_animation_finished("falling")
game:set_value("P2_state", "free")
P1:unfreeze()
end
end
end
Now there's the error :
Error: Failed to load script 'entities/P2': [string "entities/P2.lua"]:220: unexpected symbol near ':'
Error: In entities/P2: attempt to call a string value
The problem seems to be : function P2:get_sprite():on_animation_finished("falling")
I have another problem with the jump (it works once and doesn't work after) but we'll see that later !
Thanks for the help!