It actually worked.

So while I have the source under my eyes, here goes.
Hopes this helps !
First, the toolset strings editor can be used to create the required strref. That where you'll get a strref for the string you created :
-
http://img504.images...tringeditor.pngYou may have to export the talktable :
-
http://img695.images...ringeditor2.pngNow, you have to invoke the popup from somewhere in your code. For instance, in mine :
Phae_print("Invoking popup");
ShowPopup(1239822518, 2, Phae_forge_getAnvil(), TRUE);
Breakdown of those parameters :
- The
1239822518 is the strref from the string editor, shown on the previous screencaps
- The
Phae_forge_getAnvil() is just a function I use to retrieve one placeable object neaby. This object will receive the "popup used" event. This type 2 popup is the
dog naming popup.
- The last
TRUE parameter allows the user to enter text. Which is better for this type of popup.
Once that you have you popup invoking code, you need to go into the script handling your object events if you want to retrieve the player response to your popup. In my case it was a placeable. That script is the one set in the object inspector when editing the object.
An example of such a script :
void main() {
event eCurrent = GetCurrentEvent();
int iEventType = GetEventType(eCurrent);
switch(iEventType) {
/* irrelevant events removed for lisibility sake */
// Sent when the player answer to a name giving popup
case EVENT_TYPE_POPUP_RESULT: {
Phae_forge_saveConsoleName(GetEventString(eCurrent, 0));
break;
}
default: {
// Fall through to rules_core
HandleEvent(eCurrent, RESOURCE_SCRIPT_PLACEABLE_CORE);
break;
}
}
}The important part is here :
case EVENT_TYPE_POPUP_RESULT: {
Phae_forge_saveConsoleName(GetEventString(eCurrent, 0));
break;
}The function
GetEventString(eCurrent, 0) returns the text typed by the player into the popup window. You can retrieve to do whatever you want.
With other type of popups, for instance the type 1 (one question mark, two yes/no button) you can retrieve the pressed button with :
GetEventInteger(GetCurrentEvent(), 1)And that's it.
Modifié par Phaenan, 22 novembre 2009 - 12:47 .