Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function string.jsub(str, startIndex, endIndex)
- if (endIndex == nil) then
- endIndex = string.len(str) + 1
- end
- return string.sub(str, startIndex, endIndex - 1)
- end
- -- Checks if the given `str` starts with the given `value` (optionally start searching with the given start offset index. 1 by default). `string.startsWith("hello", "he", 1)` == `true`
- function string.startsWith(str, value, startIndex)
- if (startIndex == nil) then
- startIndex = 1
- end
- return string.jsub(str, startIndex, string.len(value) + startIndex) == value
- end
- -- Checks if the given `str` ends with the given value. string.endsWith("hello", "lo") == true
- function string.endsWith(str, value)
- local strLen = string.len(str)
- local valLen = string.len(value)
- return string.sub(str, strLen - valLen + 1, strLen) == value
- end
- function string.contains(str, value, startIndex)
- if (startIndex == nil) then
- startIndex = 1
- end
- return
- end
- function string.indexOf(str, value, startIndex)
- if (startIndex == nil) then
- startIndex = 1
- end
- local s,e,c = string.find(str, value)
- if (s == nil) then
- return -1
- end
- return s
- end
- peripherals = { }
- Monitor = peripheral.wrap("right")
- function loadCells()
- for i, name in pairs(peripheral.getNames()) do
- if (string.startsWith(name, "cofh_thermalexpansion_energycell")) then
- local id = tonumber(string.sub(name, 33))
- local handle = peripheral.wrap(name)
- peripherals[id] = {
- handle = handle,
- full_name = name,
- energyMin = 0,
- energyMax = handle.getMaxEnergyStored("UNKNOWN"),
- energyNow = handle.getEnergyStored("UNKNOWN"),
- id = id
- }
- end
- end
- end
- function main()
- loadCells()
- for k,v in pairs(peripherals) do
- print(k .. " - " .. v)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement