Author Topic: [SOLVED] Starting a menu from a dialog (NPC)?  (Read 245 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
  1. game:start_dialog("dialog_npc", function(answer)
  2.                                                 if answer == 1, then --Answer = YES--
  3.                                                    --Start Cutscene Menu??--
  4.                                                 else return
  5.                                                 end
  6. end)
  7.  

Thanks in advance ;)
« Last Edit: September 25, 2018, 10:11:58 pm by Eyth »

Starlock

  • Jr. Member
  • **
  • Posts: 98
    • 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
  1. local map = ...
  2. local game = map:get_game()
  3. local crafting_menu = require("scripts/menus/crafting")
  4. local hero = game:get_hero()
  5.  
  6. function fire:on_interaction()
  7.   game:start_dialog("craft_cooking", function(answer)
  8.     if answer == 3 then
  9.       sol.menu.start(game, crafting_menu)
  10.       game:set_pause_allowed(false)
  11.       hero:freeze()
  12.     end
  13.   end)
  14. end
  15.  
  16. function crafting_menu:on_finished()
  17.   game:set_pause_allowed(true)
  18.   hero:unfreeze()
  19. end
  20.  
  21.  

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 ^^