Getvariableofnpc

From Hercules Wiki
Jump to: navigation, search

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.