Author Topic: Help!!! Can't open a specific map in solarus quest editor...  (Read 2178 times)

aminemax

  • Newbie
  • *
  • Posts: 9
    • View Profile
Help!!! Can't open a specific map in solarus quest editor...
« on: March 16, 2016, 05:20:10 pm »
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:

Quote
local 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 following error:
 Error: No valid destination on map 'Light-world/1'. Placing the hero at (0,0) instead.

Diarandor

  • Hero Member
  • *****
  • Posts: 1045
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #1 on: March 16, 2016, 05:57:52 pm »
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...
« Last Edit: March 16, 2016, 06:04:51 pm by Diarandor »
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #2 on: March 16, 2016, 06:05:59 pm »
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
« Last Edit: March 16, 2016, 06:35:51 pm by MetalZelda »

aminemax

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #3 on: March 16, 2016, 06:32:43 pm »
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!

Diarandor

  • Hero Member
  • *****
  • Posts: 1045
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #4 on: March 16, 2016, 06:39:49 pm »
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".
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

aminemax

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #5 on: March 16, 2016, 06:49:26 pm »
i verified but all names are correct really weird. See the screenshot bellow


Diarandor

  • Hero Member
  • *****
  • Posts: 1045
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #6 on: March 16, 2016, 07:03:32 pm »
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 :(
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

aminemax

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #7 on: March 16, 2016, 07:08:44 pm »
i've changed the folder's name, same problem, i also changed starting map but still have the same bug ???

aminemax

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #8 on: March 16, 2016, 07:11:26 pm »
the editor always starts the game with the same map which is the first map declared in project_db.dat

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #9 on: March 16, 2016, 07:54:14 pm »
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)

Code: (lua) [Select]
-- 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
« Last Edit: March 16, 2016, 07:57:21 pm by MetalZelda »

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1172
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #10 on: March 16, 2016, 11:11:13 pm »
Are you sure that you call game_manager:create() at some point?

aminemax

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #11 on: March 17, 2016, 02:19:17 pm »
Hi every one, here is my main.lua file so you can help me to solve this bug
Code: [Select]
    -- 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




Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1172
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #12 on: March 17, 2016, 02:19:47 pm »
This is what I thought, you never call game_manager:create().

aminemax

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Help!!! Can't open a specific map in solarus quest editor...
« Reply #13 on: March 17, 2016, 03:02:09 pm »
done, i got the solution from Christopho, it was in main.lua file.
 i replaced
Code: [Select]
local exists = sol.game.exists("save1.dat")
local game = sol.game.load("save1.dat")
game:start()

by
Code: [Select]
local game = game_manager:create("save1.dat")
game:start()

Thanks a lot Christopho