Solarus-Games English Forum

Solarus => Development => Topic started by: knil on May 28, 2018, 01:48:26 AM

Title: problem_start_dialog
Post by: knil 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) Select

function uncle:on_interaction()

  if game:get_value("sword",1) then ------  THIS IS THE PROBLEM!!!!!!!  this function doesnt work !!!!  the rest is ok
    game:start_dialog("uncle.finish")
  else

      if  game:get_value("uncle_sword_quest_started")   then
       game:start_dialog("uncle.done")
       door_switch:set_enabled(true)
     
      else

         game:start_dialog("uncle.sword", function(answer)
            if answer == 3 then -- non
              game:start_dialog("uncle.no")
            else  -- oui
              game:start_dialog("uncle.yes")
                game:set_value("uncle_sword_quest_started", true)
                door_switch:set_enabled(true)
                sol.audio.play_sound("door_open")
          end
       end)
     end
  end
end



Title: Re: problem_start_dialog
Post by: Diarandor 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
Title: Re: problem_start_dialog
Post by: knil 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
Title: Re: problem_start_dialog
Post by: Diarandor 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.