Aller au contenu

Photo

Display Input Box


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
MammonTheViscount

MammonTheViscount
  • Members
  • 35 messages
i've written a little code with this and can't get it to work, but before we go into detail about how sloppy my scripting is, i'd like to understand where the text input in the box is passed on to another script, and how... i don't see it in the definition of the function at all... :-\\  little help for a noob?  thanks.

#2
MammonTheViscount

MammonTheViscount
  • Members
  • 35 messages
I think i have an issue with answering my own questions... but voicing them here does seem to help... okay, the callback script will contain the data in the Void main (VARIABLE_HERE)... whooohoo....

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
MammonTheViscount

MammonTheViscount
  • Members
  • 35 messages
This is the working? version of the script where the cries go off, but i dont have a way to test it across multiple areas if the creatures in different areas all have the same tag... (would require 3 people to test... one talking to the crier in one area, one standing in another area with a crier of the same tag, and one standing in a different area with a crier of a different tag).. the idea was to have more than one location where the criers shout messages, but say a multi area city like waterdeep would have all the criers going off, while not having the criers shouting in neverwinter... if that makes sense?

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
MasterChanger

MasterChanger
  • Members
  • 686 messages
Two thoughts to offer: One, make sure the bitwise (I assume) conditional in your while statement is correct. Two, I recommend either using GetNearestObjectByTag, or if you stay with GetObjectByTag, starting with n = 0 and incrementing from there. I think this would work better with the declaration of GetObjectByTag, where n defaults to 0 if not specified in the argument.

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
MammonTheViscount

MammonTheViscount
  • Members
  • 35 messages
GetObjectByTag n starts at 0, it's the first thing i define in the script. I'm not sure what you mean by the bitwise conditional, though... i don't really speak scripter very well, i've been doing this for three or four days :-\\\\. can you explain?

Modifié par MammonTheViscount, 28 juillet 2010 - 04:44 .


#6
Morbane

Morbane
  • Members
  • 1 883 messages
...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.

#7
MasterChanger

MasterChanger
  • Members
  • 686 messages
OK, the post I was originally responding to was #2, in which n did start as 1 rather than 0. In that post, you had the statement: while(GetIsObjectValid(oNPC)&n++<5)



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
MasterChanger

MasterChanger
  • Members
  • 686 messages

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
Freeze01

Freeze01
  • Members
  • 12 messages
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 crying ;) without the need to be in all areas.

Modifié par Freeze01, 28 juillet 2010 - 05:52 .


#10
Morbane

Morbane
  • Members
  • 1 883 messages

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
MammonTheViscount

MammonTheViscount
  • Members
  • 35 messages

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 crying ;) without 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
.Lv

.Lv
  • Members
  • 6 messages
It can be heard in the module yes, by any player in any map.

Modifié par .Lv, 28 juillet 2010 - 04:40 .