Show Posts

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.


Messages - Realguigui

Pages: [1] 2
1
Development / Re: menu with parameters
« on: November 16, 2017, 11:42:22 pm »
the good thing is that I use a custom entitie to launch the menu exactly like you said. The bad thing is that the scripts of pause menu are very complex and I don't find any help in them.

Thanks anyway.

2
Development / Re: menu with parameters
« on: November 16, 2017, 01:52:58 pm »
You don't need to code a menu for each door. You can pass all the necessary info from the door to the menu with an initialization function.

It's not clear for me. Can you tell me where I can found some examples ?

3
Development / menu with parameters
« on: November 16, 2017, 10:10:07 am »
Hello.
I have created a menu to manage the display and use of a digicode. It works but I would like to make it customizable to make it usable with several doors. For the moment, the secret code of the digicode and the name of the door that it opens are hardcoded in the code of the menu. This requires me to create a menu for each digicode. Would there be a way to launch my menu digicode by passing some parameters ("secret codes","door", map etc.) like a function ?
If it's not possible, is it a good idea to use some savegame_variables hardcoded in the menu that I initialize just before the lauch of the digicode's menu ?

Thank you

4
Development / block blocked on custom entity
« on: March 07, 2017, 06:20:53 pm »
Hello

In the same layer, if I push a block on a custom entity just created (default settings) and their bounding boxes (16px by 16px) are exactly superimposed, the block can not move anymore. This problem does not occur when the custom entity is above the block.

Is this normal?

5
Development / enemy movement
« on: February 13, 2017, 10:56:09 am »
Hello.
I'm studying the generic_soldier.lua code of zelda solarus dx. I have created a new model of enemy and I integrate, step by step, some functions of generic_soldier. I notice the use of 2 variables "going_hero" and "being_pushed" and in order to understand their function I don't use them in my code but they seems to be necessary because there is a behavior that I can't explain.
In my code, I have integrated, for the moment, the "target hero", the "change direction of sprite" and the "parrage with the sword" functions. I have also try an "audacious" : "movement:start(self,self:restart())" at line 83.

my code:
Code: Lua
  1. -- Lua script of enemy mon_enemie.
  2. -- This script is executed every time an enemy with this model is created.
  3.  
  4. -- Feel free to modify the code below.
  5. -- You can add more events and remove the ones you don't need.
  6.  
  7. -- See the Solarus Lua API documentation for the full specification
  8. -- of types, events and methods:
  9. -- http://www.solarus-games.org/doc/latest
  10.  
  11. local enemy = ...
  12. local game = enemy:get_game()
  13. local map = enemy:get_map()
  14. local hero = map:get_hero()
  15. -- sprite du corps de l'enemie
  16. local body_sprite
  17. -- sprite de l'épée de l'enemie
  18. local sword_sprite
  19. -- mouvement de l'enemie
  20. local movement
  21.  
  22. -- Event called when the enemy is initialized.
  23. function enemy:on_created()
  24.   -- On crée le sprite du corps de l'enemie en fonction de la race de l'enemie (nommage formalisé)
  25.   body_sprite = enemy:create_sprite("enemies/" .. enemy:get_breed())
  26.   -- On crée le sprite de l'épée de l'enemie en fonction de la race de l'enemie (nommage formalisé)
  27.   sword_sprite = enemy:create_sprite("enemies/" .. enemy:get_breed().."_sword")
  28.   -- On parametre les points de vie à l'enemie
  29.   enemy:set_life(5)
  30.   -- On parametre les dégats en pts de vie qu'inflige l'enemie
  31.   enemy:set_damage(1)
  32.   -- On parametre que l'enemie est repoussé quand il touché
  33.   enemy:set_pushed_back_when_hurt(true)
  34.   -- On parametre que le sprite épée est invincible
  35.   self:set_invincible_sprite(sword_sprite)
  36.   -- On parametre que le sprite épée quand il recoit une attaque de type "sword" déclenche l'evenement enemy:on_custom_attack_received
  37.   self:set_attack_consequence_sprite(sword_sprite, "sword", "custom")
  38. end
  39.  
  40. -- Event called when the enemy should start or restart its movements.
  41. -- This is called for example after the enemy is created or after
  42. -- it was hurt or immobilized.
  43. function enemy:on_restarted()
  44.   print("restarted")
  45.   -- On crée un mouvement de type "target"
  46.   movement = sol.movement.create("target")
  47.   -- On param que la cible de ce mouvement est le héro
  48.   movement:set_target(hero)
  49.   -- On param la vitesse du mouvement enemie
  50.   movement:set_speed(10)
  51.   -- On affecte le mouvement à l'enemie et on le lance
  52.   movement:start(enemy)
  53. end
  54.  
  55. -- LORSQUE L'ENEMIE CHANGE DE DIRECTION
  56. function enemy:on_movement_changed(movement)
  57.   print("change direction")
  58.   --if not being_pushed then
  59.     -- On recupere la direction du mouvement
  60.     local direction4 = movement:get_direction4()
  61.     -- On represente la nouvelle direction en changeant la direction du sprite du corps de l'enemie
  62.     body_sprite:set_direction(direction4)
  63.     -- On represente la nouvelle direction en changeant la direction du sprite de l'épée de l'enemie
  64.     sword_sprite:set_direction(direction4)
  65.   --end
  66. end
  67.  
  68. -- LORSQUE L'ENEMIE RECOIT UNE ATTAQUE QUE L'ON VEUT GERER SOIT MEME
  69. function enemy:on_custom_attack_received(attack, sprite)
  70.   -- Si l'attaque et de type sword et qu'elle touche l'epée enemie
  71.   if attack == "sword" and sprite == sword_sprite then
  72.     -- On joue le son de choc d'épées
  73.     sol.audio.play_sound("sword_tapping")
  74.    
  75.     --being_pushed = true
  76.     local x, y = self:get_position()
  77.     local angle = self:get_angle(self:get_map():get_entity("hero")) + math.pi
  78.     local movement = sol.movement.create("straight")
  79.     movement:set_speed(128)
  80.     movement:set_angle(angle)
  81.     movement:set_max_distance(32)
  82.     movement:set_smooth(true)
  83.     movement:start(self,self:restart())
  84.   end
  85. end
  86.  
   
