Display Input Box
#1
Posté 28 juillet 2010 - 03:30
#2
Posté 28 juillet 2010 - 03:46
now, onto my script, and my problem with it...
the first script:
void main()
{
object oPC = GetPCSpeaker(); //gets the pc so we can make the input box show up on his screen
int nMessageStrRef = -1;
string sMessage = "My message.";
string sOkCB = "gui_towncriercallback";
string sCancelCB = "";
int bShowCancel = TRUE;
string sScreenName = "";
int nOkStrRef = 181744;
string sOkString = "";
int nCancelStrRef = 181745;
string sCancelString = "";
string sDefaultString = "Hello World"; //default text in the message box...
DisplayInputBox(oPC, nMessageStrRef, sMessage, sOkCB, sCancelCB, bShowCancel, sScreenName, nOkStrRef, sOkString, nCancelStrRef, sCancelString, sDefaultString); //do the thing...
}
and the second script:
void main(string sInputString) //set the input string into sInputString
{
int n = 1;
SetLocalString(GetModule(),"TownCry",sInputString); //store the string as a local variable on the module (it'll be called in theory by creatures from different areas)
object oNPC = GetObjectByTag("RRTownCrier", n); //get the crier so we can have him shout the input
string sMessage = GetLocalString(GetModule(), "TownCry"); //string up the message
AssignCommand(oNPC,ActionSpeakString(sMessage)); //say the message (this part works)
while(GetIsObjectValid(oNPC)&n++<5)
{
object oNPC = GetObjectByTag("RRTownCrier", n);
AssignCommand(oNPC,ActionSpeakString(sMessage));
}
}
I have two goblins set up as Town Criers with the correct tag n all, but only the first one says anything... can't get the second goblin to fire the speakstring.
a little help?
Modifié par MammonTheViscount, 28 juillet 2010 - 04:32 .
#3
Posté 28 juillet 2010 - 04:34
anyways, here is the final callback script.
void main(string sInputString)
{
int n = 0; //used later for object oNPC, to get the first crier of the group
object oPC = OBJECT_SELF; //sets oPC to the pc who started the script so that we can get the area variables
string sCrier_Cry = GetLocalString(GetArea(oPC),"Crier_Cry"); //retrieves the name of the variable to be used to store the cry in the module
SetLocalString(GetModule(), sCrier_Cry ,sInputString); //stores the cry in the module with the tag defined above
string sMessage = GetLocalString(GetModule(), sCrier_Cry); //sets the message to be cried to the variable set above (and keeps it stored for possible future use on a bulletin board)
while(n
{
string sCrier_Tag = GetLocalString(GetArea(oPC),"Crier_Tag"); //gets the tag of the crier for the area
object oNPC = GetObjectByTag(sCrier_Tag, n); //gets the specific crier, starting with the first one, to make the cry
AssignCommand(oNPC,ActionSpeakString(sMessage)); //tells the crier to make the cry
n=n+1; //raises n by one to move on to the next crier.
}
}
if anyone is able to test it in multiplayer i'd be much obliged... or just tell me if it looks like it'll work?
thanks :-)
Modifié par MammonTheViscount, 28 juillet 2010 - 04:35 .
#4
Posté 28 juillet 2010 - 04:41
Edit: Ah, ninja'd. Your "while" line is missing, so I'm not sure if that's correct, but this looks better, starting with n=0 and going n++ from there.
The only thing I'd recommend, if you want to restrict your search to the given area, is to use GetNearestObjectByTag. AFAIK GetObjectByTag does not restrict itself to the current area.
Modifié par MasterChanger, 28 juillet 2010 - 04:44 .
#5
Posté 28 juillet 2010 - 04:43
Modifié par MammonTheViscount, 28 juillet 2010 - 04:44 .
#6
Posté 28 juillet 2010 - 04:48
//do stuff
return "string";
or
return sString;
afaik that is how the main parameter will 'see' the passed variable.
#7
Posté 28 juillet 2010 - 04:48
I don't know whether that's a correct statement or not, but it's certainly not the simplest. Moving the n++ out of the conditional is better, as you did in post #3. Your while could read as:
while( GetIsObjectValid ( oNPC ) && n < 5)
#8
Posté 28 juillet 2010 - 04:51
Morbane wrote...
...Also if you want to pass a string into the main parameter you have to have a string main() return a string to the action script;
//do stuff
return "string";
or
return sString;
afaik that is how the main parameter will 'see' the passed variable.
Wha? I'm not sure what you're getting at. The string is passed into the GUI script from the InputBox. The action script (I think you mean the script that calls the InputBox?) doesn't need the string passed back to it. In fact, the GUI script does not return back to the script that called the InputBox anyway.
#9
Posté 28 juillet 2010 - 05:51
That way you know all your criers are crying
Modifié par Freeze01, 28 juillet 2010 - 05:52 .
#10
Posté 28 juillet 2010 - 11:08
MasterChanger wrote...
Morbane wrote...
...Also if you want to pass a string into the main parameter you have to have a string main() return a string to the action script;
//do stuff
return "string";
or
return sString;
afaik that is how the main parameter will 'see' the passed variable.
Wha? I'm not sure what you're getting at. The string is passed into the GUI script from the InputBox. The action script (I think you mean the script that calls the InputBox?) doesn't need the string passed back to it. In fact, the GUI script does not return back to the script that called the InputBox anyway.
Err - wasn't thinking about the right context - sorry to muddle up the post:whistle:
#11
Posté 28 juillet 2010 - 03:58
Freeze01 wrote...
Dont have a lot of advice, but for testing purposes you could let the criers say their line with ActionSpeakString (sMessage, TALKVOLUME_SHOUT);
That way you know all your criers are cryingwithout the need to be in all areas.
how far does talk volume shout go? is it server wide?
Modifié par MammonTheViscount, 28 juillet 2010 - 03:58 .
#12
Posté 28 juillet 2010 - 04:39
Modifié par .Lv, 28 juillet 2010 - 04:40 .





Retour en haut






