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

Topics - MetalZelda

#41
Development / [Script] Fog Effect & Map Name
January 11, 2016, 10:47:22 PM
Script Information :
- Fog Effect : Display and move a surface, creating a fog moving effect.

This script is heavily inspired by the Day/Night / Fog effect tuto made by Christopho (most of the code is from the tutorial.), but this is more generalized since it use metatable (so it avoid copies over maps script.).

How it works ?
- place the script in quest_manager (or other file that regroup all metatable)
- copy/paste the script in a function that hold the map metatable.
- Place your fogs png in /sprites/fogs
- The fog surface should be higher or equal to 320x240 (or else it would do strange thing where you will need to duplicate the fog, which will result in higher map loading time and framerate issue)
- In your map script, in on_started(), add

Code (lua) Select

function map:on_started(destination)
map:display_fog("filename", speed, angle, opacity)
end


where :

filename must be a string pointing to an existing file in /sprites/fog
speed a number (0 = immobile, higher value = faster)
angle a number between 0 and 7 (0 = right, 7 = south-east
opacity a number between 0 and 255 (0 = transparent, 255 = opaque)

- A savegame value that check if there is any fog graphic. If yes, it is drawn.

Problems :

- If you use map:on_draw(surface) in your map script, the function in the metatable is overwritten, but, this script is temporary before solarus allows shader

What's next :

- add a parameter that analyse the size of the map, if higher then 320x240, automatically multiply the surface to fit the map.
- add a boolean, if true, the fog will slightly follow the camera movement
- fade in/fade out with user custom timer. (Useful for sunrays-like fog)

Code (lua) Select


  function map_metatable:display_fog(fog, speed, angle, opacity)
   local  fog = fog or nil
local speed = speed or 1
local angle = angle or 0
local opacity = opacity or 16

if type(fog) == "string" then

  self.fog = sol.surface.create("fogs/"..fog..".png")
      self.fog:set_opacity(opacity)
  self.fog_size_x, self.fog_size_y = self.fog:get_size()
      self.fog_m = sol.movement.create("straight")
 
  function restart_overlay_movement()
self.fog_m:set_speed(speed)
self.fog_m:set_max_distance(self.fog_size_x)
self.fog_m:set_angle(angle * math.pi / 4)
self.fog_m:start(self.fog, function()
restart_overlay_movement()
self.fog:set_xy(0,0)
end)
      end
  restart_overlay_movement()

self:get_game():set_value("current_fog", fog)
     end
  end
 
  function map_metatable:get_current_fog()
    return self:get_game():get_value("current_fog")
  end

  function map_metatable:on_draw(dst_surface)
local scr_x, scr_y = dst_surface:get_size()
if self:get_current_fog() ~= nil then
  local camera_x, camera_y = self:get_camera_position()
  local overlay_width, overlay_height = self.fog:get_size()
  local x, y = camera_x, camera_y
  x, y = -math.floor(x), -math.floor(y)
  x = x % overlay_width - 4 * overlay_width
  y = y % overlay_height - 4 * overlay_height
  local dst_y = y
  while dst_y < scr_y + overlay_height do
local dst_x = x
while dst_x < scr_x + overlay_width do
  self.fog:draw(dst_surface, dst_x, dst_y)
  dst_x = dst_x + overlay_width
end
dst_y = dst_y + overlay_height
  end
end
end

  function map_metatable:on_finished()
self:get_game():set_value("current_fog", nil)
  end


This is an example of what you can do.
#42
Bugs & Feature requests / Stairs acting weird
January 04, 2016, 11:34:09 PM
Hi.

I was playtesting some things earlier and I was testing stairs transitions, but I faced something quite strange with stairs going left to up, left to down, same thing for the right side. The animation is halted and the hero slides away, I don't know if this is a bug, but there are no walls that can modify the behaviour
#43
Hi.

I see in the video tutorial that Christopho always use tiled wall to cover under-layers, so I am asking if wall entity does have any impact on the game performance in comparaison to tiled wall ?

The only thing that I see about entitified wall :
- can be created, enabled or disabled dynamically
#44
Hi.

So I was working on some items today (ice rod, deku nuts) and I was wondering how can I make the custom item to immobilize enemies, I tried "set_attack_reaction = "immobilize" but it seems that it doesn't do anything. "set_attack_reaction = "immobilized" hurt the enemies even if the desired reaction is "immobilize". Enemies sprite does have "immobilized" animation.

Code (lua) Select
-- Initialize the metatable of appropriate entities to work with the ice.
local function initialize_meta()

  -- Add Lua ice beam properties to enemies.
  local enemy_meta = sol.main.get_metatable("enemy")
  if enemy_meta.get_ice_reaction ~= nil then
    -- Already done.
    return
  end

  enemy_meta.ice_reaction = "immobilize"
  enemy_meta.ice_reaction_sprite = {}
  function enemy_meta:get_ice_reaction(sprite)

    if sprite ~= nil and self.ice_reaction_sprite[sprite] ~= nil then
      return self.ice_reaction_sprite[sprite]
    end
    return self.ice_reaction
  end

  function enemy_meta:set_ice_reaction(reaction, sprite)

    self.ice_reaction = reaction
  end

  function enemy_meta:set_ice_reaction_sprite(sprite, reaction)

    self.ice_reaction_sprite[sprite] = reaction
  end

  -- Change the default enemy:set_invincible() to also
  -- take into account the ice.
  local previous_set_invincible = enemy_meta.set_invincible
  function enemy_meta:set_invincible()
    previous_set_invincible(self)
    self:set_ice_reaction("ignored")
  end
  local previous_set_invincible_sprite = enemy_meta.set_invincible_sprite
  function enemy_meta:set_invincible_sprite(sprite)
    previous_set_invincible_sprite(self, sprite)
    self:set_ice_reaction_sprite(sprite, "ignored")
  end

end
initialize_meta()


Also question : Does it need extensive code to allow enemies to have a "freeze" attack reaction ?

Any help would be great
Thanks
#45
Development / [Test]Reworked items
December 04, 2015, 04:27:01 PM
These items scripts are still Work in Progress and thus still need more and more improvement (direction fix mostly, but that's gonna be possible on Solarus 1.5).
You probably have played Four Swords Adventure ? The items behavious is now the same.

But, as I am mostly alone to remake these I can't debug the whole thing, I know that there should be some other glitches wandering around but I can't find these, so I'm going around the players itself to test them and post feedbacks.

Explanations :
-When you use an item, the pause menu is disabled and the opposite item slot is too.
-You can't interract with NPC or such, you need to quit the item. (Similar to Wind Waker)
-Action input is disabled
- To quit the item, there are a lot of method
    - Falling
    - Sword button
    - be hurt by an ennemy (use an alternate function)
    - jumping
    - Going in water.
- Speed is slowed while using item, slower when you're arming the item
- You can rapid-fire (and I believe that bugs are here)
- Hookshot : If you are tracted, the item stop itself, else you can re-fire
- set_finished (containing saved input values) is called in on_map_changed, which is called in game start

The obtainable items are Fire Rod, Hookshot and the Bow, I did already have show the Fire Rod but it's way to function was way too hard and too complex, now, the whole item is scripted and working within it's item file, and allowed to implement joypad controls.

You can take these as you wish, I did not check the whole folder so there might be some files of my project wandering around, some files are from Book of Mudora (text, sprites), it's a really old backup of the project with these new files. But keep in mind that these need more and more improvement, essencially if you might use sensors to trigger cutscenes which will require a game function to halt all items.

The only language available is French but that's only testing things so)

Any feedbacks and bug reports would be nice (Except the dialogs, I already know these).
You can open with with Solarus 1.4.5

They only work for tunic1 (Green tunic)

Authors to credit :
Christopho (Hookshot script (ROTH SE), basic functions)
Wrightmat(some of his ressources are still used in the demo)

Download :
http://www.filedropper.com/test_51

Edit : I didn't included treasure pose management, because items are supposed to be obtainable on chests. But this is gonna be fixed.
#46
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.

#47
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



#48
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())
#49
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
#50
Development / Is Surface bellow layers possible ?
November 09, 2015, 04:52:18 PM
Hi.

Does Solarus accept drawable objects (surface) to be bellow all layers ? I do have checked the API http://www.solarus-games.org/doc/latest/lua_api_surface.html and it doesn't seems to have some parameters like putting it on a certain layer or bellow
http://www.solarus-games.org/doc/latest/lua_api_drawable.html#lua_api_drawable_draw_region
This would be cool if there were a parameter "height" in drawable:draw (desired layer or top or bellow all)

Example of use :
This could be useful for auto-scrolling backgrounds
#51
Hello

I was creating some items when I faced something ... Strange

This is the code that is running to keep the hero direction

Code (lua) Select

function hero:on_position_changed()
hero:set_direction(direction)
end


Pretty basic but that work

The problem is, and that I can't figure out what does this. There is a frame reckeck when I press another direction, making some strange feedbacks, and if I press the item button to trigger it multiple time, Link can change direction, even if he is forced to keep the last memorized one because of this frame recheck
#52
Development / Where is used PhySFS in Solarus ?
November 01, 2015, 06:16:47 PM
Hi

I would ask a question to Solarus' developpers, I see that you use a archiving library that can access zip, etc. However, it also allows writing on some files.

In the Solarus engine, I do only found Physfs in the "QuestManagement.cpp" and I do wonder what would happen if I delete this lib and replace it manually by manually defined path and do something like Vincent Jouilat does?

Is physfs used elsewhere ?
#53
if I set a custom speed on the hero, let's say 20, before going on a shallow water terrain type, the hero would slow down, which is normal, the engine runs a algorithm to slow down speed a bit on shallow water, but if you set another speed while on shallow water, the new speed is only set when you're not on the shallow water terrain, same thing happen while in water, you need to press action (swim) or go on another solid terrain to update the new speed

You can reproduce this glitch with the debug keys.
#54
Just to be clear, this is NOT MY PROJECT, I found it on Youtube, it is stated to be made with Solarus.
https://www.youtube.com/watch?v=uVt3gd9XWr4
This is a nice start
#55
Issue tracking bellow

Hi

I'm quite stuck with a problem with items, I'm currently working on a new bow mechanism. I'm stuck with a problem.
I'm trying to get where the item is assigned (slot 1 or 2) by getting it's keyboard key (I'm using on_key_pressed, on_command_pressed freeze the hero  ???

Code (lua) Select
function game:on_key_released(key)
local map = game:get_map()
local hero = map:get_hero()

local bow_state = game:get_value("bow_state")
local can_fire = game:get_value("can_shoot")

if key == "x" and bow_state == 1 and item:get_amount() == 0 and can_fire == true and not game:is_suspended() then
hero:set_tunic_sprite_id("hero/item/bow_shoot_tunic1")
sol.audio.play_sound("/items/bow/no_arrows_shoot")
hero:freeze()
-- can't shoot arrows, but reset to state 1
sol.timer.start(100, function()
    game:set_value("bow_state", 1)
game:set_value("can_shoot", false)
hero:set_tunic_sprite_id("hero/item/bow_moving_free_tunic1")
hero:unfreeze()
game:set_pause_allowed(true)
end)
elseif key == "x" and bow_state == 1 and item:get_amount() > 0 and can_fire == true and not game:is_suspended() then
hero:set_tunic_sprite_id("hero/item/bow_shoot_tunic1")
shoot_arrow()
hero:freeze()
sol.timer.start(100, function()
game:set_value("bow_state", 1)
game:set_value("can_shoot", false)
hero:unfreeze()
hero:set_walking_speed(40)
hero:set_tunic_sprite_id("hero/item/bow_moving_free_tunic1")
game:set_pause_allowed(true)
end)
end
end


I'm trying to get the corresponding key where the item is assigned to replace the gross if key == "x" but it's kinda messy, Christopho suggested to me this code where the game retrieve info from the item but it's a mess too. I already tried a condition where the key value = x or v depending on the i value, but only x works, v doesn't, and if i print the value, the number I got is 1, even for the item in slot 2

Code (lua) Select
function game:get_item_slot(item)
for i = 1, 2 do
  if game:get_item_assigned(i) == item then
  return i
end
return nil
#56
Hi
I was wondering if it was possible to save a single custom entity state on the map when there are copies of the same entity  ?

This is my alternate chest script (issue bellow)

Code (lua) Select
local entity = ...
local game = entity:get_game()
local map = entity:get_game():get_map()
local hero = entity:get_map():get_entity("hero")

-- Chest example : Small Key (code from : Big chest example : Master Key)

-- Hud notification : check hero & entity direction and tell by the way of a hud info if it can be opened
entity:add_collision_test("touching", function()
if not open and hero:get_direction() == entity:get_direction() then
game:set_custom_command_effect("action", "open")
else
game:set_custom_command_effect("action", nil)
end
end)

function entity:on_created()
  self:set_drawn_in_y_order(true)
  self:set_can_traverse("hero", false)
  self:set_traversable_by("hero", false)

-- check if open
if open then
self:get_sprite():set_animation("open")
end

end

function entity:on_interaction()

local x,y = entity:get_position()
local hero = entity:get_map():get_entity("hero")

if not open then
open = false
end

  if hero:get_direction() == entity:get_direction() and not open then
       if entity:get_direction() == 0 then --right
           hero:set_position(x-16, y)
       elseif entity:get_direction() == 1 then --up
           hero:set_position(x, y+16)
       elseif entity:get_direction() == 2 then --left
           hero:set_position(x+16, y)
       elseif entity:get_direction() == 3 then --down
           hero:set_position(x, y-16)
       end

    hero:freeze()
    game:set_pause_allowed(false)

    sol.timer.start(1,function()
            hero:set_animation("drop")
    end)

    sol.timer.start(200,function()
           if hero:get_direction() == 3 or hero:get_direction() == 1 then
            hero:set_animation("stopped")
           else
            hero:set_animation("grabbing")
           end
    end)

    sol.timer.start(300,function()
           if hero:get_direction() == 0 or hero:get_direction() == 2 then
            hero:set_animation("stopped")
           end
    self:get_sprite():set_animation("open")
    sol.audio.play_sound("/common/chest_open")
    end)
     
    sol.timer.start(600,function()
    hero:set_animation("stopped")
    if hero:get_direction() == entity:get_direction() then
       if entity:get_direction() == 0 then --right
           hero:set_direction(3)
       elseif entity:get_direction() == 1 then --up
           hero:set_direction(2)
       elseif entity:get_direction() == 2 then --left
           hero:set_direction(3)
       end
      end
     end)

    sol.timer.start(750,function()
    hero:set_animation("chest_holding_before_brandish")
    end)

    sol.timer.start(1500, function()
    hero:unfreeze()
    hero:start_treasure("small_key")
    hero:set_animation("brandish_alternate") -- overwrite the default brandish animation for this particular item
    game:set_pause_allowed(true)
    hero:set_direction(entity:get_direction())
    open = true
    end)

    elseif not open then
      game:start_dialog("gameplay.cannot_open_chest_side")
end
end


It works fine when loaded in-game (though it can be optimized), the chest, animation, interraction and treasure works fine, same for the logic (if it is open then you can't re-open it), the issue is, if I place some copies of the same entity on the same map / another map, it acts as it was opened because it re-use the same way than the 1st chest do. And I want this script to be  copied, used and functionnal on many dungeon maps without recreating a code for each chest

I don't have many idea so I don't really know if that would work and I don't really know how to render this possible, i'm stuck with this issue, if someone have any idea, I'm on.
#57
Hello

I'm facing a issue with a basic custom entity (rewriting the chests), in on_created, i do follow the instructions by adding

Code (lua) Select
  self:set_can_traverse("hero", false)
  self:set_traversable_by("hero", false)
  self:set_traversable_by("hookshot", false)
  self:set_traversable_by("arrow", false)
  self:set_traversable_by("destructible", false)


the thing is, the hero cannot traverse the door, except if he has a certain item, but the hookshot,arrow and destructible don't work, they go through the entity, even if set_traversable_by is false.

I'm using Christopho's LUAs'd hookshot and bow scripts, that might be the issue, but I don't understand why it don't work for the destructible

Oh by the way, do you know a way to disable menu access during a cutscene ? hero:freeze() still allow to access the pause menu  ???

thanks for the answer
#58
Hi
I was wondering if there is a way to add sound like random listed sound when using the sword ? I've tried to add sol.audio.sound_play in the sword item script with 'item:on_using()' but it doen't play the sound at all.
Oh and also is there a chance of someone to re-code in LUA the sword for making sword skills easily ?
#59
Your projects / The Legend of Zelda
October 13, 2015, 03:10:54 PM
THIS THREAD IS SUBJECT TO CHANGE, RESERVED

This is a port of a old running fan game I was developping in the past 4 years in RPG Maker XP, and I succeed to get to it's limit, so I discovered Solarus and so I decided to port the game on this engine with amelioration, gameplay and mapping wise.
There is still not so much to show yet, as I am mostly porting the tilesets /  musics and remaking every maps, there are some finished maps with working stuffs currently.
Here's a sneek peak.

Water Temple, everyone loves Water Temple right ?
The blue bar is sort of "life bar" while plunging, if the bar is empty while being under water, without the Zora tunic, you'll drawn and insta death, the bar replenishes itself when you're out of the water, instantly after surfacing if you have the zora tunic watchout for that. The lengh of the bar depend on which version of flippers you have.

This dugeon was cut in the RPG Maker version due to layers and eventing limitation, it is returning in the Solarus version.




Exterior graphic
Castle Entrance with a nice bug, the water bar spawn whereas it shouldn't spawn here, same as the bars


Deep in the woods

Some village


Some place from previous Zelda games are presents (the Sanctuary from ALTTP) but showing them while they does already exist is a non-sense

I'll update some info soon.

Some ressources comes from wrightmat's project atm, I'm using and modifying some of his thing to learn and to save time (mostly the reconvertion of the stamina to a alternate life bar)
Graphics are from Parallel Worlds + mods, Solarus, various Zelda and Nintendo, some are personnal
#60
Development / Camera zooming function ?
October 13, 2015, 03:07:59 PM
I was thinking if a system of that sort is do-able in the solarus engie, you know, a zooming function, mostly useful for cutscenes, puzzle enigma hint, etc

I found a script of this sort, but for the LOVE engine, if someone is interested of porting it to Solarus, here it is :
https://github.com/vrld/hump/blob/master/camera.lua

I'm not experienced enough with the engine to port it :(