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 - MetalZelda

#466
Quote from: GameboyArda on December 02, 2015, 08:23:09 PM
It happend to me just I did not use a joypad ???

Your issue might be caused by a faulty script call.,  did the crash happend at the same spot or when using an item ?

All kind of stuffs can still make the editor to crash, but the Joypad issue is recurrent and always happend at the 2nd playtest.
#467
Hi.

I am posting this bug I faced multiple time (and hope that it is not my pc)

When I plug a joypad and open the editor and playtest, it works great, joypad commands are responsive, but if I stop the game (for some configuration for example) and restart the project through the editor, the joypad is not responding and if I stop it again, the editor crash and no errors are displayed .

Tested with MoS and other project, still crash, so quests aren't the culprit.

I am running Solarus Quest Editor 1.4.5, Windows 7.

#468
Your projects / Re: The Legend of Zelda
November 30, 2015, 10:31:09 PM
Update : Today I was able to work on the Fire Rod and successfully extended it to be Four Sword Adventure like (moving, burn stuffs and repeating fire stream).
The code that I used for making it is from Return of the Hylian SE and the Ice rod is on the my sight.

(The video was recorded with a nice (and hopefully) fixed issue where the .dat shouldn't be saved for some unknown reason so Link didn't had any "moving" animation when the video was recorded.)

https://www.youtube.com/watch?v=FNIhVF84aBg
#469
Development / Re: other:get_type() weird issue
November 23, 2015, 02:56:42 PM
Quote from: Christopho on November 23, 2015, 01:30:28 PM
Can you display the type of the other entity instead of just "not a pickable"?
Also, try with the new version 1.4.5 that was released yesterday. Some issues related to collisions with custom entities were fixed.

This was just a test to see if the custom entity collision works when it reach any pickable, the rest of the script is just the other bottle variant, nothing to do with this. I did take the custom entity thing from the hammer script. I don't really know what cause the issue, solarus 1.4.5 didn't solved it

I'm gonna work-around with metatable, this might be the issue (since the collision need to check if it is a pickable) but I don't know how i'm gonna do it ...
#470
Development / other:get_type() weird issue
November 23, 2015, 12:56:55 PM
Hello,

I was working on some items and I am currently facing a weird issue

Code (lua) Select
local variant = item:get_variant()
local game = item:get_game()
local map = item:get_map()
local hero = item:get_game():get_hero()
local tunic = game:get_ability("tunic")
 
  hero:freeze()
  game:set_pause_allowed(false)
 
if variant == 1 then -- swing, detectors are here

  hero:set_tunic_sprite_id("hero/item/bottle/bottle.swing.tunic_"..tunic)
  hero:set_animation("stopped")
 
  if math.random(1) == 0 then
  sol.audio.play_sound("items/bottle/swing0")
  else
  sol.audio.play_sound("items/bottle/swing1")
  end

  local x, y, layer = hero:get_position()
  local direction4 = hero:get_direction()
 
  if direction4 == 0 then x = x + 12
  elseif direction4 == 1 then y = y - 12
  elseif direction4 == 2 then x = x - 12
  else y = y + 12
  end
 
  local bottle = map:create_custom_entity{
    x = x,
    y = y,
    layer = layer,
    width = 8,
    height = 8,
    direction = direction4,
  }
 
  bottle:set_origin(4, 5)
 
sol.timer.start(200,function()
  bottle:add_collision_test("overlapping", function(bottle, other)
    if other:get_type()  == "pickable" and direction4 == bottle:get_direction() then
      print("it's a pickable")
  sol.audio.play_sound("items/bottle/close")
  bottle:clear_collision_tests()
  hero:set_tunic_sprite_id("hero/tunic"..tunic)
  hero:unfreeze()
  bottle:remove()
  self:set_finished()
  else
  print("it's not a pickable")
    end
  end)
end)

sol.timer.start(300,function()
hero:set_tunic_sprite_id("hero/tunic"..tunic)
hero:unfreeze()
bottle:remove()
    self:set_finished()
end)


The script works well, but the main issue is the collision test.
The script check if the custom entity is colliding with a pickable and does currently nothing else than display a message on the console.
But, weird thing is, the script, even if the custom entity is on any pickable, display "not a pickable", and the custom entity is only enabled if the hero is facing north, despite the "direction = direction4" (hero:get_direction()).

I did though of metatable, but I don't know how these works

