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

#1
Your scripts / Pushable block reimplemented in Lua
June 29, 2019, 05:15:32 PM
Daniel and I wanted to create pullable/pushable entities that aren't blocks. Below is a Solarus block entity reimplemented in Lua. It's almost an exact copy, except that when pushing, the hero does not continually display the "pushing" animation (only between movements). It's a minor issue but I'd appreciate any help to solve it. Here's the code:


-- Lua script of custom entity block.
-- By Daniel Molina and Alex Gleason, licensed under GPL-3.0-or-later

require("scripts/utils")

local entity = ...
local game = entity:get_game()
local map = entity:get_map()


-- Moves an entity in the 16x16 grid
local function grid_movement(d4)
  local m = sol.movement.create("straight")
  m:set_max_distance(16)
  m:set_speed(30)
  m:set_angle(d4_to_angle(d4))
  return m
end

-- Event called when the custom entity is initialized.
function entity:on_created()
  self:set_traversable_by(false)
  self:set_can_traverse(false)
  self:set_drawn_in_y_order()
  self._cooldown = sol.timer.start(self, 0, function() end)
end

-- Handle the hero pushing/pulling the entity
function entity:on_update()
  local hero = game:get_hero()
  local d4 = hero:get_direction()

  if not self:can_move() then
    return -- skip
  end

  if self:is_being_pushed() then self:push(d4) end
  if self:is_being_pulled() then self:pull(invert_d4(d4)) end
end

-- Push the entity
function entity:push(d4)
  log("Entity is being pushed")

  -- Set hero state
  local hero = game:get_hero()
  hero:freeze()
  hero:get_sprite():set_animation("pushing")

  -- Move entity
  local m = grid_movement(d4)
  function m:on_obstacle_reached()
    entity:stop_movement()
    hero:unfreeze()
  end
  m:start(self, function()
    entity:stop_movement() -- HACK: solarus-games/solarus#1396
    entity:snap_to_grid()
  end)

  -- Move hero
  local m_hero = grid_movement(d4)
  m_hero:set_smooth()
  m_hero:start(hero, function()
    hero:unfreeze()
    hero:start_grabbing()
    entity:start_cooldown()
  end)
end

-- Pull the entity
function entity:pull(d4)
  log("Entity is being pulled")

  -- Set hero state
  local hero = game:get_hero()
  hero:freeze()
  hero:get_sprite():set_animation("pulling")

  -- Move entity
  local m = grid_movement(d4)
  m:start(self, function()
    entity:stop_movement() -- HACK: solarus-games/solarus#1396
    entity:start_cooldown()
    entity:snap_to_grid()
  end)

  -- Move hero
  local m_hero = grid_movement(d4)
  m_hero:set_smooth()
  function m_hero:on_obstacle_reached()
    hero:unfreeze()
    hero:start_grabbing()
    entity:stop_movement() -- HACK: solarus-games/solarus#1396
  end
  m_hero:start(hero, function()
    hero:unfreeze()
    hero:start_grabbing()
  end)
end

-- Check if hero can move the entity (boolean)
function entity:can_move()
  return not self:is_moving() and self._cooldown:get_remaining_time() == 0
end

-- Check whether the entity is currently being pushed/pulled (boolean)
function entity:is_moving()
  return entity:get_movement() and true or false
end

-- Check whether the entity is being pushed (boolean)
function entity:is_being_pushed()
  local hero = game:get_hero()
  return self:overlaps(hero, "facing") and hero:get_state() == "pushing"
end

-- Check whether the entity is being pulled (boolean)
function entity:is_being_pulled()
  local hero = game:get_hero()
  return self:overlaps(hero, "facing") and hero:get_state() == "pulling"
end

-- Cooldown between pulling/pushing by 1 tile
function entity:start_cooldown()
  self._cooldown:stop()
  self._cooldown = sol.timer.start(self, 500, function() end)
end


It requires some utility functions, found here: https://gitlab.com/voadi/voadi/blob/feb500f3e3325d99dc394398ecbb1c7dc5710b23/data/scripts/utils.lua

Here's the upstream file: https://gitlab.com/voadi/voadi/blob/56118adfe3516a1ea8ce816e4f46422576d6b976/data/entities/mirror.lua
#2
For the past week the bridge has been broken. I can see all your messages from Discord just fine, but you can't see any of our Matrix messages. It's a known issue, but the Matrix team is going through some hard times right now because the matrix.org homeserver was recently hacked, so there's nobody able to fix the problem right now. Hope it gets fixed soon!

