Menu

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.

Show posts Menu

Messages - Diarandor

#946
On the one hand, I think this is quite unnecessary, since you can put a tile and resize it to have it as a background. This is just my opinion.

But, on the other hand, we would have the advantage of not being able to move the background accidentally in the editor (which happens sometimes), which could be useful, although not really important at all.
#947
Unfortunately, I think this is not possible yet, but maybe possible in next releases. In that effect, some pixels are shifted before drawn (not only for the ground, but also for entities on the map). We would need to be able to modify the pixels of the map and entities with some getters and setters functions on their sprites/tiles/surfaces, or something like that.

Solarus developers are still working on this, see:
https://github.com/christopho/solarus/issues/452
#948
Development / Re: Question about dynamic tiles
August 27, 2015, 04:07:32 AM
Hi! I also wanted to make a shovel for my game, although I haven't thought much how to program it.

I thought that I could detect the ground in some way and create a dynamic tile with hole ground over it. This was not a good idea since you would need to detect a 16x16 grid to create the hole in the correct position, but since sometimes the tiles are shifted 8 pixels in some coordinate, we would not be able to know the exact position where we should create the 16x16 hole (because of these possible shifts of 8 pixels in some coordinate). Thus, we will need to use some 16x16 entity that will be replaced by a 16x16 hole, that is unavoidable.

I think you are right that the best way would be using dynamic tiles. I would try to detect them with a collision test, checking if they are "sand" (checking the pattern id), and in that case removing it and creating a new dynamic tile with hole ground in its place, or something like that.

In this post http://forum.solarus-games.org/index.php/topic,386.0.html, Christopho said that he can do the functions dynamic_tile:get_pattern_id() and dynamic_tile:get_ground() for the next version of Solarus (the version 1.5), so you cannot detect the pattern id of a dynamic tile yet.

I think that the only solution at present would be using custom entities instead of dynamic tiles. In this case, instead of removing it and creating a new one, you can directly change the sprite and ground type of the custom entity.
#949
Development / Re: Problem to detect sword collision
August 26, 2015, 11:30:41 AM
I don't know, because I never made a wall that can be bombed. I just wanted to destroy some custom entities (plants) with the sword, and I didn't find a better way to do it, so I will keep that code
#950
Development / Re: Problem to detect sword collision
August 26, 2015, 05:00:01 AM
Well, I finally solved my own problem... XD
This is part of the code I used for the "plant" custom entity that can be cut by the sword:

function entity:on_created()
  -- Set properties.
  local map = self:get_map()
  self:set_traversable_by(false)
  -- Cut the entity when the sword hits it.
  entity:add_collision_test("sprite", function(entity, other_entity, sprite, other_sprite)
    -- Do nothing if the animation set is not of the sword, or if the sword is not close enough.
    if other_sprite == nil then return end
    local animation_set = other_sprite:get_animation_set()
    local sword_id = map:get_hero():get_sword_sprite_id()
    if animation_set ~= sword_id then return end
    if entity:get_distance(other_entity) > 28 then return end -- Set a max distance to cut.
    entity:cut() -- Cut the plant.
  end)
end
#951
Development / Problem to detect sword collision
August 26, 2015, 04:14:15 AM
Hi! I am having problems to detect a custom entity (a plant) when it is cut by the sword. The code I am using is something like this:

entity:add_collision_test("sprite", function(entity, other_entity, sprite, other_sprite)
  -- Do nothing if the animation is not "sword", or if the sword is not close enough.
  if other_sprite == nil then return end
  if other_sprite:get_animation() ~= "sword" then return end
  -- cut the plant!
end)

I realized that when the hero was in down direction, he could cut a plant that was in the up direction, and I didn't know why that did happen until now (because the sword sprite was not colliding with the plant).

I found that the problem is that, when the hero attacks, both the hero and the sword have an animation called "sword", so if the hero sprite touches the plant during the attack, the plant is cut too (even if the sword does not touch it). I also tried using the method get_type, but the collision with the sword sprite seems to return "hero" as the type of the entity (I suppose that the sword is just a sprite of the hero).

Is there some way to deal with this problem quickly? As a last option I would change the sword item by a custom entity sword, but I want to keep the sword item if possible, for simplicity.
#952
Development / Re: Problem w global go value
August 26, 2015, 03:56:54 AM
You have a 'go' function in line 51 which is not defined in the script.
#953
Development / Re: Problem w global go value
August 26, 2015, 03:42:39 AM
Do you still get an error or does it work now? And, in case you get an error or something is wrong, what is it?
#954
Development / Re: Problem w global go value
August 26, 2015, 03:19:57 AM
Your errors says that you have an error in line 53 because the function go is not defined before (in other words, it is equal to nil). If you still have problems with this, post the code here, so we can help you.
#955
Development / Re: Custom code debugging
August 26, 2015, 02:45:07 AM
Yes, you can put custom entities in the editor with a sprite which is graphically shown in the editor.
#956
Development / Re: Custom code debugging
August 25, 2015, 02:44:38 PM
I would do as Christopho suggests. Using custom entities instead of dynamic tiles, as a workaround, until the day these bugs are fixed. Custom entities are great ;D
#957
Development / Re: Custom code debugging
August 25, 2015, 02:37:02 PM
Isn't it possible to get the pattern or other information from a dynamic tile with some function?
#958
Development / Re: Custom code debugging
August 25, 2015, 02:23:59 PM
@wrightmat:

These seem hard problems. I have never used dynamic tiles, so I'm not sure if this would work. For the collision test when you create the block, I would try to do it in a different way, without the collision test. Try to use a loop on all entities (

for e in map:get_entities("") do
   if e:get_type() == "dynamic_tile" then
     -- Try to detect somehow if the dynamic tile is of lava. (And in that case, do something.)
     -- Also, check if the entities are overlapping with entity:overlaps(other_entity).
  end
end

I don't know if it is possible to detect if a dynamic tile represents water or lava (there is no function to get the info). But still, when you create the dynamic tile dynamically, you can set a boolean property like "entity.is_lava = true" and use it in the loop above to know if the entity is the good one. This might solve one of your problems.

@Christopho:

By the way, there is an error in the Lua API. One of the functions "entity:overlaps(other_entity)"
should appear as "entity:overlaps(x,y,width,height)".
http://www.solarus-games.org/doc/latest/lua_api_entity.html#lua_api_entity_overlaps

EDIT: another idea, for your dynamic tiles would be to set a property in the moment you create them: "dynamic_tile.is_of_type = ..." and save the type of it there (lava, water, ice, etc), and modify it when necessary, so you can get the info you need from there.
#959
Development / Re: Custom code debugging
August 25, 2015, 12:25:03 PM
Yes, I had that problem for custom switches (made with custom entities) not detecting collision tests (when pushed by some entity) if the other entity was created above them, or something like that (I don't remember the details). In the end, I had to use a timer to detect collisions as a workaround.
#960
Development / Re: Trying to change key binding
August 24, 2015, 10:09:38 PM
Try to put it in the event game:on_started(). I have a similar code for my joypad that works, like this:

function game:on_started()
  -- Prepare the dialog box menu and the HUD.
  game:initialize_dialog_box()
  hud = hud_manager:create(game)
  pause_menu = pause_manager:create(game, exists)
  -- more code that I am using... and:
  -- Configure some joypad buttons. [Change this for a menu later!]
  game:set_command_joypad_binding("action", "button 10")
  game:set_command_joypad_binding("attack", "button 11")
  game:set_command_joypad_binding("item_1", "button 12")
  game:set_command_joypad_binding("item_2", "button 13")
end