Grammarsalad Posted July 20, 2015 Share Posted July 20, 2015 Hello, Is there a limit to the number of local variables that can be stored in a single cre file, either a "hard"limit, or a "practical"limit? By hard limit,I mean an absolute limit on the number of local variables that can be stored in a cre files (eg "20"and no more). By "practical" I mean are there any foreseeable consequences if too many variables are present (eg slows or crashes the game). Thanks Link to comment
Jarno Mikkola Posted July 21, 2015 Share Posted July 21, 2015 I don't think there's a hard limit, I wouldn't go over a 100 000 practically on the over all game, as checking those gets impractical ... a 100-200 might already be reaching it a bit, just like you shouldn't have more than 100 co-existing effects on the character ... also the saves won't contain the locals, so. Link to comment
Grammarsalad Posted July 21, 2015 Author Share Posted July 21, 2015 ... also the saves won't contain the locals, so.I understand that this is only true of the original bg1. Specifically, IESDP says, "... In BG1, local variables are not saved - they are temporary to the current game session." Granted, it doesn't specifically say that in other versions they are not saved, but I have set local variables in game, and after closing the game found them I'm the cre file in near infinity. Edit: oh, I don't care if they are saved I'm the gam file. I just want them to persist after saving I'm the cre file. Edit2: thinking about it, I think I did check the gam file...I'll have to double check Link to comment
Mike1072 Posted July 21, 2015 Share Posted July 21, 2015 Since they are stored as effects on each creature, they do persist through saves and there is a hard limit... of around 4 billion. Link to comment
Grammarsalad Posted July 21, 2015 Author Share Posted July 21, 2015 Since they are stored as effects on each creature, they do persist through saves and there is a hard limit... of around 4 billion.Beautiful! I'll need far fewer than that. Link to comment
Grammarsalad Posted July 21, 2015 Author Share Posted July 21, 2015 @mike1072, Are they saved across games? That is, if a character created in bgee is imported into bg2ee, will it retain its locals? Link to comment
cmorgan Posted July 21, 2015 Share Posted July 21, 2015 Ok, rechecking this - Mike1072, can you confirm? I have the following "common modder knowledge" and a bunch of approaches to transfer "LOCALS" to "GLOBAL". This was based on BG, Tutu/EasyTutu, and BG2 content development. The variable scope "LOCALS" is stored on the .cre as effects, but was listed as not persisting in saved games, and required detecting and moving to a related "GLOBAL" in order to be stored in the game file and be available to other script actions. Link to comment
Mike1072 Posted July 21, 2015 Share Posted July 21, 2015 This is what the IESDP has to say about local variables: LOCALS: SetGlobal("XXXXXX", "LOCALS", 1) The above command sets the XXXXXX variable to 1 in the local scope. The local scope is only valid for creatures (as opposed to area scripts or baldur.bcs). Only the creature that has set a variable in the local scope can see it. This allows for several creatures to use the same script (with the same variable names) as the value assigned to variables are for each creature. Local scope variables are often used for tracking things that are unique to a particular creature (e.g. number of spells left, a specific one-shot dialog option has been chosen etc.). In BG1, local variables are not saved - they are temporary to the current game session. Local variables are stored as attached effects on CRE files. The "not saved in saved games" is part of BG1 - the effect didn't exist before TotSC. In BG2, they are effects attached to creatures. Creatures are stored in the saved game in their associated .are files (in the .sav) or in the .gam file. Are they saved across games? That is, if a character created in bgee is imported into bg2ee, will it retain its locals? Yes. I have the following "common modder knowledge" and a bunch of approaches to transfer "LOCALS" to "GLOBAL". This was based on BG, Tutu/EasyTutu, and BG2 content development. The variable scope "LOCALS" is stored on the .cre as effects, but was listed as not persisting in saved games, and required detecting and moving to a related "GLOBAL" in order to be stored in the game file and be available to other script actions. Since you can only check local variables from scripts running on that creature, if you ever want to check those values in any other script, it'd be better to use a global instead. Link to comment
cmorgan Posted July 21, 2015 Share Posted July 21, 2015 Cool - thanks! So if we can import a .cre from a save into the game and check for LOCALS via their own script... heh... we could set the GLOBAL var accordingly... has no one done this because there is no way to import a .cre from a save (example - BG1 > BG2)? (talking NPCs here) Link to comment
Salk Posted July 23, 2015 Share Posted July 23, 2015 Do you know if it's possible to use a limited timing mode for local variables? So that they would be automatically removed from the .cre file after a certain time? Link to comment
Fiann of the Silver Hand Posted July 23, 2015 Share Posted July 23, 2015 The absence of a variable is the same thing as it being set to 0, right? So just IF Blah() THEN RESPONSE #100 SetGlobal("jshdjs","LOCALS",23) SetGlobalTimer("TIMERjshdjs","LOCALS",600) END IF GlobalTimerExpired("TIMERjshdjs","LOCALS") THEN RESPONSE #100 SetGlobal("jshdjs","LOCALS",0) END Setting a variable isn't like an effect with all the different timing modes. Even some effects' timing modes don't stick. I tried using Set AI Script (AI) with a limited timing, and the script endured beyond the duration. Link to comment
Mike1072 Posted July 23, 2015 Share Posted July 23, 2015 For part of a spell's effects, I needed to set a local variable for a number of rounds. Regardless of the timing mode, the value didn't seem to revert when the spell expired. I think I got around the issue by using a delayed effect that set the value back to 0, which worked for what I was doing. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.