Jump to content
Poison

donpcevent script command with arguments

Recommended Posts

 

*donpcevent "<NPC object name>::<event label>";

 

This command invokes the event label code within an another NPC or NPCs.

It starts a separate instance of execution, and the invoking NPC will

resume execution its immediately.

 

How about adding argument options for this script command? What do you think guys?

 

 

*donpcevent "<NPC object name>::<event label>",{<argument1>,<argument2>,...};

 

Script Example:

 

	place,100,100,1%TAB%script%TAB%NPC%TAB%53,{		.@i = rand(1,2);		if (.@i == 1) { donpcevent "NPC2::OnEmote",1; }		if (.@i == 2) { donpcevent "NPC2::OnEmote",2; }		end;	}	place,102,100,1%TAB%script%TAB%NPC2%TAB%53,{		end;	OnEmote:		if (getarg(0) == 1) {			emotion 1;		}				if (getarg(0) == 2) {			emotion 2;		}		end;	}
Edited by Poison

Share this post


Link to post
Share on other sites

This piece of code can already do what you want:

set getvariableofnpc(.arg0,"TargetNPC"),1;set getvariableofnpc(.arg1,"TargetNPC"),3;donpcevent("TargetNPC::OnDoFunction");//-----------------------------------// On the other NPCOnDoFunction:callsub "S_Function",.arg0,.arg1;

 

Anyways, I agree your script is way easier.

Share this post


Link to post
Share on other sites

Can these script lines change a variable of an npc remotely?

 

set getvariableofnpc(.arg0,"TargetNPC"),1;
set getvariableofnpc(.arg1,"TargetNPC"),3;

 

Would it not be setting the variable of the current npc?

 

.arg0 = 1;

.arg1 = 3;

 

Thanks!

Edited by Poison

Share this post


Link to post
Share on other sites

You could use that for setting variables of the current NPC if you want. However, I think that's overkill since you can set your current NPC variables like this:

set .variable, value;

 

For setting an NPC variable with getvariableofnpc, you could use any of these two sentences (but hey, don't do that, you're about to do quite an overkill!):

set getvariableofnpc(.var, "Current NPC name"), value;set getvariableofnpc(.var, strnpcinfo(3)), value;

 

However, 'getvariableofnpc' script command is made for getting another NPC's variable and even setting it, just in case you need it. Check out what the doc/script_commands.txt has to say about the 'getvariableofnpc' command:

 

*getvariableofnpc(<variable>,"<npc name>")
 
Returns a reference to a NPC variable (. prefix) from the target NPC.
This can only be used to get . variables.
 
Examples:
 
//This will return the value of .var, note that this can't be used, since
//the value isn't caught.
getvariableofnpc(.var,"TargetNPC");
 
//This will set the .v variable to the value of the TargetNPC's .var
//variable.
set .v,getvariableofnpc(.var,"TargetNPC");
 
//This will set the .var variable of TargetNPC to 1.
set getvariableofnpc(.var,"TargetNPC"),1;
 
Note: even though function objects can have .variables, getvariableofnpc
will not work on them.

 

Anyways, I agree the structure I've put before is a bit complicated, so I also support your suggestion.

Share this post


Link to post
Share on other sites

Okay now its clearer. I would hope that Hercules can implement this suggestion so that scripts can have more flexibility and higher performance.

 

//This will set the .var variable of TargetNPC to 1.	set getvariableofnpc(.var,"TargetNPC"),1;

 

Thank you for your support! :)

Share this post


Link to post
Share on other sites

me likes this~
waiting for herc 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.