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

#16
Your problem is line 210 of scripts/fsa_effect.lua

I'm guessing the line is something like:
Code (lua) Select
light_entity:register_event("on_enabled", true)

or perhaps:
Code (lua) Select
light_entity:register_event("on_enabled", light_entity:is_enabled())

where basically what you are passing as the second argument to register_event() is a boolean value, where it should be a function. Like so:
Code (lua) Select
light_entity:register_event("on_enabled", function()
  --do the things that should happen when the light is enabled here
end)


If you still need help then paste the code of your setup_inside_lights() function in your fsa_effect.lua script and indicate which line is line 210.
#17
Here's how you can pinpoint the line of code giving you problems:

Edit your multi-events script to add the following line after line 72 (extra lines shown for context)
Code (lua) Select
local function register_event(object, event_name, callback, first) --line 72
  assert(type(callback)=="function", "callback must be a function!") --add this new line
  local events = get_events(object) --line 73
  if (not events[event_name]) and safe_rawget(object,event_name) then --line 74


This will give you an error pointing you to the line with bad syntax for the register_event() function. Then revert the multi-events script back to how it was originally.
#18
Development / Re: Help with name display code
January 07, 2020, 05:20:47 AM
Oops, I tried to hint at how to fix that problem in my last post. I must have not been clear enough.

Change this:
Code (lua) Select
    if not sol.game.exists(file_name) then
      games[i] = nil
    else
      -- Existing file.
local game = game_manager:create(file_name)
games[i] = game

-- Player name get or use EMPTY
if sol.game.exists(file_name) then
player_name_text:set_text(game:get_value("player_name"))
else
local name = "- " .. sol.language.get_string("savegames_menu.empty") .. " -"
player_name_text:set_text(name)
end
    -- Draw hearts and player name.
draw_hearts(game, surface)
player_name_text:draw(surface, 64, 8)
    end


To this:
Code (lua) Select
    if not sol.game.exists(file_name) then
      games[i] = nil
    else
      -- Existing file.
local game = game_manager:create(file_name)
games[i] = game

-- Player name get or use EMPTY
if sol.game.exists(file_name) then
player_name_text:set_text(game:get_value("player_name"))
else
local name = "- " .. sol.language.get_string("savegames_menu.empty") .. " -"
player_name_text:set_text(name)
end
    -- Draw hearts and player name.
    end
draw_hearts(game, surface)
player_name_text:draw(surface, 64, 8)


i.e. move the draw call to outside of the end block (so it happens on the empty condition as well).

FYI-- you'd probably get a faster response if you asked questions like these on discord instead of the forums.
#19
Development / Re: Help with name display code
January 05, 2020, 06:00:45 AM
looks like your problem is this line:
Code (lua) Select
player_name_text:draw(surface, 90, 16 + i * 48)

You are drawing the text surface to surface, where surface is only 16 pixels tall. So it makes no sense to be drawing to a y coordinate of 16 + 48 = 64 pixels when i==1, which is beyond the edge of the surface and thus will not be visible. You'd want a y coordinate of 0 if your text is vertically aligned by "top", but I think you are using "middle" in which case it should be half the height of the text.

btw, you want to do that draw() line for both cases whether the savegame file exists or not, so it should be moved outside of the if..else block (not the cause of your immediate problem, but will your next problem to deal with).
#20
Here's a tutorial I put together explaining how to create seamless loops for .ogg music using the metatags LOOPSTART and LOOPEND.

It assumes you have an existing music file and explains how to find the values to use for the start and end of the loop. The free audio editor Audacity is used.

https://gitlab.com/llamazing/solarus-scripts/-/wikis/ref/tutorials/creating_music_loops
#21
Awesome idea  ;D

I'll mention that this is intended to be a map script in case that is not obvious.

It could be improved by deactivating the puzzle once the player has solved it. This could be done simply by setting switch_index to nil once solved, then checking it at the beginning of the map:process_switch() method:
Code (lua) Select
function map:process_switch(name)
  if switch_index then --add this line
    if switches[switch_index] == name then --unchanged (for context)
      --lines in between unchanged
    end --unchanged
  end --add this line
end


Also could be useful to save the state of the solved puzzle as a savegame variable so that the player doesn't have to solve it again when revisiting the map later. Simply save the savegame variable once the puzzle is complete:
Code (lua) Select
game:set_value("puzzle_complete", true)
Then change the first line of the script to the following:
Code (lua) Select
local switch_index = not game:get_value("puzzle_complete") and 1
#23
Bugs & Feature requests / Re: Cutscene builder bug
October 29, 2019, 12:11:11 AM
Quote from: wrightmat on October 28, 2019, 06:38:05 PM
Sorry to necropost a bit, but I've been playing around with this coroutine_helper script and wondered if there was any additional documentation.

The documentation is in the form of a comment at the top of the script file.

Quote from: wrightmat on October 28, 2019, 06:38:05 PM
For example, I don't understand what wait_for might be used for - are there example of specific engine functions that this might utilize this?

