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) [Select]
-- Lua script of enemy mon_enemie.
-- This script is executed every time an enemy with this model is created.

-- Feel free to modify the code below.
-- You can add more events and remove the ones you don't need.

-- See the Solarus Lua API documentation for the full specification
-- of types, events and methods:
-- http://www.solarus-games.org/doc/latest

local enemy = ...
local game = enemy:get_game()
local map = enemy:get_map()
local hero = map:get_hero()
-- sprite du corps de l'enemie
local body_sprite
-- sprite de l'épée de l'enemie
local sword_sprite
-- mouvement de l'enemie
local movement

-- Event called when the enemy is initialized.
function enemy:on_created()
  -- On crée le sprite du corps de l'enemie en fonction de la race de l'enemie (nommage formalisé)
  body_sprite = enemy:create_sprite("enemies/" .. enemy:get_breed())
  -- On crée le sprite de l'épée de l'enemie en fonction de la race de l'enemie (nommage formalisé)
  sword_sprite = enemy:create_sprite("enemies/" .. enemy:get_breed().."_sword")
  -- On parametre les points de vie à l'enemie
  enemy:set_life(5)
  -- On parametre les dégats en pts de vie qu'inflige l'enemie
  enemy:set_damage(1)
  -- On parametre que l'enemie est repoussé quand il touché
  enemy:set_pushed_back_when_hurt(true)
  -- On parametre que le sprite épée est invincible
  self:set_invincible_sprite(sword_sprite)
  -- On parametre que le sprite épée quand il recoit une attaque de type "sword" déclenche l'evenement enemy:on_custom_attack_received
  self:set_attack_consequence_sprite(sword_sprite, "sword", "custom")
end

-- Event called when the enemy should start or restart its movements.
-- This is called for example after the enemy is created or after
-- it was hurt or immobilized.
function enemy:on_restarted()
  print("restarted")
  -- On crée un mouvement de type "target"
  movement = sol.movement.create("target")
  -- On param que la cible de ce mouvement est le héro
  movement:set_target(hero)
  -- On param la vitesse du mouvement enemie
  movement:set_speed(10)
  -- On affecte le mouvement à l'enemie et on le lance
  movement:start(enemy)
end

-- LORSQUE L'ENEMIE CHANGE DE DIRECTION
function enemy:on_movement_changed(movement)
  print("change direction")
  --if not being_pushed then
    -- On recupere la direction du mouvement
    local direction4 = movement:get_direction4()
    -- On represente la nouvelle direction en changeant la direction du sprite du corps de l'enemie
    body_sprite:set_direction(direction4)
    -- On represente la nouvelle direction en changeant la direction du sprite de l'épée de l'enemie
    sword_sprite:set_direction(direction4)
  --end
end

-- LORSQUE L'ENEMIE RECOIT UNE ATTAQUE QUE L'ON VEUT GERER SOIT MEME
function enemy:on_custom_attack_received(attack, sprite)
  -- Si l'attaque et de type sword et qu'elle touche l'epée enemie
  if attack == "sword" and sprite == sword_sprite then
    -- On joue le son de choc d'épées
    sol.audio.play_sound("sword_tapping")
   
    --being_pushed = true
    local x, y = self:get_position()
    local angle = self:get_angle(self:get_map():get_entity("hero")) + math.pi
    local movement = sol.movement.create("straight")
    movement:set_speed(128)
    movement:set_angle(angle)
    movement:set_max_distance(32)
    movement:set_smooth(true)
    movement:start(self,self:restart())
  end
end
   
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) [Select]
function item:on_obtaining(variant, savegame_variable)
  your_code
end

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