9 posts
Posted 19 June 2016 - 06:48 AM
Hi. I need help with the method getJobList(). I'm fairly new to lua and I want to just display the name of item(s) being crafted, rather then print the whole table you get from getJobList()
7083 posts
Location
Tasmania (AU)
Posted 19 June 2016 - 09:39 AM
9 posts
Posted 21 June 2016 - 08:36 AM
Here's the code so far :—Background, I started programming a few days a go. This is my first attempt at a useful program. I would like to be able to show the items crafting if any, and not just show the whole table returned by "control.getJobList()" if you know how to do that, let me know.
—-ME Status Program—Jackson_Pike—-Connect wired modem to computer, ME controller, and Monitor
—Adjust Peripheral Wrapping based on your #'s
——-Wrapping Peripherals————————–
control = peripheral.wrap("appeng_me_tilecontroller_0")
mon = peripheral.wrap("monitor_4")
mon.setBackgroundColor(colors.black)
mon.clear()
function Draw_Line(xPos, yPos, length)
mon.setCursorPos(xPos, yPos)
mon.setBackgroundColor(colors.purple)—Change to Desired Color
mon.write(string.rep(" ", length))
end
while true do
monX, monY = mon.getSize() —- Getting Size of Monitor
—————————————————–
mon.setBackgroundColor(colors.black)
————————-Defining Variables—————-
BUsed = control.getUnusedBytes()—–Methods Error, actually returns Used Bytes
BFree = control.getFreeBytes()
BTotal = control.getTotalBytes()
EnergyStored = control.getEnergyStored("appeng_me_tilecontroller_0")
EnergyFinal = EnergyStored / 2
–pollCraft = control.getJobList()–I hope to add later. Get's items crafting in MAC
BUsedDecimal = BUsed / BTotal
BFreeDecimal = BFree / BTotal
BUsedPercent = BUsedDecimal * 100
BFreePercent = BFreeDecimal * 100
UsedOutput = math.floor(BUsedPercent)—-Rounds
——————–End Variables———————————
mon.setBackgroundColor(colors.black)
mon.clear()
Draw_Line(1, 1, monX)
Draw_Line(1, monY, monX)
mon.setTextColor(colors.white)
mon.setCursorPos(monX/2-4.5, 1)
mon.write("ME Status")
mon.setBackgroundColor(colors.black)
mon.setCursorPos(1,3)
mon.write("Storage Used: "..UsedOutput.."%")
mon.setCursorPos(1,4)
mon.write("Energy Stored: "..EnergyFinal.." AE")
sleep(1)
end
——-Please report bugs, and feel free to suggest things.
Im using a wired modem to get info from the ME controller in AE 1.6.4.
One of the methods is called "getJobsList()" it returns a table with a bunch of info of what's currently crafting in the Molecular assembly chamber. (Auto crafter). In the table of course is the name of the item crafting. How would I just get the name, rather then the whole table, to display on the monitor? Sorry if it's simple. I just started coding a few days ago.
7083 posts
Location
Tasmania (AU)
Posted 22 June 2016 - 01:18 AM
One of the methods is called "getJobsList()" it returns a table with a bunch of info of what's currently crafting in the Molecular assembly chamber. (Auto crafter). In the table of course is the name of the item crafting. How would I just get the name, rather then the whole table, to display on the monitor? Sorry if it's simple. I just started coding a few days ago.
Figure out which key holds the data you want and just print that. Compare the table structure to second link I provided you.
If you don't know how to view the table structure, this would allow you to save an example to disk:
local output = fs.open("tableExample.txt", "w")
output.writeLine( textutils.serialise( control.getJobList() ) )
output.close()
9 posts
Posted 22 June 2016 - 06:44 PM
hai, so here is the code i have to get an idea where the name is in the table.
mon = peripheral.wrap("monitor_4")
mon.clear()
while true do
mon = peripheral.wrap("monitor_4")
control = peripheral.wrap("appeng_me_tilecontroller_0")
mon.setCursorPos(1, 1)
poll = control.getJobList()
mon.write(poll[1])
sleep(1)
end
poll returns everything in the [1] part of the table. So like all the data isn't separated into different sections in the table, it's all on [1]. Quantity, Name, ID, ect