1
Tbl = {"ex","x"}
Is it shared to everyone? Because I'm making an inventory system made from tables. Thank you.
Tbl = {"ex","x"}
inv = {} -- Create the master table addhook("join","createinv") function createinv(id) 	inv[id] = {"ex","x"} -- Create the inventory table that's exclusive to player 'id' end addhook("serveraction","displayinv") function displayinv(id,a) 	if a == 1 then 		menu(id,"Inventory,"..inv[id][1]..","..inv[id][2]) -- Show the player their inventory 	end end addhook("leave","destroyinv") function destroyinv(id) 	inv[id] = nil -- Destroy a player's inventory when they leave the server end
addhook("attack","additemtest") function additemtest(id) 	table.insert(inv[id],"item") -- Inserts an item into a player's inventory every time they attack end
function init_array(length,mode) 	local array={} 	for i=1,length do 		array[i]=mode end 	return array end myowntable=init_array(32,"")
myowntable[1]="Testing"
tbl={} function c_table(t,c) 	if type(t)=="table" then 		print(string.format("%s exists.",t)) 	else 		print(string.format("%s doesn't exist.",t)) 		if type(c)=="number" and c==1 then 			local t={};return t 		else 			print(string.format("Wrong parameter value %q. Try %q instead.",c,1)) 		end 	end end --[[ This creates new table based on checked table if checked table doesn't exist. ]]-- tbl2=c_table(tbl2,1) -- Create table if table doesn't exist. --[[ This checks if table exists. ]]-- c_table(tbl) -- Check if table exists.
shop=c_table(shop,1) -- Checks if table exists already and if it don't. It creates table with name shop. print(shop) -- The table named shop is now usable. tbl={} -- Otherwise use this to create a table, whatever is preferred. There's many ways to accomplish things. shop[1]="Value" -- Storing strings. shop[2]=1234 -- Storing integers (signed or unsigned). shop[3]=1 -- Storing objects (such as images). shop[4]=tbl -- Storing tables within specific table indexes. -- Learn Lua by watching some tutorials and you will comprehend it.
If button == 1
pocinventory = {} function table.createNested(s) 	local tbl = {} 	for k = 1, s do 		tbl[k] = {} 	end 	return tbl end pocinventory.shop_items = { 	[1] = "Item 1", 	[2] = "Item 2", } pocinventory.inventory = table.createNested(32) addhook("leave","pocinventory.leave") function pocinventory.leave(id) 	for k in pairs(pocinventory.inventory[id]) do pocinventory.inventory[id][k]=nil end -- Clear inventory end addhook("serveraction","pocinventory.serveraction") function pocinventory.serveraction(id, a) 	if (a == 1) then -- Open shop (F2) 		menu(id, "Shop,"..table.concat(pocinventory.shop_items,",")) -- Display shop items in a menu (the first 9) 	end 	if (a == 2) then -- Open inventory (F3) 		menu(id, "Inventory,"..table.concat(pocinventory.inventory[id],",")) -- Display inventory in a menu (the first 9) 	end end addhook("menu", "pocinventory.menu") function pocinventory.menu(id, menu, button) 	if (menu == "Shop") then 		if (pocinventory.shop_items[button]) then -- Just in case 			table.insert(pocinventory.inventory[id],pocinventory.shop_items[button]) -- Add item to inventory 	end end