i can't open a specific map, i have changed starting_location to open a map named (7) but Solarus quest editor starts the quest in the first map named (1). See the code below:
Quotelocal dialog_box_manager = require("scripts/dialog_box")
local game_manager = {}
-- Sets initial values for a new savegame of this quest.
local function initialize_new_savegame(game)
game:set_starting_location("Light-world/7")
game:set_max_money(100)
game:set_max_life(12)
game:set_life(game:get_max_life())
end
-- Creates a game ready to be played.
function game_manager:create(file)
-- Create the game (but do not start it).
local exists = sol.game.exists(file)
local game = sol.game.load(file)
if not exists then
-- This is a new savegame file.
initialize_new_savegame(game)
end
local dialog_box
-- Function called when the player runs this game.
function game:on_started()
dialog_box = dialog_box_manager:create(game)
end
-- Function called when the game stops.
function game:on_finished()
dialog_box:quit()
dialog_box = nil
end
return game
end
return game_manager
i also deleted .solarus folder to avoid starting a savegame but still have the same problem and the editor shows the followin
g error: Error: No valid destination on map 'Light-world/1'. Placing the hero at (0,0) instead.
I think the error means that you need to put a destination entity in the map (the default one will be the starting point).
Edit: however I do not understand why your game tries to start in the wrong map...
There are 3 solutions :
- Diarandor's one might be the one that cause your bug.
See http://www.solarus-games.org/doc/latest/lua_api_game.html#lua_api_game_set_starting_location
you need a destination on your map and set the destination name in set_starting_location(unnecessary if you put a default destination).
- The map pointer doesn't exist (typo), but even with a typo, it would send you to the 1st map found in the map folder (subfolders included)
If this is the case.
In the map editor, go to your map
Right click, rename
Copy the value in the box
Click Cancel
Paste it in the function
- The savegame isn't created
I've done everything that you said, I set a default destination in the map 7, I even set its exact name in set_starting_location but the editor always starts in the map 1!
It could be, as MetalZelda suggests, that the name of the map is misspelled.
Are you sure "Light-world/7" is the name of the map?
Make sure you do not have a map name like "Light_world/7" or something like that instead (you might have changed "-" by "_" by mistake, or something like that).
Edit: it could also be that the name of your map is just "7", instead of "Light-world/7".
i verified but all names are correct really weird. See the screenshot bellow
(http://s21.postimg.org/vn51phi3r/aaaaaaaa.png)
It could also be a problem of the Editor not allowing the "-" symbol in the name of a map, but this is unprobable. Does it work if you try it for other of the maps in the same folder?
I have run out of ideas :(
i've changed the folder's name, same problem, i also changed starting map but still have the same bug ???
the editor always starts the game with the same map which is the first map declared in project_db.dat
Then your savegame isn't created at launch time. The starting map is always the first map found in the maps folder and because there is no file to load
The problem is, you create the values, but these values aren't saved so when the engine is supposed to load this savegame, it load a blank file because none of these values has replaced the default one provided by the engine. (I suppose that you don't have a Selection screen menu)
-- Create the game (but do not start it).
local exists = sol.game.exists(file)
local game = sol.game.load(file)
if not exists then
-- This is a new savegame file.
initialize_new_savegame(game)
-- save the initialized values
game:save()
end
And you have to load and run this same file in order to load this game
Are you sure that you call game_manager:create() at some point?
Hi every one, here is my main.lua file so you can help me to solve this bug
-- This is the main Lua script of your project.
-- You will probably make a title screen and then start a game.
-- See the Lua API! http://www.solarus-games.org/solarus/documentation/
local quest_manager = require("scripts/quest_manager")
local game_manager = require("scripts/game_manager")
function sol.main:on_started()
print("example de map.")
-- Make quest-specific initializations.
quest_manager:initialize_quest()
-- Setting a language is useful to display text and dialogues.
sol.language.set_language("fr")
local solarus_logo = require("menus/solarus_logo")
-- Show the Solarus logo initially.
sol.menu.start(self, solarus_logo)
solarus_logo.on_finished = function()
-- Do whatever you want next, like showing your title screen
-- or starting a game.
local exists = sol.game.exists("save1.dat")
local game = sol.game.load("save1.dat")
game:start()
end
end
This is what I thought, you never call game_manager:create().
done, i got the solution from Christopho, it was in main.lua file.
i replaced
local exists = sol.game.exists("save1.dat")
local game = sol.game.load("save1.dat")
game:start()
by
local game = game_manager:create("save1.dat")
game:start()
Thanks a lot Christopho