Code (lua) Select
bottle:add_collision_test("overlapping", function(bottle, other)
    if other:get_type()  == "pickable" then
      print("it's a pickable")
  sol.audio.play_sound("items/bottle/close")
  bottle:clear_collision_tests()
  hero:set_tunic_sprite_id("hero/tunic"..tunic)
  hero:unfreeze()
  bottle:remove()
  self:set_finished()
  else
  print("it's not a pickable")
    end



#471
strange thing is that it doesn't do the thing in Mystery of Solarus ... You might try to copy / paste a destructible event from Mystery of Solarus and test in yout project with your destructible.
#472
Quote from: Diarandor on November 22, 2015, 12:16:45 AM
Is there some error in error.txt? If so, in which line?
Also, I think that the line

minecart:set_direction(minecart:get_direction() - 2)

should be

minecart:set_direction((minecart:get_direction() - 2)%4)


Oh that was that, I didn't though about the %4 in the algorythm, thanks, it now works properly.

Code (lua) Select
hero:set_direction(((minecart:get_direction() + 4)%4))

Thanks Diarandor  :)
#473
Yeah, this might be a bug, if you lift a destructible, the animation "destruction" is played.
But it's kinda cool though.
#474
Quote from: Diarandor on November 21, 2015, 08:43:18 PM
Hi! Maybe you can use the event on_direction_changed of the custom entity or its sprite to change the direction of the hero.

Hi

As you may see, the whole script works, if the minecart encounter the turning entity, it turns well and it change the direction of both the entity and the hero.
The main issue is when I wanna go again in the minecart when it finished, the hero:set_direction(minecart:get_direction()) don't work, while it was working the first time.

The strangest thing is this

Code (lua) Select
  function movement:on_position_changed()
    -- Put the minecart at the same position as the hero.
    minecart:set_position(hero:get_position())
    minecart:set_direction(hero:get_direction())
  end


This works, but not the opposite (hero:set_direction(minecart ...))
#475
Hi
My title might be unclear but it is quite easy to understand.
I modified a script that set the hero direction to the entity direction, it worls great the first time, but then the script runs a movement on the entity and alters direction by angle, and so the second time I wanna re-use that event, I get a error "invalid direction for "set_animation_direction" while it was working the first time.
self:get_angle doesn't work eigher

the script :

Code (lua) Select
-- A minecart to be used by the hero on railroads.
-- Source : Mercuri's Chest, customized to fit Minish Cap style (insane speed, sound effects, re-usable in opposite direction, destroy-able).
--[[
ToDo :
- Cane of Pacci system (if planned)
- entity (minecart_turn) dependant of entity state (use prefices and set_enabled) 0 = in default place 1 = opposite direction
Done :
- Speed
- Sprites
- Disable action, pause
- player ejection, keeping the minecart entity usable
- looping sound effects
--]]

local minecart = ...
local map = minecart:get_map()
local game = minecart:get_game()
local hero = map:get_hero()

-- Whether the hero is facing the minecart stopped.
local hero_facing_minecart = false
local action_command_minecart = false

minecart:set_drawn_in_y_order(true)

-- Don't let the hero traverse the minecart.
minecart:set_traversable_by("hero", false)

-- Hurt enemies hit by the minecart.
minecart:add_collision_test("sprite", function(minecart, other)
  if other:get_type() == "enemy" then
    other:hurt(4)
  end
end)

