Saving Tables and Var Problem..

azure_glass
Posts: 97
Joined: Wed Jul 25, 2012 12:35 pm

Saving Tables and Var Problem..

Post by azure_glass »

Hi!

How to do a simple table with i can save? The wikipedia example does not work :/
I need to store only one value and make it sometime +1 by few triggers.


And more complicated :/


My mud does not accept "kill 1 enemy" must be "kill first enemy"

so i make
Code: [show] | [select all] lua
function SwitchNames()

if CountingMobs ==  1 then y = "first" end
if CountingMobs ==  2 then y = "second" end
if CountingMobs ==  3 then y = "third" end
.....
if CountingMobs ==  20 then y = "twenty" end
in
Code: [show] | [select all] lua
cecho("Con", "abc" .. y .. "abc")
switchNames() is working propertly to each line. but not in
Code: [show] | [select all] lua
echoLink("Con", x, [[send("kill " ..  y .. " enemy")]], "kill " ..  y .. " enemy", true)
the value of y is always top of the number of mobs on location

What to do?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Saving Tables and Var Problem..

Post by Vadi »

Code: [show] | [select all] lua
echoLink("Con", x, [[send("kill ]]..y..[[ enemy")]], "kill " ..  y .. " enemy", true)
You were embedding the y a bit wrong.

azure_glass
Posts: 97
Joined: Wed Jul 25, 2012 12:35 pm

Re: Saving Tables and Var Problem..

Post by azure_glass »

OMG !!! It works :D

But how to save table?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Saving Tables and Var Problem..

Post by Vadi »

Follow the wiki examples - they do work... you'll need to show what are you doing that's not working.

azure_glass
Posts: 97
Joined: Wed Jul 25, 2012 12:35 pm

Re: Saving Tables and Var Problem..

Post by azure_glass »

http://wiki.mudlet.org/w/Manual:Technical_Manual

code is copy pasta from wikipedia
----/save

----/save

----
----Variables saved in: '/home/xxx/.config/mudlet/profiles/Arkadiamychar'
----/load

----
----{
age = 26,
name = "Bob",
sex = "male"
}

----
My name is: Bob
----

restarting mudlett and /load


----
----nil


----
Code: [show] | [select all] lua
Alias name=^/load$(^/load$) matched.
Alias: capture group #1 = </load>
LUA: ERROR running script ^/load$ (Alias156) ERROR:[string "function Alias156()..."]:7: attempt to 
index global 'mychar' (a nil value)

Code: [show] | [select all] lua
-- echo a link named 'press me!' that'll send the 'hi' command to the game
echoLink("press me!", [[send("hi")]], "This is a tooltip")
 
-- do the same, but send this link to a miniConsole
echoLink("my miniConsole", "press me!", [[send("hi")]], "This is a tooltip")
Look at the syntax of example. Copy-pasta.,,, I hardly image that i will have idea to do "]]..y.. [["

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Saving Tables and Var Problem..

Post by Vadi »

Check the example now - there were two missing /'s and that's the first time someone pointed it out.

azure_glass
Posts: 97
Joined: Wed Jul 25, 2012 12:35 pm

Re: Saving Tables and Var Problem..

Post by azure_glass »

still the same :/
Code: [show] | [select all] lua
[ERROR:] object:<^/load$> function:<Alias156>
         <[string "function Alias156()..."]:4: attempt to index global 'mychar' (a nil value)>
I have Ubuntu 13.04

And Mudlet from ppa.

Code: [show] | [select all] lua
return {{[ [[age]] ] = 26,[ [[name]] ] = [[Bob]],[ [[sex]] ] = [[male]],},
}
that's all from that file.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Saving Tables and Var Problem..

Post by Vadi »

That's right, you can't echo mychar if it doesn't exist yet, which it won't if you've restarted Mudlet. Delete that sample line from the loading part...

azure_glass
Posts: 97
Joined: Wed Jul 25, 2012 12:35 pm

Re: Saving Tables and Var Problem..

Post by azure_glass »

For me that is not right because mudlett does not save name of table so he can't load it property look at the content of file (up) I think that is a bug.

remember() function also does not work :/

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Saving Tables and Var Problem..

Post by Vadi »

The name of the table isn't saved, but when you're loading it, you can give it the same name.

Post Reply