How to jump straight into a map without intro

Started by Slicky, August 07, 2016, 08:08:08 AM

Previous topic - Next topic
Hey guys, I was wondering if there was anyway for you to jump straight into any map that you are working on to test something rather than having to wait through your intro or menu screens just to get to it. Hope I made that kind of clear, but I was just wondering if that was a feature and maybe it could be in the future? Thanks guys!

You could always replace the default destination entity to the map you want to test, then in the main.lua (or the game_manager.lua) script, change the name of the starting location to the one you need to test (starting locations are relative, which means if the map you want to test is in a sub folder you will need to specify the sub folders as well.  starting locations are case-sensitive!!!).  That's the only way I know how to do it unfortunately >.<
My tilesets page can be found here:
http://absolute-hyrule-tutorials.solarus-games.org/

Yea I know how to do that, but I was hoping for a really quick way to just jump in and test something really quick. Thanks for helping out though! Maybe it will be something that could be implemented in the future!

August 07, 2016, 01:02:37 PM #3 Last Edit: August 07, 2016, 02:33:08 PM by MetalZelda
Edit : Tested, work

Place this script on the top of main.lua


Code (lua) Select

local starting_map = "your_map"
local destination = "your_destination" or nil -- if nil then the destination = debug, if not found then it will teleport you to the default destination
local use_debug = true -- set to false if you don't want to playtest anymore

-- put here the values you want to save like so
-- {"your_savegame_variable", your_value},

local values_to_save = {
  {"i1025", 0}, -- these one are essential to the file, don't remove it
  {"i1024", 0}, -- these one are essential to the file, don't remove it
  {"player_name", "Debug"} -- If using MoS engine, this might be useful
}

-- put here the values you don't want to save like so
-- {"your_savegame_variable", your_value}
-- Remark: If you save manually (from your pause menu or by calling game:save()) these will be saved
-- They are just not saved when the script (set_debug_location) is called, unlike values_to_save

local values_to_not_save = {}

function sol.main.set_debug_location(map_id, destination)
  destination = (destination == nil) and "debug" or destination

  -- creates a savegame that runs this and start it.
  local name = "debug.dat"
  local file = sol.game.load(name)

  file:set_max_life(4 * 14)
  file:set_life(file:get_max_life())
 
  for i = 1, #values_to_save do
    file:set_value(values_to_save[i][1], values_to_save[i][2])
  end

  file:get_item("tunic"):set_variant(1)
  file:set_ability("tunic", 1)
  file:set_ability("shield", 1)
  file:get_item("sword"):set_variant(1)
  file:set_ability("sword", 1)

  -- set a starting location for this file
  file:set_starting_location(map_id, destination)

  file:save()
 
  --run it, if not, modify the path to game_manager (if it exist)
  local game_manager = sol.main.load_file("scripts/game_manager")
  game_manager(file)

  -- Values that are not saved here, unless you save manually (from a menu or by calling game:save())
  for i = 1, #values_to_not_save do
    file:set_value(values_to_not_save[i][1], values_to_not_save[i][2])
  end
end

if use_debug then
  sol.main.set_debug_location(starting_map, destination)
end



Normally, the solarus logo should be continuing playing if you straight start the game like so, but when finished, the hero might unfreeze and you can playtest.

Personally, I have debug keys in my game to test map quickly. I use this script: https://github.com/christopho/zelda_olb_se/blob/dev/data/scripts/debug.lua
When a file called "debug" exists, the user has a lot of shortcuts. For example, you can traverse walls with Ctrl, walk much faster with R, skip dialogs with Shift, and to answer your question, skip title screens and menus with 1, 2 or 3 (directly loading the corresponding savegame file).

I tried copying over the debug script and I set it all up, but now nothing is happening when I launch. I think I have some other issues that are preventing it from working because I even copied all of the scripts from your script folder and the main, but it won't even launch when I do that.

Copy debug.lua somewhere and call it from your main.lua like I do. See the comments explaining how to use it. (You need to create a file called "debug" in your savegames directory to enable the debug keys.)