Just a quick and easy one...
Is there a limit to the character size of a Variable's name? If so, what would that number be?
Variable Character Limits?
Débuté par
MERP UK
, déc. 13 2013 09:28
#1
Posté 13 décembre 2013 - 09:28
#2
Posté 13 décembre 2013 - 10:03
I believe it's 32 characters; at least that's what I put in my notes. Probably got it from one of the function descriptions.
Modifié par rjshae, 13 décembre 2013 - 10:04 .
#3
Posté 13 décembre 2013 - 10:08
This answers a little problem I have been having. I know what to do now. I'll make a note of this myself for future reference. Many thanks!
#4
Posté 14 décembre 2013 - 12:01
32 is quite a lot
. Hard to exceed.
#5
Posté 14 décembre 2013 - 01:34
If that's true, then my collection quest tracker script will only work with quests whose tags are 9 or fewer characters long, due to the automatic tracking strings I use. I'll test this, and if so, I'll shorten the code to accommodate longer quest tags.
#6
Posté 14 décembre 2013 - 11:57
I tested my system using a total variable name length of 50 characters, and it functioned as intended.
(This was the name of a local int stored on a waypoint.)
(This was the name of a local int stored on a waypoint.)
Modifié par Tchos, 14 décembre 2013 - 11:58 .
#7
Posté 14 décembre 2013 - 02:59
Interesting! My issue arose from a global int set through conversation and then checked for in an ItemActivated event. Reducing the size of the int name resolved my problem.
#8
Posté 14 décembre 2013 - 07:10
I think the OC has some pretty big variables for bark convos. Some names that don't even make sense to me... I don't know why.
Maybe a convo set variable can have less character than one set on an area or placeable etc?
Maybe a convo set variable can have less character than one set on an area or placeable etc?
#9
Posté 14 décembre 2013 - 11:47
For the purpose of aiding any further investigation of whatever the limits might be, I'll describe in more detail what worked for me, which should not have worked if there is a 32-character limit. MERP UK, could you also go into more detail about your situation?
In my case, I wrote a script that is designed to be used multiple times simultaneously for different things (each of which can handle numerous items itself), so I generate unique variable names to keep track of each one separately by beginning with the prefix "CollectionTrack", then appending to the name the tag of the quest associated with this particular tracking instance, then appending the token number, which is expected to be 4 characters long, but could be of any length, and which is incremented for each item involved in each instance.
An important thing to note is that the number that makes the tracking possible is placed at the end of the variable's name. So if there were any name-truncating going on due to a character limit, it would cause this script to fail.
Finally, to track when these pieces are done, I add another variable, whose name is the same as the full-length one described above, but with the additional word "done" added to the end.
(The values of these local variables are quite short, by contrast -- usually single digits.)
My test involved using a quest tag of "taglongerthanninecharacters" to be used in this system, which resulted in 50 characters total for the variable's name in the "done" version, and 46 long for the in-progress version.
In my case, I wrote a script that is designed to be used multiple times simultaneously for different things (each of which can handle numerous items itself), so I generate unique variable names to keep track of each one separately by beginning with the prefix "CollectionTrack", then appending to the name the tag of the quest associated with this particular tracking instance, then appending the token number, which is expected to be 4 characters long, but could be of any length, and which is incremented for each item involved in each instance.
An important thing to note is that the number that makes the tracking possible is placed at the end of the variable's name. So if there were any name-truncating going on due to a character limit, it would cause this script to fail.
Finally, to track when these pieces are done, I add another variable, whose name is the same as the full-length one described above, but with the additional word "done" added to the end.
(The values of these local variables are quite short, by contrast -- usually single digits.)
My test involved using a quest tag of "taglongerthanninecharacters" to be used in this system, which resulted in 50 characters total for the variable's name in the "done" version, and 46 long for the in-progress version.
#10
Posté 15 décembre 2013 - 11:25
Ok, so I had some long variable names in use to track the party's knowledge of many different crafting recipes. For example:
KNOWN_RECIPE_HARDENED_LIGHT_ARMOUR (34 characters)
This is set during a player-to-self conversation, using the ga_globalint generic script. The int is to be set at a value of 1.
The problem arose when I attempted to craft items requiring the setting of this int. I got the feedback that I did not know how to make x item. I went back, checked the basics - all seemed fine. Tested again incase I did something stupid (very likely at certain times of day) - still nothing. This process involves the player using a tool item on a placeable container which launches a tag-based ItemActivated script. This script checks for recipe knowledge, such as the variable I posted above.
Next move was to post here for support. As you can see, rjshae suggested 32 as a limit, so I went back and tried it out by cutting down all names which exceeded 32 characters. After editing the setting and checking scripts, I had instant results. This problem affected 6 variables, which were over 32 characters. All of them worked properly onwards.
Hope this was useful.
KNOWN_RECIPE_HARDENED_LIGHT_ARMOUR (34 characters)
This is set during a player-to-self conversation, using the ga_globalint generic script. The int is to be set at a value of 1.
The problem arose when I attempted to craft items requiring the setting of this int. I got the feedback that I did not know how to make x item. I went back, checked the basics - all seemed fine. Tested again incase I did something stupid (very likely at certain times of day) - still nothing. This process involves the player using a tool item on a placeable container which launches a tag-based ItemActivated script. This script checks for recipe knowledge, such as the variable I posted above.
Next move was to post here for support. As you can see, rjshae suggested 32 as a limit, so I went back and tried it out by cutting down all names which exceeded 32 characters. After editing the setting and checking scripts, I had instant results. This problem affected 6 variables, which were over 32 characters. All of them worked properly onwards.
Hope this was useful.
#11
Posté 15 décembre 2013 - 08:05
A few minor differences I see between our two situations are:
Your variable names use underscores, and mine do not.
Your names are in all-caps, and mine are mixed-case.
You're using global ints, and I'm using local ints.
The first two I expect are irrelevant, since you didn't change those things, and it works now. The global/local difference may be something to check, just for the sake of seeing what works and what doesn't. Perhaps there's a limit on globals that doesn't apply to locals? I've long avoided global variables.
Your variable names use underscores, and mine do not.
Your names are in all-caps, and mine are mixed-case.
You're using global ints, and I'm using local ints.
The first two I expect are irrelevant, since you didn't change those things, and it works now. The global/local difference may be something to check, just for the sake of seeing what works and what doesn't. Perhaps there's a limit on globals that doesn't apply to locals? I've long avoided global variables.
#12
Posté 16 décembre 2013 - 08:24
I only used globals to check the availability of a world map point of travel. I did this because I was confused, and didn't know if locals work from module to module. I thought: global=campaign, local=one module. I was mistaken. But now I know and I don't use them anymore, for I heard they can prove unstable from time to time.
#13
Posté 19 décembre 2013 - 02:46
I thought the 32 character limit was for campaign variables. Maybe it was globals though. I read about it somewhere but never tested it out myself.
Regards
Regards





Retour en haut






