Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---- finds out which item it is and what fuel
- function getFuelFromTable(tab,value)
- for i,v in pairs(tab) do
- local a = v[1] -- name of item
- local b = v[2] -- heating value
- local valueClipped = ""
- local char1 = string.sub(a,1,1)
- if char1 == "*" then
- a = string.sub(a,2,-1)
- --crazy work around that allows wildcard-like functionality
- --> if the last characters of 'a' are the same as the last characters of 'value' then true
- local aLen = string.len(a)
- valueClipped = string.sub(value,-aLen,-1)
- --print(a)
- else
- valueClipped = value
- end
- if a == valueClipped then
- return b
- end
- end
- --not found
- return false
- end
- function getFuelValue(fuelSlot)
- local stdFuelValues = {
- {"minecraft:charcoal",80},
- {"minecraft:coal",80},
- {"minecraft:stick",5},
- {"minecraft:lava_bucket",1000},
- {"*_log",15},
- {"*_planks",15},
- {"*_plank",15},
- {"*_planks_slab",15},
- {"*_chest",15},
- {"*_wool",5}
- }
- local prevSlot = turtle.getSelectedSlot()
- --change slots, if neccesary
- if prevSlot ~= fuelSlot then
- turtle.select(fuelSlot)
- end
- --get the name of the item in fuel slot
- local a,b = turtle.getItemDetail()
- if a ~= nil then
- local name = a.name
- a=nil; b=nil
- local fuelValue = getFuelFromTable(stdFuelValues,name)
- return fuelValue
- else
- end
- --change slots back, if neccesary
- if fuelSlot ~= prevSlot then
- turtle.select(prevSlot)
- end
- return nil
- end
- --local fslot = 1
- --getFuelValue(fslot)
- return getFuelValue
Add Comment
Please, Sign In to add comment