[SOLVED] Starting a menu from a dialog (NPC)?

Started by Eyth, September 24, 2018, 09:54:54 PM

Previous topic - Next topic
September 24, 2018, 09:54:54 PM Last Edit: September 25, 2018, 10:11:58 PM by Eyth
Hello guys!

A - hopefully short - question ^^
I want to start a menu from a dialog with a NPC. More precise, the hero talks to the NPC and the NPC asks a YES/NO question (that works).
But now I want to start a menu (or cutscene - with I suppose is also a menu) when the hero chooses the answer YES.
How do I start/link the script from the menu/cutscene-script to the map script?

Like:
Code (lua) Select

game:start_dialog("dialog_npc", function(answer)
                                                if answer == 1, then --Answer = YES--
                                                   --Start Cutscene Menu??--
                                                else return
                                                end
end)


Thanks in advance ;)

I've done something similar so I'm just going to post the code that I used

Code ( lua) Select
local map = ...
local game = map:get_game()
local crafting_menu = require("scripts/menus/crafting")
local hero = game:get_hero()

function fire:on_interaction()
  game:start_dialog("craft_cooking", function(answer)
    if answer == 3 then
      sol.menu.start(game, crafting_menu)
      game:set_pause_allowed(false)
      hero:freeze()
    end
  end)
end

function crafting_menu:on_finished()
  game:set_pause_allowed(true)
  hero:unfreeze()
end


Thank you very much, thats perfect  ;D
Good to know, that I wasn't too far away ^^