Jump to content
Sign in to follow this  
mrn

How to destroy variables so ArmA doesn't save them

Recommended Posts

Hi.

I thought I had come up with a great way of reducing variables of objects by storing the names and locations in an array then deleting them and setting their vehiclename to nil.

Specifically I wanted to get locations for my Dynamic War mission then scrub the logic names so they aren't saved but I still have access to their locations in an array.

Now, after a quick experiment I'm either completely fudging something up or the ArmA save gremlins have got their claws deeper than I had hoped for.

My testing is something along the lines of (I know, I know, sqs):

In one script

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_logics = [sp1,sp2,sp3,sp4,sp5,sp6,sp7,sp8,sp9,sp10,sp11,sp12]

~0.5

{[_x] exec "logic_array.sqs"} foreach _logics

in logic_array.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_logic = _this select 0

_logic_name = vehicleVarName _logic

_logic_xPos = getpos _logic select 0

_logic_yPos = getpos _logic select 1

_logic_zPos = getpos _logic select 2

_local_logic_array = [_logic,_logic_name,[_logic_xPos,_logic_yPos,_logic_zPos]]

I can use hint format at this point and it's all there, not in a particular order but I'm still early into this. ie [[sp1,"sp1",[numbers,numbers,numbers]]

Now if I run

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_logics = [sp1,sp2,sp3,sp4,sp5,sp6,sp7,sp8,sp9,sp10,sp11,sp12]

~0.5

{[_x] exec "logic_array.sqs"} foreach _logics

~0.5

if !(isnil ("vehicleVarName _x")) then { _x setVehicleVarName nil;} foreach _logics

~0.5

{deletevehicle _x} foreach _logics

I can use hint format at this point and get

[[<null object>,scalar bool etc.,[numbers,numbers,numbers]]

Woohoo, I thought. Sp1 is no longer "real" so it won't be in the savegame file. Open up the savegame file and sure enough sp1 and all the other variables are still there.

While I have a sick kind of enjoyment trying this sort of thing the last few hours have brought me nothing.

Am I doing this wrong? confused_o.gif

Am I misunderstanding something? crazy_o.gif

Is there a way to do what I am after, short of putting loads of positions (50-60) into an array manually? huh.gif

help.gif

Cheers

Share this post


Link to post
Share on other sites

Can you not collect the logic objects dynamically? Wouldn't that effectively remove the need to name the logics? Aren't there commands in the ArmA scripting language to get at the logic objects dynamically.

Share this post


Link to post
Share on other sites
Quote[/b] ]Can you not collect the logic objects dynamically? Wouldn't that effectively remove the need to name the logics? Aren't there commands in the ArmA scripting language to get at the logic objects dynamically.

How do you do that then? smile_o.gif

To be more specific there's also logics I don't want and if I have say 24 logics, 12 may be used by the spawn script, 12 by the location script and I only need locations of the latter 12.

I may be making things more complicated than necessary.

Quote[/b] ]The only practical application I can see here is reducing the savefile size...

Bingo.

The more I think about it there are certain things I can do to some of the internal scripts in the mission for the name count but I'd like to significantly expand the location choice, the easiest way of doing this is plonk a logic down.

Or, would it make more sense to use something that wouldn't normally be used, a roadcone for example, capture the locations of those then they're easily deleted?

The more I ramble on in this post I think I may have solved my own problem, but it still serves as a warning that once declared a variable is probably permanent in the savefile.

Cheers

smile_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ] The only practical application I can see here is reducing the savefile size...

There are others, but it would take this off topic...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if !(isnil ("vehicleVarName _x")) then { _x setVehicleVarName nil;} foreach _logics

To remove the editor placed, variable names on the logics? You could try:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{if !(isnil (Call Compile Format ["%1",vehicleVarName _x])) then {Call Compile Format ["%1=nil",vehicleVarName _x]}} foreach _logics

Assuming you placed and named the logics using the mission editor?

Not tested the code, so it might need tweaking. JIP and re-spawn not guaranteed.

Share this post


Link to post
Share on other sites

Thanks for the reply.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{if !(isnil (Call Compile Format ["%1",vehicleVarName _x])) then {Call Compile Format ["%1=nil",vehicleVarName _x]}} foreach _logics

{if !(#isnil (Call Compile Format ["%1",vehicleVarName

error isnil, type object expected string,code

sad_o.gif

I don't understand the whole Call Compile thing so I wouldn't know where to start with that.

smile_o.gif

Quote[/b] ]JIP and re-spawn not guaranteed.

Not a problem with me, I wouldn't be in this situation if it was MP. wink_o.gif

Don't worry too much, I think I've rambled away a fix for my situation but I'd love to know if someone finds a way of getting rid of a variable in a save.

Cheers

Share this post


Link to post
Share on other sites

try:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{if !(isnil (Format ["%1",vehicleVarName _x])) then {Call Compile Format ["%1=nil",vehicleVarName _x]}} foreach _logics

Share this post


Link to post
Share on other sites

@T_D thats what I was about to post smile_o.gif

Quote[/b] ]isnil, type object expected string,code

Well if it requires type string or code, then give it what it wants:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{if !(isnil (Compile Format ["%1",vehicleVarName _x])) then {Call Compile Format ["%1=nil",vehicleVarName _x]}} foreach _logics

Or perhaps:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{if !(isnil (Format ["%1",vehicleVarName _x])) then {Call Compile Format ["%1=nil",vehicleVarName _x]}} foreach _logics

Quote[/b] ]but I'd love to know if someone finds a way of getting rid of a variable in a save

Yes, it would be quite interesting.

Edit: Fixed typo

Share this post


Link to post
Share on other sites
Quote[/b] ]The only practical application I can see here is reducing the savefile size...

Bingo.

Ok, so why would you really care to do that?

Currently, my entire saved games folder is about 200 megs and that includes saves from a few campaigns and a whole bucket load of missions.

Considering my game folder as a whole is 7.4 gigs (with addons but not counting my seperate arma stuff folder with various zips and utilities which weighs in at 4.21 gigs), I don't know if a few extra megs worth of save data is really worth stressing over.

I mean sure, maybe it's technically better to reduce the size of your save file, but unless there's some kind of massive gain, is it really worth your time to do so?

Share this post


Link to post
Share on other sites

well isn't the savegame bug related to the amount of (global?)

variables which need to be saved .. so removing unnecessary

variables would be quite important.

i ll call sickboy over here to comment biggrin_o.gif

Share this post


Link to post
Share on other sites

@ColonelSandersLite

Quote[/b] ]I mean sure, maybe it's technically better to reduce the size of your save file, but unless there's some kind of massive gain, is it really worth your time to do so?

Yes, I've spent months trying to reduce the save game size. In case it's passed you by, look here.

It's all about the variables.

Share this post


Link to post
Share on other sites

@UNN

I just wanted to correct a little mistake. isNil requires a string the rest was fine. In your new examples you also have mistakes. whistle.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]In your new examples you also have mistakes

Yeah, I missed the Call commands from the then statement second time around.

Didn't realise, until I read the error Mrn posted, that isNill takes either code or strings.

But like I said, I wasn't tested smile_o.gif Still don't know if this will actualy remove the variables from the savegame file either.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×