Dialogs - some basic questions

Started by jatill, Mon 01/08/2011 20:54:06

Previous topic - Next topic

jatill

I am trying to set up some dialogs, and ran into some basic questions that aren't covered by the tutorial.

1) Can you only have a dialog with a character?  What is the best way to give the user the options of Push and Pull when they interact with a certain object/hotspot?  Create that object as a character, or something else?

2) How can you tell which option the user picked? (so that you can see if they picked push or pull, for example)

3) How can you have dynamic text in dialogs?  For example, say I want the NPC to give out character the choice of 5 random numbers to pick from.  How would I accomplish that?

Thanks for your help.

monkey0506

You actually have a few intersecting ideas here, so I'll try and answer each of the questions...

Quote from: jatill on Mon 01/08/2011 20:54:06Can you only have a dialog with a character?

You can include normal scripting commands in dialog scripts by preceding the line with one or more spaces, so technically you could do whatever you want within the dialog script. However, what the dialogs are intended for is the speech dialogues between characters. More specifically, they are used when you want to let the user select the speech lines instead of just making them wait through a predefined cutscene every time characters are talking.

If you're not trying to create a speech dialogue between two or more characters, then there's a good chance that you would want to look into other methods instead of using dialogs, such as a GUI, or just using the normal event handlers.

Quote from: jatill on Mon 01/08/2011 20:54:06What is the best way to give the user the options of Push and Pull when they interact with a certain object/hotspot? Create that object as a character, or something else?

When you say "when they interact with..." do you mean that they actually select from a GUI to "Interact with ..."? Either way I'd suggest using a GUI for this (instead of a dialog). The only difference would be when you show the GUI with the "Push" and "Pull" options. For example, you could add Push and Pull as separate cursor modes, and then in the ..._Interact() functions for the characters/hotspots/objects, you could show the second GUI to give the Push/Pull option. How you implement it kind of depends how you want it to appear to the user, so if you could flesh that out a bit more then we could elaborate on how to go about doing it. ;)

Quote from: jatill on Mon 01/08/2011 20:54:06How can you tell which option the user picked? (so that you can see if they picked push or pull, for example)

Regarding dialogs, which as I said are used for character speech interactions, you would simply use the entry-points for each option, such as @1, @2, @3, ...etc.

If you're referring to GUIs, then you would use the GUIControl's event handler. For example, if you have a GUI button called "btnPush", then the default event handler's name would be "btnPush_Click", and would be called any time the user clicks on the button (you must link it through the Events pane, in the bottom right corner by clicking the lightning bolt icon).

Quote from: jatill on Mon 01/08/2011 20:54:06How can you have dynamic text in dialogs?  For example, say I want the NPC to give out character the choice of 5 random numbers to pick from.  How would I accomplish that?

This seems like an actual dialog question, and there's not really a built-in way of doing this, with the exception that you can use the custom dialog rendering functions (look them up in the manual!, but be warned they are semi-advanced). Within the custom rendering functions, you could then add some additional checks for special tags that you might use. For example, if you created the dialog option with the text of "Number 1: %RAND:5%", then you could use the String functions (Substring, IndexOf, Chars, etc.) to look for such a tag as "%RAND:" ended by "%", and use String.AsInt on the value between those two, call the Random function with that result, then use String.Format to inject the random number into the rendered option. It sounds a lot more complicated than it is, but it's probably concerned fairly advanced to do something like that.

SMF spam blocked by CleanTalk