it's me again, sorry...
This time I have a problem with setting a variable.
I basically want the variable to be the return of a function, but I can't figure out how to do this.
This is how I defined my variable (...wrong ):
local TorchSlot = SlotCalculator("T")
This is what the function looks like:
function SlotCalculator(code) if code == "T" then item = "minecraft:torch" end for i = 1, #slots do if slots[i] == code then if ItemCount(item, i) ~= false and ItemCount(item, i) > 0 then return i end end end end
The table for understanding:
slots = { "I", "I", "I", "_", "_", "_", "_", "_", "_", "_", "T", "T", "T", "T", "A", "C"}
function ItemCount:
function ItemCount(Block, Slot) if Slot == 0 then return false end if Version >= 1.64 then local Data = turtle.getItemDetail(Slot) if Data == nil then return 0 elseif Data.name == Block then return Data.count else return false end else return turtle.getItemCount(Slot) end end
When my program gets to the point, where it trys to call this variable it Errors out ("expected number").
I think that the variable has the function and not it's return information as value.
So, I want something like this:
local TorchSlot = (return of SlotCalculator("T"))
Thanks in advance,
Bruno
Edited by BrunoZockt, 04 March 2017 - 11:13 PM.