Local variables(%) do not exist unless specified in the function.
That's what I thought, which is why I'm so confused. Here's a bit of code taken from the quests.cs file in the Server_TotalRPG mod made by Pecon7 (this function is called by an event in-game).
function fxDtsBrick::questStart(%this, %name, %description, %client)
{
%questName = safeQuestName(%name);
if(%client.questStarted(%questName))
{
%client.chatMessaage("\c6You have already started this quest! Do /quests");
return;
}
$InputTarget_["Self"] = %this;
$InputTarget_["Player"] = %client.player;
$InputTarget_["Client"] = %client;
if($Server::LAN)
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%client);
}
else
{
if(getMiniGameFromObject(%this) == getMiniGameFromObject(%client))
$InputTarget_["MiniGame"] = getMiniGameFromObject(%this);
else
$InputTarget_["MiniGame"] = 0;
}
%quest = new scriptObject(questObjectClass)
{
started = true;
finished = false;
name = %questName;
displayName = %name;
description = %description;
chapter["START"] = "true" TAB %description;
chapters = "START";
currentChapter = "START";
};
%client.quest[%questName] = %quest;
%client.quests = %client.quests TAB %questName;
%client.numQuests++;
%client.chatMessage("\c6You've started a new quest! Quest log has been updated. Do /quests for more information.");
}
What I don't understand about how this works is how is the function able to call functions and variables from the %client variable when it's only a local variable? And how is the game able to process and understand %client as the player's client?
This also brings up another question I had, which is does it matter what order you put the function parameters? In other words, could the declaration of this function be rewritten as function fxDtsBrick::questStart(%client, %this, %name, %description) or something along those lines?