-- Detect minecart turns.
minecart:add_collision_test("containing", function(minecart, other)

  if other:get_type() == "custom_entity" then

    if other:get_model() == "object/minecart_turn" then
      local movement = hero:get_movement()
      if movement ~= nil then
        -- Simply change the hero's movement direction.
        local direction4 = other:get_direction()
        movement:set_angle(direction4 * math.pi / 2)
        hero:set_direction(other:get_direction())
      end
    end

    if other:get_model() == "object/minecart_turn_diagonal" then
      local movement = hero:get_movement()
      if movement ~= nil then
        -- Simply change the hero's movement direction.
        local direction8 = other:get_direction() * 2 + 1
        movement:set_angle(direction8 * math.pi / 4)
        local direction4 = (direction8 == 1 or direction == 7) and 0 or 2
        hero:set_direction(direction4)
      end
    end

if other:get_model() == "object/minecart_end" then
  if other:get_direction() == minecart:get_direction() then
  game:set_value("is_on_minecart", false)
  minecart_se:stop()
  link_se:stop()
  end
      local movement = hero:get_movement()
  local direction4 = hero:get_direction()
      if movement ~= nil then
  game:set_ability("tunic", game:get_value("item_saved_tunic"))
  hero:set_tunic_sprite_id("hero/tunic"..game:get_value("item_saved_tunic"))
      game:set_ability("sword", game:get_value("item_saved_sword"))
      game:set_ability("shield", game:get_value("item_saved_shield"))
      game:set_command_keyboard_binding("action", game:get_value("item_saved_action"))
      game:set_pause_allowed(true)
  movement:stop()
  minecart:get_sprite():set_animation("stopped")
 
  sol.audio.play_sound("objects/minecart/landing")
  sol.audio.play_sound("objects/minecart/preparing")
  sol.audio.play_sound("objects/minecart/common")
 
if math.random(1) == 0 then
sol.audio.play_sound("characters/link/voice/fall_damage0")
    else
sol.audio.play_sound("characters/link/voice/fall_damage1")
end
 
  hero:start_jumping(direction4 * 2, 32, false)
  sol.timer.start(200,function()
  minecart:set_traversable_by("hero", false)
  minecart:set_drawn_in_y_order(true)
  -- oppose the direction
  minecart:set_direction(minecart:get_direction() - 2)
  end)
      end
    end

if other:get_model() == "object/minecart_dead_end" then
    minecart:get_sprite():set_animation("turning_over")

game:set_ability("tunic", game:get_value("item_saved_tunic"))
hero:set_tunic_sprite_id("hero/tunic"..game:get_value("item_saved_tunic"))
    game:set_ability("sword", game:get_value("item_saved_sword"))
    game:set_ability("shield", game:get_value("item_saved_shield"))
    game:set_command_keyboard_binding("action", game:get_value("item_saved_action"))
    game:set_pause_allowed(true)
movement:stop()

  sol.audio.play_sound("objects/minecart/landing")
  sol.audio.play_sound("objects/minecart/preparing")
  sol.audio.play_sound("objects/minecart/common")
 
if math.random(1) == 0 then
sol.audio.play_sound("characters/link/voice/fall_damage0")
    else
sol.audio.play_sound("characters/link/voice/fall_damage1")
end
 
local explode_movement = sol.movement.create("straight")
explode_movement:set_max_distance(128)
explode_movement:set_speed(150)
explode_movement:set_angle(minecart:get_direction() * math.pi / 2 )
explode_movement:start(minecart)

   --todo project link away, if he strikes a wall, damage him.###

sol.timer.start(200,function()
minecart:set_traversable_by("hero", false)
    minecart:set_drawn_in_y_order(true)
end)

   sol.timer.start(800, function()
   --restart the same movement but oppose the direction
   minecart:set_direction(0)
   minecart:get_sprite():set_animation("destroy")

   minecart:remove()
end)

end
end

end)

-- Show an action icon when the player faces the minecart.
minecart:add_collision_test("facing", function(minecart, other)

  if other:get_type() == "hero" then

    hero_facing_minecart = true
    if minecart:get_movement() == nil
      and game:get_command_effect("action") == nil
      and game:get_custom_command_effect("action") == nil then
      action_command_minecart = true
      game:set_custom_command_effect("action", "action")
    end
  end

end)

-- Remove the action icon when stopping facing the minecart.
function minecart:on_update()

  if action_command_minecart and not hero_facing_minecart then
    game:set_custom_command_effect("action", nil)
    action_command_minecart = false
  end

  hero_facing_minecart = false
end

local function store_equipment()
    local tunic = game:get_ability("tunic")
    local sword = game:get_ability("sword")
    game:set_ability("sword", 0)
    local shield = game:get_ability("shield")
    game:set_ability("shield", 0)
local kb_action_key = game:get_command_keyboard_binding("action")
game:set_command_keyboard_binding("action", nil)
    game:set_value("item_saved_tunic", tunic)
    game:set_value("item_saved_sword", sword)
    game:set_value("item_saved_shield", shield)
game:set_value("item_saved_action", kb_action_key)
end

-- Called when the hero presses the action command near the minecart.
function minecart:on_interaction()

  if self:get_sprite():get_animation() == "stopped" then
  local x,y = minecart:get_position()
  local tunic = game:get_ability("tunic")
  local direction4 = hero:get_direction()

       if hero:get_direction() == 0 then --right
       minecart:set_drawn_in_y_order(false)
           hero:set_position(x-16, y)
       elseif hero:get_direction() == 1 then --up
       minecart:set_drawn_in_y_order(false)
           hero:set_position(x, y+16)
       elseif hero:get_direction() == 2 then --left
       minecart:set_drawn_in_y_order(false)
           hero:set_position(x+16, y)
       elseif hero:get_direction() == 3 then --down
           hero:set_position(x, y-16)
       end
   
    hero:freeze()
 
