picklefish
09-30-2009, 11:21 PM
[Guide] How to create variables that persist after HoN restart.
After many headaches dealing with this I'm passing on my invaluable knowledge.
You need a variable for your version:
String picklefish_mod_version
Your Variable:
int picklefish_mod_x
SetSave('variable_name', value);
This function sets your variable. On HoN restart this gets written to Startup.cfg
Initializing:
At the top of main.interface (this makes it so people don't have to restart HoN the first time) add:
<panel
width="0h"
height="0h"
onload="
if( (!picklefish_mod_version) and (StringEquals(picklefish_mod_version, 'version1.0') != 0),
Split(
CreateInt('picklefish_mod_x', 1),
SetSave('picklefish_mod_x', 1),
CreateString('picklefish_mod_version', 'version1.0'),
SetSave('picklefish_mod_version', 'version1.0')
)
);"
/>
This checks if the version variable has been created and is equal to "version1.0", if it hasn't been, it will set them all.
Updating Variable:
Every time you want to update your variable (picklefish_mod_x) you call SetSave('picklefish_mod_x', 1);
or
SetSave('picklefish_mod_x', 0);
or whatever value you want to set to it.
Patching Mod:
If you are adding new variables simply change all cases of 'version1.0' to a new version like 'version1.1'.
If you are not adding new variables then you don't need to change anything.
Other notes:
You can actually check every variable if you want. Instead of checking version you would do this for every one.
<panel
width="0h"
height="0h"
onload="
if( !picklefish_mod_x,
Split(
CreateInt('picklefish_mod_x', 5),
SetSave('picklefish_mod_x', 5)
)
if( !picklefish_mod_y,
Split(
CreateInt('picklefish_mod_y', 5),
SetSave('picklefish_mod_y', 5)
)
if( !picklefish_mod_z,
Split(
CreateInt('picklefish_mod_z', 5),
SetSave('picklefish_mod_z', 5)
)
);"
/>
Keep in mind that this seems to be very buggy/hard to get perfect.
Hope this helps. Check out my Stats mod in my signature to see how I do it. Look in the
After many headaches dealing with this I'm passing on my invaluable knowledge.
You need a variable for your version:
String picklefish_mod_version
Your Variable:
int picklefish_mod_x
SetSave('variable_name', value);
This function sets your variable. On HoN restart this gets written to Startup.cfg
Initializing:
At the top of main.interface (this makes it so people don't have to restart HoN the first time) add:
<panel
width="0h"
height="0h"
onload="
if( (!picklefish_mod_version) and (StringEquals(picklefish_mod_version, 'version1.0') != 0),
Split(
CreateInt('picklefish_mod_x', 1),
SetSave('picklefish_mod_x', 1),
CreateString('picklefish_mod_version', 'version1.0'),
SetSave('picklefish_mod_version', 'version1.0')
)
);"
/>
This checks if the version variable has been created and is equal to "version1.0", if it hasn't been, it will set them all.
Updating Variable:
Every time you want to update your variable (picklefish_mod_x) you call SetSave('picklefish_mod_x', 1);
or
SetSave('picklefish_mod_x', 0);
or whatever value you want to set to it.
Patching Mod:
If you are adding new variables simply change all cases of 'version1.0' to a new version like 'version1.1'.
If you are not adding new variables then you don't need to change anything.
Other notes:
You can actually check every variable if you want. Instead of checking version you would do this for every one.
<panel
width="0h"
height="0h"
onload="
if( !picklefish_mod_x,
Split(
CreateInt('picklefish_mod_x', 5),
SetSave('picklefish_mod_x', 5)
)
if( !picklefish_mod_y,
Split(
CreateInt('picklefish_mod_y', 5),
SetSave('picklefish_mod_y', 5)
)
if( !picklefish_mod_z,
Split(
CreateInt('picklefish_mod_z', 5),
SetSave('picklefish_mod_z', 5)
)
);"
/>
Keep in mind that this seems to be very buggy/hard to get perfect.
Hope this helps. Check out my Stats mod in my signature to see how I do it. Look in the