The strange behavior : When the hero hit the enemy's sword, as expected, he is pushed away and the sprite change direction but after this, he walks but stay motionless. Yet there is a "restarted" in the console that prove the function "on_restarted" is call after the pushing movement but the "target" movement seems not to work. If I hit him again in his body, he's hurt and he moves again toward the hero.

Thanks

6
Development / Re: Event function linked to a dynamically created item
« on: February 10, 2017, 12:24:38 pm »
Thank all of you for your help.

the event map:on_obtaining_treasure() is the solution !

It's my fault. I always forget that parameters in events are "alredy fill" at the moment of the event contrary of functions. Obviously i tried to pass the item variable of my big key in the first parameter of "on_obtainig" event in order to have an event specific to my big key and I obtained an error message.

7
Development / Re: Event function linked to a dynamically created item
« on: February 10, 2017, 11:10:05 am »
The solution I think to implement:
  • Create the big key in the editor and disable it.
  • Transmit to my function "fall" the var "large key" to reactivate it rather than create it.

There is a problem with this solution because I use my function "fall" intensively to make a random bomb rain down. I'm brave but I do not want to create dozens of bombs in the editor.

8
Development / Re: Event function linked to a dynamically created item
« on: February 10, 2017, 10:50:47 am »
I create when  the game is running a pickable big key that drop from the ceiling.
My difficulty is to refer in my code to an object that does not yet exist. I get nil errors in the console at launch.

My function/script "falling_item" which is called uses a custom entity for the fall and a map:create_pickable when there is contact with the ground.

The solution I think to implement:
  • Create the big key in the editor and disable it.
  • Transmit to my function "fall" the var "large key" to reactivate it rather than create it.

9
Development / Re: Event function linked to a dynamically created item
« on: February 09, 2017, 09:23:39 am »
It works.
I had thought of this solution but it seemed to me not logical to code specific behavior in the general event function.

Thank you.

10
Development / Re: Event function linked to a dynamically created item
« on: February 08, 2017, 10:17:12 pm »
Thanks, but this solution works only with the actions performed each time. My goal is to cut the music when I get a large key but only on this map.

In your item script, you just need

Code: Lua
  1. function item:on_obtaining(variant, savegame_variable)
  2.   your_code
  3. end
  4.  

But, on_obtaining is called when you get that treasure, that is, before the treasure text begins.

You should use item:on_obtained() instead, or item:on_using()

11
Development / Event function linked to a dynamically created item
« on: February 08, 2017, 07:22:54 pm »
Hello.
Is it possible to code an on_obtaining () event function related to an item created during code execution ?
I know this is possible in item.lua but I want to code specific actions in this event function.

Thank you.

12
Development / Re: hard to activate a walkable switch
« on: January 29, 2017, 12:15:04 am »
It seems that the correct origin for zsdx is (0, 0), so that was not the problem, I think. I don't know yet what the problem is. Are you using both the last version of the game zsdx and the last version of the engine?

Another remark: after you modify the origin of the sprite, the refreshing button of the open map will not show the changes; you can either close/reopen the map, or double click in the switch entity and click "ok", that will show the updated origin for the switch sprite. Make sure you refresh the map to see how the changes are for that origin point.

Another question: is the size of your switch sprite 16x16?

I answer yes to all your questions.

I think there is no bug, but I realized that there was a "problem" when I made a room with a switch that launches a moving platform and the hero has to hurry To join it. To succeed, it is best to activate the switch from the side and this is difficult, much more than from the top.
I really invite you to test by yourself.

13
Development / Re: hard to activate a walkable switch
« on: January 28, 2017, 10:06:43 pm »
I 'm adding a switch on a map of solarus dx and the result is the same.


Try to set the origin point of the switch sprite to 8,13.
it's worst, the bounding box is completly offset:

14
Development / Re: hard to activate a walkable switch
« on: January 28, 2017, 09:25:08 pm »
I use the two sprites of Solarus DX.
The switch sprite origin point : 0,0.
the hero (tunic2) origin point : 12,21.

15
Development / hard to activate a walkable switch
« on: January 28, 2017, 06:34:05 pm »
Hello.

I think the activation of walkable switch needs too much accurency. Also, the activation zone seems to be offset toward down.
Is there a simple solution to resolve this ?

Switch NOT ACTIVATED


Switch ACTIVATED

Pages: [1] 2