Your prompt crashed with nil value right? Because there is no "strength" call (that I know of) and nor can you "init" twice either so the array never initiliased.
Let's wind back a bit. There is a neat "trick" I've been playing with using NAME where I use name to simply pass an index (your own "e" so to speak) but the same index can apply to multiple items.
Scenario. A bottle of water with water.lua attached. It is named "1".
I get the "1" via init_name function and then grab the corresponding entity string. (The advantage of hardcoding the string means I have one place to manage the values of ALL water bottles on my map with a name of "1")
eg:
--*********************************
function getItemData(itemIDX)
itemIDX = tonumber(itemIDX) -- name is a string - do a conversion - avoid confusion
--PromptDuration("ItemIDX "..itemIDX,5000)
local s="ERROR" -- error trap in case we send a bad index by mistake
-- index, count, type, name, value, weight, img#, health, energy, thirst, hunger, stamina
if itemIDX == 1 then s = "1,1,DRINK,Bottle0of0Water,10,800,0,1,1,0,1,2" -- water
elseif itemIDX == 2 then s = "2,6,FOOD,Beef0Jerky,5,100,1,3,2,2,4,1" -- beef jerky
end.
return s
-- etc...
Note: This is my completed code. You need to fill in the bits you need.
I then parse the string and do a breakout of the values I need (a "pop") into individual local vars
--*********************************
function popItem(s)
local tblIDX = 1
for i in string.gmatch(s, "%w+") do --Where "%w+" is the alphanumeric string pattern.
tbl[tblIDX] = i
tblIDX=tblIDX+1
end
-- index, count, type, name, value, weight, img#, health, energy, thirst, hunger, stamina
iIDX = tonumber(tbl[1])
iCount = tonumber(tbl[2])
iType = tbl[3]
iName = string.gsub(tbl[4],"0"," ") -- strip out 0 padding
iValue = tonumber(tbl[5])
iWgt = tonumber(tbl[6])
iImg = tonumber(tbl[7])
iHl = tonumber(tbl[8])
iEn = tonumber(tbl[9])
iTh = tonumber(tbl[10])
iHu = tonumber(tbl[11])
iSt = tonumber(tbl[12])
end -- func popItem
You'll note the use of "0" (zero) in the name Bottle0of0Water. This is deliberate to prevent the parse creating 3 vars at the spaces. gsub modifies.
In this coding example the only thing I "carry" around is an array of item indexes and I only query the index and parse as needed. (for display, enviromental changes or to update player values etc.)
This technique can apply to *any* entity that has a name property. I use the exact same technique to have hundreds of trees on a map, each tree type has different shade values. I also use the exact same technique to manage a huge number of inventory items (as this example shows).
With boxes you could use BoxM and BoxS as indexes rather than numbers etc.... BoxM might be strength 10, BoxS might be strength 5 etc....
There's a lot of power at your disposal here. Just keep track of your indexes and manage the values of each index in script. If you want to move, delete, use, blow up, destroy any item, the entity still uses "e" but has a lot more other info as well.
Happy to answer further queries. Note this is just
one way to do things - but it's dynamic, very efficient and has very low overheads.
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD