Category talk:LSL User-Defined Functions
Revision as of 12:51, 26 July 2024 by Takura Thielt (talk | contribs) (→Optional (and/or Default) Parameters: new section)
Optional (and/or Default) Parameters
Hi, just wondering if LSL has the ability to support optional parameters for UDF's?
As example, I'm wanting to create a function that passes commands between attachments. I want this function to always take a "command" variable, and optionally may also take relevant "parameter" variable(s). Something vaguely like this, for a weapon and HUD...
integer ACCESSORY_COMMAND_CHANNEL = 10;
key OWNER_KEY;
accessoryCommand(string cmd, string param = "")
{
llRegionSayTo(OWNER_KEY, ACCESSORY_COMMAND_CHANNEL, cmd + ":" + param);
}
default
{
state_entry() {
OWNER_KEY = llGetOwner();
}
touch_start(integer num) {
accessoryCommand("primary_attached");
accessoryCommand("ammo", "30");
}
}
Appreciate any help or direction!