minecart:set_traversable_by("hero", true)
minecart:set_drawn_in_y_order(false)   
store_equipment()
game:set_pause_allowed(false)

if math.random(1) == 0 then
sol.audio.play_sound("characters/link/voice/jump0")
    else
sol.audio.play_sound("characters/link/voice/jump1")
end

sol.audio.play_sound("characters/link/voice/jump")

local jump_movement = sol.movement.create("jump")
jump_movement:set_distance(16)
jump_movement:set_direction8(direction4 * 2)
jump_movement:start(hero)

sol.timer.start(200, function()
sol.audio.play_sound("objects/minecart/preparing")
sol.audio.play_sound("objects/minecart/landing")

hero:set_tunic_sprite_id("hero/action/minecart/minecarting.tunic_"..tunic)
hero:set_animation("stopped")
hero:set_direction(minecart:get_direction())
end)

sol.timer.start(700, function()
    minecart:go()


-- play the sound once, the rest is handled bellow
sol.audio.play_sound("characters/link/voice/fall1")
sol.audio.play_sound("objects/minecart/moving")
end)
  end
end

-- Starts driving the minecart.
function minecart:go()

if hero:get_movement() ~= nil then
game:set_value("is_on_minecart", true)
end

if game:get_value("is_on_minecart") == true and hero:get_movement() ~= nil then
link_se = sol.timer.start(1000, function()
    sol.audio.play_sound("characters/link/voice/fall1")
return true
end)
minecart_se = sol.timer.start(300, function()
sol.audio.play_sound("objects/minecart/moving")
return true
end)
end

  hero:set_position(minecart:get_position())
  hero:set_animation("walking")
  minecart:get_sprite():set_animation("start")

  game:set_custom_command_effect("action", nil)
  action_command_minecart = false
  hero_facing_minecart = false

  -- Create a movement on the hero.
  local direction4 = minecart:get_direction()
  local movement = sol.movement.create("straight")
  movement:set_angle(direction4 * math.pi / 2)
  movement:set_speed(500)
  movement:set_smooth(false)

  function movement:on_position_changed()
    -- Put the minecart at the same position as the hero.
    minecart:set_position(hero:get_position())
minecart:set_direction(hero:get_direction())
  end
 
  -- Destroy the minecart when reaching an obstacle.
  function movement:on_obstacle_reached()
    minecart:stop()
  end
 
  -- The hero must be allowed to traverse the minecart during the movement.
  minecart:set_traversable_by("hero", true)
  movement:start(hero)
end

-- Stops driving the minecart and destroys it.
function minecart:stop()

  local minecart_sprite = minecart:get_sprite()
 
  -- restore values
  game:set_ability("tunic", game:get_value("item_saved_tunic"))
  hero:set_tunic_sprite_id("hero/tunic"..game:get_value("item_saved_tunic"))
  game:set_ability("sword", game:get_value("item_saved_sword"))
  game:set_ability("shield", game:get_value("item_saved_shield"))
  game:set_command_keyboard_binding("action", game:get_value("item_saved_action"))
  game:set_pause_allowed(true)
 
  game:set_value("is_on_minecart", false)
  minecart_se:stop()
  link_se:stop()
 
  -- Break the minecart.
  local direction4 = hero:get_direction()
 
  minecart_sprite:set_direction(0)
  minecart_sprite:set_animation("destroy")

  function minecart_sprite:on_animation_finished()
    -- Remove it from the map when the animation is finished.
       minecart:remove()
  end

   -- Restore control to the player.
  -- map.on_command_pressed = nil
  hero:unfreeze()
end


The direction issue is on on_interaction()
Code (lua) Select
hero:set_direction(minecart:get_direction())
#476
Development / Re: Lens of Truth?
November 18, 2015, 05:51:37 PM
Quote from: the bread on November 18, 2015, 04:29:57 PM
Perhaps you could give some context? Like, where those variables are defined and when the if-condition is checked. But anyway, it would probably be less error-prone to check inside of the timer whether it should still be executed. Like this:
Code ( lua) Select
sol.timer.start(500,function()
  if state == 1 then --A state of one probably means that the lens are activated. Correct me if I'm wrong
    magic = magic - 1
    return true
  end
end)


