Author Topic: problem_start_dialog  (Read 160 times)

knil

  • Newbie
  • *
  • Posts: 2
    • View Profile
problem_start_dialog
« on: May 28, 2018, 01:48:26 am »
 hello  ;D

if someone can help me, i am a beginner ,thank you for you time.

i cant start dialog:"uncle.finish" with NPC: uncle . I want start_dialog "uncle.finish" when hero got  the sword . I got the sword but nothing happen.


this is the sript of the map:

Code: Lua
  1. function uncle:on_interaction()
  2.  
  3.   if game:get_value("sword",1) then ------  THIS IS THE PROBLEM!!!!!!!  this function doesnt work !!!!  the rest is ok
  4.     game:start_dialog("uncle.finish")
  5.   else
  6.  
  7.       if  game:get_value("uncle_sword_quest_started")   then
  8.        game:start_dialog("uncle.done")
  9.        door_switch:set_enabled(true)
  10.      
  11.       else
  12.  
  13.          game:start_dialog("uncle.sword", function(answer)
  14.             if answer == 3 then -- non
  15.               game:start_dialog("uncle.no")
  16.             else  -- oui
  17.               game:start_dialog("uncle.yes")
  18.                 game:set_value("uncle_sword_quest_started", true)
  19.                 door_switch:set_enabled(true)
  20.                 sol.audio.play_sound("door_open")
  21.           end
  22.        end)
  23.      end
  24.   end
  25. end


« Last Edit: May 28, 2018, 03:51:47 pm by Neovyse »

Diarandor

  • Hero Member
  • *****
  • Posts: 979
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: problem_start_dialog
« Reply #1 on: May 28, 2018, 04:16:10 am »
This syntax is wrong: game:get_value("sword",1)
This syntax is correct: game:get_value("sword") == 1
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

knil

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: problem_start_dialog
« Reply #2 on: May 28, 2018, 08:37:26 pm »
exact the syntax was wrong

doesnt work with : game:get_value("sword") == 1

but with:  game:get_ability("sword") == 1 

thank you   ;D

Diarandor

  • Hero Member
  • *****
  • Posts: 979
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: problem_start_dialog
« Reply #3 on: May 29, 2018, 01:45:58 am »
You are welcome.
Keep studying Lua and also the Lua API of Solarus. Those are the magic tools you need to master to do great things.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”