Recent Posts

Pages: 1 ... 8 9 [10]
91
Development / Missing resources
« Last post by HylianUsual on March 26, 2022, 08:54:50 PM »
Hi. I have Solarus v. 1.6.5 installed as a snap on Xubuntu 20.04 and I've just started a project. The "entities" folder is empty and I'm missing at least one sprite from "destructibles". Any help?
92
Development / Re: How to mantain the chest activated?
« Last post by leon on March 19, 2022, 08:30:07 PM »
Hello!

I made it!

Thank you for your help!
93
Development / Re: How to mantain the chest activated?
« Last post by leon on March 01, 2022, 07:47:56 PM »
Right, I will try again! Thank you!
94
Development / Re: How to mantain the chest activated?
« Last post by Christopho on February 23, 2022, 09:45:23 AM »
game:set_value() is documented here: https://www.solarus-games.org/doc/1.6/lua_api_game.html#lua_api_game_set_value
It sets a variable that can be saved in the savegame file, which is what you want if I understand correctly. So that the information (the switch state) is preserved when the player leaves and reenters the map, or even if they save and quit. You just need to choose a name for your saved variable, in my code snippet I put "mymap_interruptor_a" as an example but it is up to you to choose a relevant name. And the value is a boolean: true to indicate that the switch is activated, false (or unset) otherwise.

Then in map:on_started(), call game:get_value() to retrieve the state of the switch, and if it is saved as activated, then activate it with interruptor_a:set_activated(true).

If you are lacking Lua basics in general, I would recommend the Programming in Lua free guide: https://www.lua.org/pil/contents.html

PS: I just check tutorial 17. In that tutorial, I use the state of the treasure chest (which is automatically saved, as set by a checkbox in the quest editor) to guess the state of the switch, so actually I don't have to do all that.
95
Development / Re: How to mantain the chest activated?
« Last post by leon on February 22, 2022, 08:18:35 PM »

I´m sorry, I can´t understand (I´m noob).

What I must to learn to understand this line of code that you showed?
96
Development / Re: How to mantain the chest activated?
« Last post by Christopho on February 21, 2022, 10:29:06 PM »
The state of the switch is not saved automatically: you have to save it explicitly. In other words, this condition is always false in map:on_started() (when the map starts):
Code: [Select]
elseif interruptor_a:is_activated() then
But you can save the state of the switch yourself when the switch gets activated, with
Code: [Select]
game:set_value("mymap_interruptor_a", true)and test that in map:on_started().
97
Development / How to mantain the chest activated? (Solved!)
« Last post by leon on February 21, 2022, 08:16:20 PM »
Hi,

I want the chest to stay activated when I hit the switch, even if it hasn't opened. So when I leave the map and return, the chest remains visible and the switch has already been activated.

I tried this, but without success.

The reference is the lesson 17 on YT.

here´s the code,  first_map.lua

Code: [Select]
function map:on_started() 
  if bau_tunica:is_open() then  --"BAU_TUNICA" IS THE CHEST
    bau_tunica:set_enabled(true)
    interruptor_a:set_activated(true)  --"INTERRUPTOR_A" IS THE SWITCH
  elseif interruptor_a:is_activated() then  --this is my attempt
    bau_tunica:set_enabled(true)
  end
end

function fogo:on_interaction()
  game:start_dialog("salvar_jogo-perguntar", function(resposta)
    if resposta==1 then
      game:save()
      game:start_dialog("jogo_salvo")
    end
  end)
end

function interruptor_a:on_activated()
  sol.audio.play_sound("cursor")
  bau_tunica:set_enabled(true)
end

98
Your projects / Re: Ocean's Heart
« Last post by milirlly on February 16, 2022, 04:34:30 PM »
Whoa, this forum is still active?
99
Development / Re: sprites is a directory
« Last post by Spikira on February 11, 2022, 02:51:01 AM »
100
Development / sprites is a directory
« Last post by Peter on January 26, 2022, 10:05:40 PM »
When I start my game I get this error message:
Quote
Info: Fullscreen: no
Info: Language: en
Info: Lua console: yes
Info: Turbo mode: no
Info: Simulation started
Fatal: Data file 'sprites/' is a directory

What is causing this?

(My game is rather small. 2 rooms and one self-made item.)
Pages: 1 ... 8 9 [10]