Jump to content


Photo

GLOBALs and LOCALS


  • Please log in to reply
4 replies to this topic

#1 Dyara

Dyara
  • Member
  • 262 posts

Posted 02 March 2003 - 04:51 AM

I wonder if anyone has ever found a use for user defined tokens. Well, at least there´s one use. (In BG2:ToB?) you can use tokens to print the value of a variable:

IF
    True()
THEN
    RESPONSE #100
        SetTokenGlobal("DEBUGTEST","LOCALS","DEBUGTEST")
        DisplayString(Myself,"DEBUGTEST: <DEBUGTEST>")
        Continue()
END

IF
    True()
THEN
    RESPONSE #100
        IncrementGlobal("DEBUGTEST","LOCALS",1)
END

This script will display

DEBUGTEST: 0
DEBUGTEST: 1
DEBUGTEST: 2
...

in the message window. So instead of using a lot of CLUAConsole:GetGlobal(...) you can write a script that displays all your GLOBALs.

335 SetTokenGlobal(S:GLOBAL*,S:Area*,S:Token*)

also allows you to use the value of a variable in dialogue string.

edit: Looking at SimDing0´s scripting guide I´ve seen that it´s allready mentioned there. So it´s nothing really new but maybe there are a few who didn´t know.

#2 -Sim-

-Sim-
  • Guest

Posted 02 March 2003 - 05:05 AM

I'd never really noticed it as an action either until Avenger pointed out that it might be able to be used to simplify the system for displaying power points for DLTC spellcasting immensely. Aside from debugging, though, I think the practical uses of it are probably fairly limited for most modding applications.

[EDIT] Although, if you don't mind, I think debugging applications would be something worth mentionning in my scripting guide. Would you be OK with that?

#3 Dyara

Dyara
  • Member
  • 262 posts

Posted 02 March 2003 - 06:11 AM

Of course (why not?)

I came across SetTokenGlobal when I ran a search for 'Token' in the ACTION.IDS. I thought it would be possible to save the name of a NPC in a token and use it later but unfortunately it seems not to work.

#4 -Sim-

-Sim-
  • Guest

Posted 02 March 2003 - 06:26 AM

Thanks. That's another thing to include in the next update.

As for saving the name of an NPC, as far as I am aware, with the exception of the special handling of SetTokenGlobal, you can only set a token by specifying an existing TLK string to use. Also bear in mind that custom tokens aren't saved, so you have to reset them every time the game is loaded.

#5 Dyara

Dyara
  • Member
  • 262 posts

Posted 02 March 2003 - 07:47 AM

I thought about SetTokenObject(S:Token,O:Object) or a new action I haven´t found before (but SetTokenGlobal was the only new one :().