McDeKi Posted March 21, 2014 Share Posted March 21, 2014 Hello, I was wondering how I should do save system for my inventory. --//Zapis przedmiotow\\-- function zapiszEkwipunek() for k,v in pairs( Plecak )do for i=1, wysokoscY do if not (Plecak[k][i] == false) then outputChatBox(k.."|"..i.."|"..Plecak[k][i].id) end end end end It works fine, output all items in inventory, for example here is the item with id 4, in the slot 5|1 and it outputs 5|1|4 What function I should use, split and gettok or table.insert and table.concat. Link to comment
Weii. Posted March 21, 2014 Share Posted March 21, 2014 function zapiszEkwipunek() testing = {} for k,v in pairs( Plecak )do for i=1, wysokoscY do if not (Plecak[k][i] == false) then table.insert(testing, v) end end end return testing end -- and they save it like inventoryJson = toJSON(zapiszEkwipunek()) -- and get it from json inventoryTable = fromJSON(inventoryJson) Link to comment
McDeKi Posted March 21, 2014 Author Share Posted March 21, 2014 I must save it according to scheme: Xslot, Yslot, ID for example (4,1,1|next Item|next Item) then I must save it in mysql as string and read the substrings, then I'm gonna add the items in the slots according to scheme X, Y, ID Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now