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.


Messages - llamazing

Pages: [1] 2 3 ... 14
1
Development / Re: Audio buffer error
« on: July 28, 2020, 01:34:33 pm »
Are you on a Mac? I see this error when certain music files end if using my Mac but I don't ever see the error on my Linux machine.

2
If you set-up the quest editor to use ZeroBrane as an external editor for lua scripts, it includes auto-completion (in addition to some extra debugging features):
https://www.solarus-games.org/en/development/tutorials/solarus-official-guide/tools/zerobrane

3
Your scripts / Dialog_Box script to change font
« on: February 06, 2020, 01:59:55 pm »
It was asked on Discord how to change the font used in the dialog_box script for certain dialogs.

Here's an updated script where you can assign the font and font_size properties to a dialog entry to specify what to use, otherwise it will use default values.

Original author: Christopho, GPLv3

4
Development / Re: Strange problem with a "set_enabled()"
« on: January 17, 2020, 01:21:55 am »
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.

5
Development / Re: Strange problem with a "set_enabled()"
« on: January 16, 2020, 02:06:03 am »
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.

6
Development / Re: Help with name display code
« on: 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.

7
Development / Re: Help with name display code
« on: 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).

8
Game art & music / Tutorial for Creating Seamless OGG Music Loops
« on: December 14, 2019, 07:44:02 pm »
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

9
Your scripts / Re: Do tasks in a certain order to open a door or whatever
« on: November 05, 2019, 12:50:21 am »
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

10
Bugs & Feature requests / Re: Cutscene builder bug
« on: October 30, 2019, 11:11:18 pm »

11
Bugs & Feature requests / Re: Cutscene builder bug
« on: October 29, 2019, 12:11:11 am »
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.

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

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()).

12
Your scripts / Re: Generate map images
« on: 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.

13
Your scripts / Generate map images
« on: 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):

14
Development / Re: Text box appearing when getting an item
« on: September 13, 2019, 11:20:57 pm »
You need quotes on the dialog:
game:start_dialog("_treasure.sword.1")

15
Development / Re: Text box appearing when getting an item
« on: 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.

Pages: [1] 2 3 ... 14