Recent posts

#71
Development / Are there any examples for the...
Last post by gzuk - November 06, 2022, 11:48:09 AM
Hello, I read on the forums that you could use the new module coroutine_helper.lua to build cutscenes, to avoid endlessly nested callbacks.

However, I couldn't get it to work. I could only get one-time events to work, like playing a sound. I couldn't get the "only if game available" features to work, probably because I didn't make the game available in the right way.

Is there perhaps a working coroutine_helper game or example available, that uses the more complicated "only if game available" features, like dialogue, or characters moving around?

Many thanks for an answer!  :)
#72
Game art & music / Re: Lake Tileset with Animatio...
Last post by embarrassfat - October 30, 2022, 05:11:00 AM
This looks amazing. I like the logs.
#73
Development / Re: Making 3 wall blocks get d...
Last post by aaa - October 27, 2022, 05:14:58 PM
Thank you so much!!!
#74
Development / Re: Making 3 wall blocks get d...
Last post by Christopho - October 27, 2022, 08:57:26 AM
Check the new tutorial playlist here: https://www.youtube.com/playlist?list=PLzJ4jb-Y0ufwkbfy49F_NrLtxCAiGJw5r
Episode #57 covers exactly that (making something happen when torches are lit), but you first need all the basics including custom entities (episode #54). Have fun!
#75
Development / Making 3 wall blocks get delet...
Last post by aaa - October 27, 2022, 05:25:04 AM
Hello! I have little to no experience with programming, but I want to make a room with a route blocked by 3 wall blocks, and I want the route to become accessible once 2 torches are lit. How can I do that? Thank you very much!
#76
Development / Re: Make 2nd hero un-attackabl...
Last post by gzuk - September 24, 2022, 09:18:03 PM
Thank you very much. I've checked out your additions, and the on_attacking_hero function works very well. If you define it on both heroes and leave it empty, then the heroes won't hurt each other any more, like for a coop game.

I'll play around some more with the multiple heroes, and make a new post when something else comes up.
#77
Development / Re: Make 2nd hero un-attackabl...
Last post by stdgregwar - September 21, 2022, 11:02:48 AM
Hello !

You are right disabling friendly fire is a lacking feature. I added a way to do it in this merge request : https://gitlab.com/solarus-games/solarus/-/merge_requests/1421

It adds the `on_attacking_hero` event that can be used to short circuit the default behavior and decide what to do. To disable the friendly fire quest-wide you can add the event to the hero's metatable.

Thank you for testing the multiplayer features !

#78
Development / Re: Make 2nd hero un-attackabl...
Last post by gzuk - September 19, 2022, 08:57:48 PM
I saw that you can call state:set_can_be_hurt on a state object. And in the parameter function you could probably check if the attacker is another hero, and then do nothing. But I'd have to set that on all the default states ("free", "running", "sword swinging" etc.), and I don't know where these states are created or stored. Does anyone know how I could get a handle on all the default states?
#79
Development / Make 2nd hero un-attackable by...
Last post by gzuk - September 15, 2022, 09:37:01 AM
Hi, I tried out the new multiple heroes feature, but the default seems to be a player vs. player setup. The heroes hurt each other with their attacks, as in the "friendly fire" test map. For a coop quest, it would be nicer if you could also configure them to be immune to each other's attacks.

There are functions on the "enemy" type to configure attack reaction (set_attack_consequence), but these functions don't seem to exist on the "hero" type. In the CPP files, there are even more functions (is_sword_ignored), but it seems they have no Lua bindings.

Have I maybe overlooked an easy way to set this up? Or could it be implemented easily?
#80
Development / Re: Have a 2nd hero move, atta...
Last post by gzuk - September 14, 2022, 10:56:26 PM
Ah, I got it working by registering "on_map_changed" for the game metatable. If added to main.lua on the current develop branch, the following script will on every entered map spawn a 2nd hero in blue next to the 1st one, controlled with the WASD keys. They both hurt and are hurt by enemies, and can coop-kill them together. Neat. There's still plenty of stuff to add, but I'll ask that in other posts.

A big thanks to all devs for the 2nd hero addition, and everything else!  :)


local game_meta = sol.main.get_metatable("game")
game_meta:register_event("on_map_changed", function()
  local map = sol.main.get_game():get_map()
  local hero1 = map:get_hero()
  -- Adjust controls for hero 1.
  hero1:get_controls():set_keyboard_binding("pause", "p")
  hero1:get_controls():set_keyboard_binding("attack", "right control")
  local x, y, layer = hero1:get_position()
  hero1:set_position(x + 8, y, layer)
  -- Create hero 2 next to hero 1, with WASD controls.
  local hero2 = map:create_hero({x = x - 8, y = y, layer = layer})
  hero2:set_name("hero2")
  hero2:get_controls():set_keyboard_binding("pause", "")
  hero2:get_controls():set_keyboard_binding("up", "w")
  hero2:get_controls():set_keyboard_binding("left", "a")
  hero2:get_controls():set_keyboard_binding("down", "s")
  hero2:get_controls():set_keyboard_binding("right", "d")
  hero2:get_controls():set_keyboard_binding("attack", "left alt")
  hero2:set_tunic_sprite_id("hero/tunic2")
  -- Give them swords and extra life for testing.
  hero1:set_ability("sword", 1)
  hero2:set_ability("sword", 1)
  hero1:set_max_life(16)
  hero1:set_life(16)
  hero2:set_max_life(16)
  hero2:set_life(16)
end)