Aller au contenu

Photo

Managing Local Variables (On PCS)


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi All,

Just a few quick questions regarding variables stored on PCs....

1) If a place a variable on a PC, is there anything that "removes" it other than me using script to do so?

2) Is there a maximum umber of variables that can be stored on a PC?

3) Is there any way to see (or list) the variables currently on a PC?

EXAMPLE:

I attach a string variable "TESTSTRING" to a PC in a variable holder called, "TEST".

Does this string variable stay with a PC forever, even between module changeovers? (It appears to do so in my own module to module changeovers in my campaign.) Does it "Export" or travel with a PC between modules of different builders?

Would I eventually run out of "space" or make the PC data too big to be manageable after a certain amount of variables being added? If so, is there any way to remove all variable data from a PC?

I have a PC that has had a number of variables attached to it throughout a game, how can I see or list those variables currently attached to the PC in question?

Many thanks for your answers.

Lance.

#2
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I can only answer #3 for sure. You need to make a debug script. I know the commands and wrote a rudimentary script that I will post for reference. Note, this script is for reference only to see the concept. The script is not very good because it will only look at about 5 variables. A better one is needed to make a complete list.

This is actually a script from when I was trying to mess with in game camera angles. So ignore those parts.



__________________________________________

/*This script changes the camera angle. It doesn't work.

*/
// E.C.'s super include!

//03-12-07: added MotB ginc_'s
//23-01-08: made some corrections based on Baragg's list
//11-10-08: added ginc_symbol_spells from 1.13
//Added SoZ libraries. I forgot when.




//note oArea is the target!!!!
void main()
{
object oPlayer = GetFirstPC();
object oPC = GetPlayerCurrentTarget(oPlayer);
object oArea =oPC;
int nVariables = GetVariableCount(oArea);
string sVariables = IntToString(nVariables);

int nPos = 1;
string sVar1 = GetVariableName(oArea,nPos);
int nType1 = GetVariableType(oArea,nPos);
nPos++;
string sVar2 = GetVariableName(oArea,nPos);
int nType2 = GetVariableType(oArea,nPos);
nPos++;
string sVar3 = GetVariableName(oArea,nPos);
int nType3 = GetVariableType(oArea,nPos);
nPos++;
string sVar4 = GetVariableName(oArea,nPos);
int nType4 = GetVariableType(oArea,nPos);
nPos++;
string sVar5 = GetVariableName(oArea,nPos);
int nType5 = GetVariableType(oArea,nPos);

string sType1 = IntToString(nType1);
string sType2 = IntToString(nType2);
string sType3 = IntToString(nType3);
string sType4 = IntToString(nType4);
string sType5 = IntToString(nType5);

FloatingTextStringOnCreature(sVariables,oPC);
FloatingTextStringOnCreature(sVar1,oPC);
FloatingTextStringOnCreature(sVar2,oPC);
FloatingTextStringOnCreature(sVar3,oPC);
FloatingTextStringOnCreature(sVar4,oPC);
FloatingTextStringOnCreature(sVar5,oPC);

FloatingTextStringOnCreature(sType1,oPC);
FloatingTextStringOnCreature(sType2,oPC);
FloatingTextStringOnCreature(sType3,oPC);
FloatingTextStringOnCreature(sType4,oPC);
FloatingTextStringOnCreature(sType5,oPC);


//SetCameraMode(oPC,CAMERA_MODE_TOP_DOWN);
//SetCameraHeight(oPC,25.0);
//int nCycle = 1;
//SetCameraHeight(oPC,1000.0);

//while (nCycle == 1)
//{
//DisplayGuiScreen(oPC, "SCREEN_CAMERA", FALSE,"cameraui.xml");

//AssignCommand(oPC,SetCameraFacing(0.0,10001550.0,5.0));

//}
}

#3
kevL

kevL
  • Members
  • 4 074 messages
i'm not so sure about that, Matt
doesn't it assume you know the variable name?

*outside the Game* TlkEdit2 will open .bic and .ros files. I notice the .Ros files have an entry: VarTable, that lists all variables on a companion. unfortunately i don't see VarTable in .Bic files ... talking about SavedGame files here,