I invite you to join us on Riot in the meantime: https://riot.im/app/#/room/#voadi:matrix.org
#3
Development / Re: Weird Stairs Issue
April 24, 2019, 06:33:42 PM
I placed a $5 bounty on solving this issue using a single custom entity: https://gitlab.com/voadi/voadi/issues/106
#4
Quote from: llamazing on April 03, 2019, 02:12:18 AM
Solution #3 is possible with shaders that were just introduced in Solarus v1.6. Seem like more effort than it's worth to me. I suppose if you were strictly dealing with palette swaps, then it might not be too bad.

I think it's also possible by drawing a surface of a particular color and using a blend mode.
#5
I'm considering including a 'photo' of the NPC in the dialog box (kinda like Golden Sun). This is making me question whether putting the NPC name directly in the dialog box is the best solution.

Rather than switching between speakers mid-dialog, there could be separate dialogs for each speaker in a conversation, each with their own properties.
#7
Your scripts / Re: Dialog Box script with Name Displayed
February 26, 2019, 04:16:59 PM
Here's an example:



I might change the way it looks later, just wanted to get it working for now.

My other changes:

- 3 line text rather than 2 line
- narrower box
- use item_1 instead of attack to skip

Some of my changes were stupid because I didn't fully understand the Solarus API when I made them. I'd like to go back and improve it.
#8
Your scripts / Re: Dialog Box script with Name Displayed
February 25, 2019, 09:10:11 PM
I implemented this in VOADI - thank you!

I was concerned that it would be hard to merge with my existing script (I modified it from Christopho's original) but Meld made it easy to see the diff side-by-side and click the changes over.

I'm excited to see the impact this feature will have on the quality of my dialogue.
#9
This is a super awesome project using Solarus: http://beckylavender.co.uk/portfolio/the-zelda-dungeon-generator/

And it's heavily documented, making it even better!! http://beckylavender.co.uk/wp-content/uploads/2017/11/ZDG_Dissertation.pdf

I'm surprised we'd never heard from this person before - I'm going to reach out to her.
#10
General discussion / Discord <-> Matrix bridge status
February 16, 2019, 05:17:11 PM
Hey all,

Going forward I'm going to use this thread to update the status of the bridge in case anything happens.

Currently (Feb 16, 2019 @ 11am) the bridge is down. The developer was last seen about 12 hours ago saying:

QuoteI've updated the Telegram and Discord bridges. The Discord bridge looks to be taking a bit longer to actually apply the update though, and might be down for longer than expected.

This is the longest period of time the bridge has been down since we first set it up December 9th. The rooms are still accessible to Matrix users, they just aren't syncing messaging to/from Discord.
#11
General discussion / 4-color CC0 tileset (8px tiles)
February 16, 2019, 04:16:54 AM
This tileset looks very cool: https://stealthix.itch.io/4-colour-tileset

It's the first free 8x8 tileset I've seen that would be a good fit for Solarus. The only problem is that many prebuilt entities need to be 16x16 (including the hero). But you can probably get around this with a bit of hacking in the scripts. It would be interesting to see someone build a tiny game with this.
#13
You're welcome! Glad I could help.  :)
#14
Development / Re: combos...again
February 11, 2019, 08:53:22 PM
I'd probably create an "attack queue" on the hero.

It's a history of recent attacks, stored as a Lua table.

When you press "attack":
1. The game reviews the current attack queue,
2. determines what the attack action will be based on that queue,
3. then performs the attack action
4. and pushes it on the queue.

You could add a cooldown timer to the hero, like `hero.cooldown = sol.timer.start(hero, 1000, function() hero:reset_attack_queue() end)`

Then whenever you handle an attack, call `hero.cooldown:set_remaining_time(1000)` to reset the cooldown.

You will probably have to tweak this concept to make it really work, but this is the way I'd approach it.
#15
I was able to find these methods by searching the OLB GitLab repo for their names: https://gitlab.com/search?utf8=%E2%9C%93&search=are_small_keys_enabled&group_id=&project_id=6933859&search_code=true&repository_ref=dev

Check out scripts/equipment.lua, looks like it has what you need: https://gitlab.com/solarus-games/zelda-olb-se/blob/dev/data/scripts/equipment.lua