Jump to content

Setting Script Variables from the Console


LtMattmoo

Recommended Posts

I'm not sure if this is the place to ask this one, but seeing as the answer will help me with a plugin I'm developing I think it fits.

 

Simply put; I would to like to know if it's possible to set variables held within a script while in-game, via the console.

 

I remember this being possible in Oblivion by using the following syntax...

set [script].[variable] to x

...where [script] is the name of the script containing the variable, [variable] is the variable in question and x is the value for the variable to be set to.

 

I just tried this syntax and the result made me think that this approach should work, but something minor needs to be different. This being because, rather than suggesting that the function did not exist, the console claimed to not be able to find the variable.

 

If anybody knows what I need to do to get this to work I will be very grateful, so thanks in advance.

Edited by LtMattmoo
Link to comment
Share on other sites

Only properties can be accessed outside the proper script (they work like quest script variables from previous games). Even them the syntax for Oblivion would be QuestID.Questvariable instead the script.

 

Properties in Papyrus receive two functions when Auto is used, or you can write the functions yourself. The main functions there are the Get and the Set to that property, which allows respectively reading and writing them from outside. This approach is powerful for beyond allowing more functions being defined for the property also allows omitting "get" (making the variable write only) or "set" (making it read only). PS: And properties go far beyond simple variables... once you become acquainted with the method you'll see how powerful it is.

 

So the Set ... to ... is not used anymore and the property uses parameters for communication. If that sounds confuse, forgive my bad English and read directly at wiki

 

 

Edit: Sorry, I got all wrong, you meant from console (was in the very thread title and I forgot don's ask me why).

 

Sorry, in this case I can't help, I'm not acquainted with what can be done from there, to the extent I know the set command there is used over global variables, at least did not see any example of properties being accessed from there. Maybe there is a way, I just don't know how.

Edited by nosisab
Link to comment
Share on other sites

Thanks for your help, Nosisab.

 

I've done a bit of digging, and Global Variables should be perfect for what I want to do. However, I can't seem to call them in a script; <variable>.GetValue() returns that <variable> is an undefined variable. I haven't declared the variable at the top of the script but I figured that if I did that the script would call from that local variable and not the global one.

 

Could anybody please explain how to call upon Global Variables from within a script?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...