wait_for() is a generic implementation of "wait for a function with a callback to complete". You can use it with any function whose last argument is a callback function (the coroutine script supplies the callback so you don't have to).

Example:
Code (lua) Select

map:start_coroutine(function()
  wait_for(map.move_camera, map, 100, 0, 128)
  dialog("sample_dialog")
  wait(100)
  wait_for(hero.start_treasure, hero, "ultimate_sword", 1, nil) --nil for unused savegame_variable parameter
  print("done!")
end)


Which is basically equivalent to:
Code (lua) Select

map:move_camera(100, 0, 128, function()
  game:start_dialog("sample_dialog", nil, function()
    sol.timer.start(map, 100, function()
      hero:start_treasure("ultimate_sword", 1, nil, function()
        print("done!")
      end)
    end)
  end)
end)


The first example is easier to read, isn't it? 8)

Be sure you are using the latest version of the coroutine_helper script because there was a bug in specifying nil parameters in the wait_for() function. See https://gitlab.com/solarus-games/solarus-free-resource-pack/issues/16

Quote from: wrightmat on October 28, 2019, 06:38:05 PM
You also specifically pointed out hero:freeze - was this saying this function would NOT work with this coroutine setup? I'm having sporadic issues with hero:freeze working, either inside or outside of the coroutine, so I wasn't sure if that was known behaviour.

I think the point stdgregwar was making is that hero:freeze() would not have worked in the old cutscene builder script, but it does work in with the coroutine helper script (as does any function that doesn't require waiting). If a function does require waiting and isn't already setup to be used in the coroutine helper script, then you'd have to edit the coroutine helper script to incorporate it (or get it to work using wait_for()).
#24
Your scripts / Re: Generate map images
September 15, 2019, 03:16:03 AM
I updated the script linked above to version 1.1.1.

Now there are warning messages when using export_world_map() if there are any overlapping maps or discontinuities are detected. These can be disabled respectively by setting IS_OVERLAP_WARNING and IS_DISCONNECT_WARNING to false at the beginning of the script.

I also added support for ignoring maps with an id matching a given pattern in the EXCLUDE_MAPS list.
#25
Your scripts / Generate map images
September 14, 2019, 03:23:28 PM
I revisited my script to generate images from a map .dat file. The original topic can be found here:
http://forum.solarus-games.org/index.php/topic,1122.0.html

Notable improvements:
*I adjusted the colors for a sleeker and more uniform appearance
*It now generate a composite image from all map layers
*It now exports an image file
*Can generate a "world" image of multiple maps linked by edge teletransporters
*Can generate individual images for all maps in a single operation

The image exported is a .ppm file, which has a very simple file format, but the file size is not optimal. The image can be converted to a .png using GIMP.

I experimented with a pure-lua library that generates png images, but it was slow and was actually generating the exact same sequence of bits, just with a different header (so there was no improvement in file size over the .ppm file). Maybe a better png library could be an option in the future.

Solarus crashes for me when trying to export an image of approximately 8000x8000 pixels or larger. I'm guessing this is some sort of memory limitation that is being exceeded (the outputted image would be over 100MB), but no error is given. The default SCALE_FACTOR is 8 (maps rendered at 1/8th original size), so this will probably not be an issue at this scale even when generating a world map image (unless you have a VERY big world map), just beware. I could possibly improve memory performance here by generating the image data one row at a time instead of doing the entire image at once if this becomes a problem.

Also note there are some bugs in Solarus v1.6 related to the drawing order (which are fixed in v1.6.2). I am not able to test in v1.6.2 right now, but the image might look slightly different.

https://gitlab.com/llamazing/solarus-scripts/blob/master/data/scripts/map_imager.lua
Usage:
Code (lua) Select

local map_imager = require"scripts/map_imager"
map_imager(map_id) --to generate one image for the specified map_id (string)
--equivalent to map_imager:export_map(map_id)
map_imager() --to generate images for ALL maps
--equivalent to map_imager:export_all()
map_imager:export_world_map(map_id) --to generate an image of the specified map_id (string) and any maps connected by edge teletransporters


When generating a world map image, it will also output coordinates of each map with 0,0 being the top-left corner. This could be useful if you need assistance in figuring out world coordinates of your maps.

Here is a world map generated from Ocean's Heart using "ballast_harbor/ballast_harbor" as the starting map (converted to png with GIMP):
#26
Development / Re: Text box appearing when getting an item
September 13, 2019, 11:20:57 PM
You need quotes on the dialog:
game:start_dialog("_treasure.sword.1")
#27
Development / Re: Text box appearing when getting an item
September 13, 2019, 12:53:45 AM
I think it's because the alttp resource pack does not set a language by default. On cursory examination it looks like there's some language selection menu you have to open to set it first.

add the line: sol.language.set_language("en")

You can also try starting a dialog manually with game:start_dialog(dialog_id) to test whether a language has been set. If it hasn't then you'll get an error saying the language is not set.
#28
Development / Re: Text box appearing when getting an item
September 12, 2019, 05:29:49 AM
You don't need any code in your sword.lua for the dialog to be shown, it's all automatic. The dialog for an item is always shown when you get an item from a chest (unless you didn't define its dialog).

The dialog displayed corresponds to the item name. So the "_treasure.sword.1" dialog is shown when you pick up the first variant of the sword, "_treasure.sword.2" when you pick up the second variant. The dialog "_treasure.boomerang.1" is shown when you pick up the first variant of the boomerang, etc.
#29
hmm... looking into it some more it seem that the usage example given is wrong. From the code it looks like it just wants:
lua update_maps_to_rearranged_outside_tilesets.lua full_path_to_map_file_1.dat full_path_to_map_file_2.dat

where it is simply calling:
io.open("full_path_to_map_file_1.dat")
io.open("full_path_to_map_file_2.dat")
etc...


So yes, you have to specify the full path to a map (including the map file itself) and you have to input it for ever map you want to convert.
#30
The script gives the following usage example:
Usage: lua update_maps_to_rearranged_outside_tilesets.lua quest_path map_file_1.dat ...

I think it is not meant to be run from within Solarus. Try opening a terminal and entering the above line. And definitely make a backup of your files first.