(and, at present, i don't see this having a direct use *ingame* )


ahh, the playerlist.ifo file has the VarTable for PC it looks like. I see one here with over 600 entries .....

#4
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi Matt,

EDIT: I stand corrected. I will check this out some more. Thanks.

Hi KevL,

It sounds like you are getting close to answering this, but I am not quite understanding your "thinking aloud". Which files do you think are the specific ones, and how are you viewing them?

At the moment, it sounds like you may be opening a few files in a txt editor?

Can you clarify this please. :)

Lance.

EDIT: I tried opening up the playerlist.ifo with a text editor and (apart from teh garbage bit), I could not see anything clearly.  I will try opening a bic now.

EDIT 2: HEY! I found out where they store the global variables info. :) That's good to know as well! (globals.xml)

Modifié par Lance Botelle, 04 février 2012 - 07:15 .


#5
kevL

kevL
  • Members
  • 4 074 messages
sure Lance,

in a SavedGame folder, the .Ros files are companions (roster members), .Bic file seems to be some sort of auto-exported PC, and .Ifo is the PC information file.


TlkEdit2 off the Vault, is what i'm using to view those ...

#6
kevL

kevL
  • Members
  • 4 074 messages
hehe

#7
MasterChanger

MasterChanger
  • Members
  • 686 messages

Lance Botelle wrote...

Hi Matt,

Unfortunately, it is as KevL says, your script assumes you know the variables on a PC in the first place. I am looking at viewing variables that may have even been "forgotten" about, if you see what I mean.

Lance.


You know, I don't think you do need to know the name. Here's the prototype for GetVariableName:

string GetVariableName (object oTarget, int nPosition)        

//Returns a Local Variable's name from an object at position nPosition.
//Empty string is returned if points to an invalid variable


The function returns the name of the variable. Presumably, you could loop over the variables attached to an object by incrementing nPosition. You would repeat until GetVariableName returns "".

Once you have the name of the variable and its type (returned by GetVariableType), you can do whatever you like with it!

Pain also has a function in the CSL to reverse this and get a variable's index on the object given its name. This function, called CSLGetVariableIndex, just loops over the variables at incremental positions on the object until the names match.

#8
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi KevL,

I just noticed the *.Ros files were updating myself. :)

I will try opening these with the TlkEdit2 program now then. Many thanks for the explanation.

If you discover anything else, or any better way to get this info (and any other answers to my other questions) then please keep me appraised.

Many Thanks,
Lance.

#9
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

MasterChanger wrote...

Lance Botelle wrote...

Hi Matt,

Unfortunately, it is as KevL says, your script assumes you know the variables on a PC in the first place. I am looking at viewing variables that may have even been "forgotten" about, if you see what I mean.

Lance.


You know, I don't think you do need to know the name. Here's the prototype for GetVariableName:

string GetVariableName (object oTarget, int nPosition)        

//Returns a Local Variable's name from an object at position nPosition.
//Empty string is returned if points to an invalid variable


The function returns the name of the variable. Presumably, you could loop over the variables attached to an object by incrementing nPosition. You would repeat until GetVariableName returns "".

Once you have the name of the variable and its type (returned by GetVariableType), you can do whatever you like with it!

Pain also has a function in the CSL to reverse this and get a variable's index on the object given its name. This function, called CSLGetVariableIndex, just loops over the variables at incremental positions on the object until the names match.


Hi MC,

Thanks for pointing out this some more. I stand corrected  on my understanding of this function. :)

I will take a closer look now.

Many Thanks for the heads up.

Lance.

EDIT: That's rather a clever addition by Pain. I will try to locate that too.

Modifié par Lance Botelle, 04 février 2012 - 07:18 .


#10
kevL

kevL
  • Members
  • 4 074 messages
ah, coolio's to Matt & MC.

#11
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi KevL,

That TalkEDT program worked fine. :) When I loaded the *.ros file, I was able to examine the VarTable part of the PC, which appeared to be what I was after. Not every entry made sense (especially when referring to a struct) as the value appeared different to what I was expecting. However, at least I was able to see what was actually on the PC. :)

EDIT: Actually, they do make sense ... It just has some others included that I was not aware were made at the same time, like Journal times and dates, which obviously use their own format.

This is very useful.

Many Thanks.

Lance.

Modifié par Lance Botelle, 04 février 2012 - 07:32 .


#12
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Neat little trick with that talkEDT program. Gonna remember that one.