Difference between revisions of "Getvariableofnpc"

From Hercules Wiki
Jump to: navigation, search
(Created page with "==Syntax== *'''getvariableofnpc'''(<variable>, <"npc name">); ==Description== This function retrieves a variable reference to a [[Variables#NPC_Variables|permanent NPC variab...")
 

Latest revision as of 07:40, 6 August 2013

Syntax

  • getvariableofnpc(<variable>, <"npc name">);

Description

This function retrieves a variable reference to a permanent NPC variable in an another NPC script. Note, that the return value behaves like a variable, not like a value, which means, the return value of this function can be used in other script commands, which expect a variable as parameter.

Examples

mes "The current name of my co-worker is "+getvariableofnpc(.npcname$, "Site Co-Worker");

Prints the value of the variable .npcname$ as if it was used inside the NPC "Site Co-Worker".

mes "Let's give him an another name...";
set getvariableofnpc(.npcname$, "Site Co-Worker"), "Sleeping Tom";

Sets the variable .npcname$ of the NPC "Site Co-Worker" to "Sleeping Tom".

set .mynpcnamecopy$, getvariableofnpc(.npcname$, "Site Co-Worker");
set .mynpcnamecopy$, "Sleeping Tom";

Will change the variable .mynpcnamecopy$ to "Sleeping Tom", but keep the variable .npcname$ of NPC "Site Co-Worker" unaffected, because the first call to set copies the value of .npcname$ to .mynpcnamecopy$, rather than the reference.