 |
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Tue Nov 04, 2008 10:39 pm
[lua] variable transcribtion |
empty session
| Quote: |
#ADDK a {1=d|2=c|4=7} //numerical keys are the "key" here
#VA a //to check |
switch to lua
| Quote: |
va = {}
va.a = zs.getvar("a")
for i,v in ipairs(va.a.value) do print(i,v) end -- fine, theres a break cause its not stringlist
a = va.a.value
for i,v in ipairs(a) do print(i,v) end -- still fine
print(a) -- all ok, lets go back then
va.a.value = a
for i,v in ipairs(va.a.value) do print(i,v) end
print(va.a.value) -- guess we have stringlist now... |
|
|
|
|
 |
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Tue Nov 18, 2008 11:15 am |
***BUMP***
of course, im the only one who ever uses those things it seems, but its a pretty serious (and irrecoverable if one is unaware and dont have backup) variable corruption
course, i dont even need it fixed since now i store me lua vars in own sql db, but point is above should work and i shouldnt be needing to double functionality of basic aux functions to work around quirks  |
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Nov 18, 2008 6:11 pm |
CMUD only converts a string list or database variable into a Lua table when you access it via the zs.var.a function. When you retrieve the variable object using zs.getvar() and then access the "value" property directly, you are actually retrieving the raw string value stored in the database for the variable. Doing the low-level database access is not recommended. You lose all of the internal hash table caching when you do this.
So the correct way to access the variable is via the zs.var.varname function. |
|
|
|
 |
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Tue Nov 18, 2008 9:07 pm |
same thing will happen when writing back with zs.var.a = a - cmud variable becomes stringlist, and keys are lost
true, but access time after transcribing a var to lua-native is greatly improved, i was using cmuds variable only as savable storage means there |
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Nov 18, 2008 10:25 pm |
Oh, I see what you are saying. If a table is getting converted to a string list instead of a database variable, then that's definitely a bug and I've added it to the bug list.
|
|
|
|
 |
|
|
|