I don’t really care if you going to check everything you wrote during making update or whatever… my point is that you can easily change it and you don’t need to check everything because the most important for all of us (or at least I think) is time… in meanwhile you can do a lot more things than checking if you made any mistake.
Who would save the whole table :Dd the only necessary thing is the item identificator and that’s 1 in this situation, because you need it to access the data from table that aren’t suppose to be saved.
You can make mistakes and everybody on this planet makes mistakes, if you tell me that you aren’t making mistakes then you are lying to yourself.
How does naming items have something to do with sanity checks? I am just saying what are the best practices when working with tables and data.
local items = {
[1] = "Wood"
[2] = "Apple"
[3] = "Box"
}
local targetItem = "Wood" -- the item you want to check what the ID is.
local itemID -- you won't assign this since you don't have the value, yet.
for id, item in pairs(items) do
-- id is the key
if item == targetItem then
itemID = id
end
end
print(itemID) -- now you know what ID 'Wood' is.
If I’ve got a-lot of values, I’m talking 100s, is this still reliable? Would it take too long or cause any problems if I had to individually check each value?
local items = {
[1] = "Wood",
[2] = "Apple",
[3] = "Box"
}
print(items[1]) -- "1" is the id, this is how you get the item
print(table.find(items, "Wood")) -- "Wood" is the item, this is how you get the id