Quote from: Blueblue3D on July 17, 2019, 02:37:09 AM
Thanks for the reply. I've been fiddling for a while but I'm having trouble understand how Solarus organizes scripts. If I want to put a camera:set_size() call in game:on_started(), what script file would I put it in? Or would I make a new script?
You could create a new script. Not sure what your directory looks like but if you have nowhere to put it all ready you could create a game.lua file either in the scripts folder or, optionally, in a subfolder you create called meta.
The script would use metatables so if you aren't familiar with them, it may be confusing. I'm not entirely familiar with them so what I have to say will be pretty basic, I think. It would also require the multi_events script that the solarus team has generously shared with their game files.
The following should change the camera size everytime the game is started; although I can't say that this will be the best or most efficient way to do this:
Code Select
require("scripts/multi_events") --This is required for this script to work. It allows the script to be called on its own.
local game_meta = sol.main.get_metatable("game")
game_meta:register_event("on_started", function() local map = game:get_map()
local camera = map:get_camera()
camera:set_size(width, height) --size will be replaced with the size of the camera on screen.
--If your screen is the standard 320x240 then you could make
--the camera 320, 200 and it should leave a black bar at the bottom of the screen.
end)
then just require your game.lua script in either the main script (messy if you have to require too many scripts) or in another script that would then be called in the main lua. With the sample quest, I believe there is a script called features.lua that fills this purpose. It collects many scripts into one and then is required at the beginning of the main.lua.
so at the top of your main.lua you should type this:
Code Select
require("scripts/game") --If you saved it in the scripts folder. require("scripts/meta/game") if you added the subfolder.
unless you compile many of your scripts into one feature script; which is recommended.
Hope this helps.