Solarus-Games English Forum

Solarus => Development => Topic started by: zutokaza on September 09, 2016, 02:27:09 AM

Title: How do I display a variable in dialogs?
Post by: zutokaza on September 09, 2016, 02:27:09 AM
How do I display a variable in dialogs? How would I do something like in the example below?

Example:

You took v[apple_amount] apples.

apple_amount would be a variable equal to some number.

You took 20 apples.
Title: Re: How do I display a variable in dialogs?
Post by: Christopho on September 09, 2016, 09:31:27 AM
Which dialog box script are you using?
Title: Re: How do I display a variable in dialogs?
Post by: zutokaza on September 09, 2016, 11:53:36 AM
The one from your old 1.3 tutorials on YouTube. Is it possible with the dialogs.dat file? I noticed I think it was $v, but I am not sure if that has anything to do with variables in the map script.

I basically want to display a variable amount in the dialogs text.
Title: Re: How do I display a variable in dialogs?
Post by: Christopho on September 09, 2016, 11:59:53 AM
First you should update to the dialog box script of the 1.5 tutorials as explained here: https://www.youtube.com/watch?v=iG0YRerYphg

Anyway, with this one or the old one, the dialog box script replaces the "$v" sequence by the value of the info parameter you pass to game:start_dialog(dialog_id, [info], [callback]).
Example:

Code (lua) Select

local value = 42
game:start_dialog("my_dialog", value)
Title: Re: How do I display a variable in dialogs?
Post by: zutokaza on September 09, 2016, 12:25:12 PM
You are the best Christopho! Worked pefectly.