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

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

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

4
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.

5
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):

6
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")

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

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

9
Bugs & Feature requests / Re: Tileset upate script in Lttp pack
« on: September 01, 2019, 04:37:05 pm »
hmm... looking into it some more it seem that the usage example given is wrong. From the code it looks like it just wants:
Code: [Select]
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:
Code: [Select]
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.

10
Bugs & Feature requests / Re: Tileset upate script in Lttp pack
« on: August 31, 2019, 02:42:00 pm »
The script gives the following usage example:
Code: [Select]
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.

11
Development / Re: Enemy sprite layers
« on: August 12, 2019, 02:41:19 pm »
You could make an enemy that creates another enemy on a different layer using map:create_enemy(), and then the script for the first enemy always moves the second enemy to be at its same location. It would then appear to be a single enemy. You'd probably want to make it so damaging enemy #2 causes damage to enemy #1 and also remove enemy #2 when #1 is killed.

12
Development / Re: How to configure game window
« on: August 05, 2019, 05:04:10 am »
The problem has to be reported in order to be fixed.

13
Development / Re: How to configure game window
« on: August 04, 2019, 09:39:26 pm »
On second thought, my quest doesn't actually have any scrolling screens (I was going to have one but removed it). Come to think about it, I may have reworked my quest to not have any side-scrolling maps because I encountered the same issue you did (it's been a while and I am forgetting).

I tested my quest out with a side-scrolling map and have similar issues to what you describe.

You'll probably get better traction with this problem if you open an issue on the gitlab repository: https://gitlab.com/solarus-games/solarus/issues

14
Development / Re: How to configure game window
« on: July 30, 2019, 01:24:39 am »
on_map_changed passes the map as an argument. Use that instead of game:get_map().

Code: (lua) [Select]
local function set_camera(game, map)
  local camera = map:get_camera()
  camera:set_size(256, 160)
  --camera:set_position_on_screen(0, 16)
end

In one of my projects I used the map:on_started() event instead of game:on_map_changed(). You could try that if the above still does not work. My code was as follows:

Code: (lua) [Select]
--// Setup the map to be displayed in the upper-right corner of the screen (all maps)
local map_meta = sol.main.get_metatable"map"
map_meta:register_event("on_started", function(self)
local camera = self:get_camera()
camera:set_size(320, 240)
camera:set_position_on_screen(304,16)
end)

15
Your scripts / Re: Enemy drop rate and multiple item drops
« on: July 13, 2019, 05:32:03 pm »
You are constantly reseeding the RNG, which will actually make things less "random". You should only set the random seed once when you start a game.

Pages: [1] 2 3 ... 14