State = what is the current item state (on or off)
magic : getting the current magic level and set an algorythm that will take 1 Magic P. each 500 milliseconds.
return true = the timer is looped

The condition is active when the state of the item, declared in a local (game:get_value()) reach 1., the others are also local variables.
This might be the culprit

Everything is explained in the API

There is another method to do the lens of truth much easier but it need pixel opacity calculations on a surface, which is still not possible to do with solarus
#477
Development / Re: Lens of Truth?
November 18, 2015, 03:01:35 PM
You can first in you item script call a sprite representing the lens effect and create a sensor around the clear area that follows the hero and display the event / active it if it is in the sensor range.

This item is also in my todo, I might start it soon.

Since the Lens of Truth is separated in 2 process (on and off), it might be more complex, you might need more coding to do in on_using() and in on_map_changed (if you want to keep it active in another map while being teleported)

This is a mock up but this is what I'm going to do, but, I don't know how to control the magic

  if state ==1then
  magic_timer = sol.timer.start(500, function()
  magic - 1
  return true
  end)
  else magic_timer:stop()
  end


This is a brieve thing on the current script, it works in-game but the magic drop drastivally, magic - 1 isn't stopped when the item is stopped

#478
Your projects / Re: The Legend of Zelda
November 13, 2015, 10:13:35 PM
Week Update : Here are some enhancement make so far.



This is the Tower of Spirits, dungeon made in 2 parts, one of which will consist of seeking spirits to open another path, kinda like Twilight Princess' Arbiter Grounds.
Within this screen, you can also see the newly added ennemy in the game (and my first one) : the Darknut, it works like Minish Cap and use Wind Waker's actor  sounds, it is used as a Miniboss and in some dugeons as regular ennemies. And the reworked boss door which works the same way than OOT/MC.

The tileset looks like garbage and will be re-worked again because of bad resize format / method of resize used.
#479
Development / Re: Ignoring entity prefix ?
November 10, 2015, 01:45:08 PM
Quote from: Christopho on November 10, 2015, 01:25:27 PM
I don't understand. You want to remove the numbered suffix of a string?


local name_without_suffix = name_with_suffix:match("^(.*)_[0-9]+$")
if name_without_suffix == nil then
  -- No match. It means that there was actually no suffix.
  name_without_suffix = name_with_suffix
end


Or this shorter and more idiomatic way, completely equivalent:

local name_without_suffix = name_with_suffix:match("^(.*)_[0-9]+$") or name_with_suffix


I want to grab the entity that have a prefix and make the code to ignore that prefix, since the script I use need to retrieve the item name from the map entity name, so I need to pass through map:get_entities(), but, when it is about to give the treasure, the game doesn't start the treasure and input  "string expected, got nil", which is normal, since there is no item _x_"item" in the database, even if the entity have a name, and start_treasure have "name" (the local) in value.
Gonna try your method.

Edit : Great, it works like a charm, thanks Christopho. :)

Code (lua) Select
local name_without_suffix = self:get_name():match("^(.*)_[0-9]+$") or self:get_name()
hero:start_treasure(name_without_suffix)

#480
Development / [Solved] Ignoring entity prefix ?
November 10, 2015, 12:58:32 PM
Hi

I was wondering if this is possible to "ignore" the prefix of a copied entity ?
For example : I do have finished 100% my chest script and the treasure received is based on the entity name on the map, trouble is, if I copy this same entity, there would be a suffix "_x" where x is a number that increase if the same entity has been pasted.

But, as you may read, if I go get the treasure, let's say I do named the treasure "small_key", and open one of it's copy "_2_small_key", the game cannot recognize the item _2_small_key since it read the entire entity:get_name().

I do have see that Solarus have an event to parse all prefixes (http://www.solarus-games.org/doc/latest/lua_api_map.html#lua_api_map_get_entity) and I know how to retrieve the X value (the pool enigna from MoS helped in some way), but I don't really know how to ignore the prefix itself.

any help would be apreciated

This was my attempt in on_interaction(), but ended with "string expected, got nil", name is declared as local at the start of the script


Code (lua) Select
for entity in map:get_entities("^_([1-9])_$" ..self:get_name()) do
   if entity == find(self:get_name()) then
    name = self:get_name()
   end
  end


also tried this, same thing occurs

Code (lua) Select
  for entity in map:get_entities() do
   if map:get_entities():match("^_([1-9])_$" ..self:get_name()) then
    name = self:get_name()
   end
  end