Can't make anything to work… :(
Since EXP per level is static, I want to be able to set it on a per world basis (since my MCL files are per-character).
But whenever I try to re-use the value, it's a nil.
Here's the variable state file:
And here's part of the script:
I also tried a different way, manually setting a variable via Shift+CTRL+7 but the plugin doesn't see it, tried GetVariable, GetPluginVariable, to no avail.
*shrugs* Not sure what I'm missing or might have misunderstood.
Anyway, it's for my EXP bar.
Thanks ^_^
Since EXP per level is static, I want to be able to set it on a per world basis (since my MCL files are per-character).
But whenever I try to re-use the value, it's a nil.
Here's the variable state file:
<variable name="char_exp">char_exp = {
xpl = "16000",
}</variable>
And here's part of the script:
require "serialize" -- needed to serialize table to string
char_exp = {} -- ensure table exists, if not loaded from variable
function OnPluginInstall ()
assert (loadstring (GetVariable ("char_exp") or "")) ()
end -- function OnPluginInstall
function OnPluginSaveState ()
SetVariable ("char_exp",
"char_exp = " .. serialize.save_simple (char_exp))
end -- function OnPluginSaveState
if char_exp == nil then -- pop-up dialog for the first time
xpl = utils.inputbox (
"Max XP per level?", -- text question
"XP per Level", -- window title
nil, -- field pre-text
nil, -- font
nil, -- font-size
{ -- dialog box dimensions
box_width = 180,
box_height = 130,
prompt_height = 12,
reply_width = 80,
reply_height = 20,
max_length = 12,
}
)
char_exp.xpl = xpl -- push dialog value to char_exp.xpl for saving
char_xpl = xpl -- push dialog value to char_xpl for XP bar use
else -- already set
char_xpl = char_exp.xpl -- reuse existing value in state file
Note ("char_xpl: " .. char_exp.xpl) -- test if it's working
end
I also tried a different way, manually setting a variable via Shift+CTRL+7 but the plugin doesn't see it, tried GetVariable, GetPluginVariable, to no avail.
*shrugs* Not sure what I'm missing or might have misunderstood.
Anyway, it's for my EXP bar.
Thanks ^_^