Author Topic: [SOLVED] Starting a menu from a dialog (NPC)?  (Read 584 times)

Eyth

  • Newbie
  • *
  • Posts: 26
    • View Profile
[SOLVED] Starting a menu from a dialog (NPC)?
« on: September 24, 2018, 09:54:54 pm »
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 ;)
« Last Edit: September 25, 2018, 10:11:58 pm by Eyth »

Starlock

  • Full Member
  • ***
  • Posts: 106
    • View Profile
Re: Starting a menu from a dialog (NPC)?
« Reply #1 on: September 25, 2018, 04:30:23 pm »
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


Eyth

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Starting a menu from a dialog (NPC)?
« Reply #2 on: September 25, 2018, 10:11:14 pm »
Thank you very much, thats perfect  ;D
Good to know, that I wasn't too far away ^^