'Dialog' => [
["Talker"],
["Dialog Message"],
[["Reply 1", "Resulting dialog"]],
[["Reply 2", "Resulting dialog"]],
...
[["Reply N", "Resulting dialog"]]
]
@message["[PLAYER_NAME]"] = @player.name if @message.include?("[PLAYER_NAME]")
[VAR X]
", then it is substituted with the value of variable X (so if I'd write "[VAR $game_width]
", it would write "1366" in dialog.[NOTES KEY]"
, then this part is deleted, but it also calls function add_note(KEY)
. eval
method, e.g.eval "$game_width"
would return 1366String#gsub
(globally substitute). You can use it to remove parts from a string by replacing them with ''
, and (I didn't even know this) you can pass a Hash
as the second argument that contains a table to replace things. You could use this for the $game_width
part, e.g.your_dialog_line.gsub /\$[a-z_]+/, { "$game_width" => "1366", "$player_name" => "Herbert", "$level_name" => "Tutorial" }
/\$[a-z_]+/
bit is a Regexp that will match all $variable_names
in your_dialog_line
.
# dialogs.yml
---
:dialogs:
:talking_to_pete:
:talker: Peter Heinz
:message: |
Blah Blah Blah
And what do you think of that, $player_name?
:sound: key.ogg
:actions:
- [:muster_troops, 15] # Calls #muster_troops(15)
- [:invade_poland] # Calls #invade_poland
:replies:
-
:option: Get off, you fiend!
:dialog: talking_to_pete_angry
-
:option: I love you!
:dialog: talking_to_pete_lustful
-
:option: Do you want to buy some eggs?
:dialog: talking_to_pete_bemused
:talking_to_pete_bemused:
...
:talking_to_pete_angry:
...
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill