lfnetwork.com mark read register faq members calendar

Thread: About using Local Variables (TSL)
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 08-07-2006, 02:36 PM   #1
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
About using Local Variables (TSL)

Mod note: This is a post lifted from this thread since it might be useful as a local variable reference list, even though the list isn't fully complete. ~M

Unlike global variables, which are set to one value for each index/name for the entire game, local variables can be set on individual objects and will only have their value for that object (like a creature, placeable, waypoint, area or module).

To set a local, pick an index that's not already occupied. If you have no standard scripts running on the placeable (such as Random Loot generation for container placeables) you could pick any index between 0 and 159. Then you use a script to set it.

If it's in a dialog you can use the script a_local_set that comes with the game for this. Assign it to a Script slot of a dialog node and set the first parameter (P1) to the index of the LocalBoolean slot you wish to set.

If you want to set it in one of your own scripts you use the SetLocalBoolean() function, where you set the first parameter to the object you wish to set it on, the second to the index you wish to set, and the third to the TRUE/FALSE value you want to set.

To check if it's set in your scripts you similarily use the GetLocalBoolean() function where the first parameter is the object to check the local value on and the second is the LocalBoolean index to check.

One important thing to keep in mind with GetLocalBoolean() is that it does not return TRUE or FALSE for some reason. It returns either FALSE or not FALSE. Thus, never do this when using that function since you'll get unpredictable results:
Code:
    if (GetLocalBoolean(OBJECT_SELF, 12) == TRUE) {
        ...
    }
Instead, check like this for the desired result:
Code:
    if (GetLocalBoolean(OBJECT_SELF, 12)) {
        ...
    }
Here is an incomplete list of which LocalBooleans and LocalNumbers are generally already in use on different types of objects. This is in general, for specific standard game objects others may be set as well during quests and conversations.

Creatures:
Boolean 1-3 - Creature AI, ambient NPC settings.
Boolean 10 - Dialogs, used to set that the creature has been talked to once.
Boolean 20-28 - Creature AI, used to activate userdefined script events.
Boolean 29 - Creature AI, used to set if NPC should play ambient animations when idle.
Boolean 30-64 - Reserved range for scenario/plot specific uses, some NPCs use them, most do not.
Boolean 65 - Creature AI, used to set of the NPC should walk around randomly when idle.
Boolean 66-86 - Creature AI, various settings set in the NPC spawn scripts.
Boolean 87 - Creature AI, blocks out the AI for this creature if set.
Boolean 88 - Creature AI defined, but likely unused in K2:TSL.
Boolean 89 - Creature AI, sets the creature to use the Boss Combat AI, overriding their normal AI style.
Boolean 90 - Creature AI, sets that the creature has activated their energy shield in combat.
Boolean 91 - Creature AI, toggles userdefined event for the OnDialogEnd event handler.
Boolean 92 - Creature AI, sets that a force using NPC has buffed with Resist/Immunity at start of battle.
Boolean 94 - Creature AI, sets that the creature has entered combat.
Boolean 95 - Creature AI, sets the creature to use the KotOR1 Malak end fight AI.
Boolean 96 - Creature AI, sets creature to use a zone controller to determine their combat zone.
Boolean 97 - Creature AI, setting for the OnDialog event.
Boolean 98-109 - Creature AI, used by the waypoint walking/ambient animation system.
Boolean 110-159 - Generally unused as far as I can tell.

Number 0-2 - Creature AI, used by the waypoint walking/ambient animation system.
Number 3-6 - Creature AI, internal state info for last attack used, chosen attack pattern etc.
Number 7 - Creature AI, Zone Controller this creature is attached to, if any.
Number 8-9 - Creature AI, settings for healer AI, how much to heal and how often.
Number 10-11 - Creature AI, used for turrets to determine rate of fire.
Number 12-31 - Generally unused as far as I can tell.


Placeables:
Boolean 10-19 - Security terminals, used to set the user's choice of action.
Boolean 55 - Containers, container has been bashed and broken item substituted.
Boolean 57 - Containers, used to set that random loot has been spawned.


Triggers:
Boolean 40 - Used to set that the trigger has been tripped for one-shot triggers.


Last edited by stoffe -mkb-; 12-13-2006 at 03:38 PM.
stoffe is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > Tutorials: Scripting > About using Local Variables (TSL)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:52 PM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.