Thank you in advance. :D/>
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
ME Storage logging system using ComputerCraft
Started by xRegret, 28 June 2014 - 10:22 PMPosted 29 June 2014 - 12:22 AM
Hello. Before I ask my question i'd like to say that I am referring to the Applied Energetic mod in case you're wondering. Anyway, I way wondering if it was possible to log what comes in and out of a ME 64K storage? For example a player right clicks on an ME Access terminal and takes 64 pieces of Redstone. A ComputerCraft monitor puts it up as text saying it was taken. Vice versa with items being put in. I am wondering because this would be a good way to check if people have been taking stuff from my storage ya know?
Thank you in advance. :D/>
Thank you in advance. :D/>
Posted 29 June 2014 - 07:43 AM
Yes it is possible, however it would require the computer to keep a record of everything that is in the AE network, and then periodically (say once a second) check the levels again for any differences. there will be no way for you to validate who took the items so even when you take them your program would log those items. same as any automation you have that may remove/add items along with auto-crafting etc.
Posted 29 June 2014 - 07:52 AM
Hmmm…I'm not sure offhand how the coding would work, but I'm reasonably sure you could use an OpenCC Sensors player detector and whenever a change is detected in the AE network; log the changes, the time, and the players in the area. If the player detector returns coordinates (or you combine multiple player detectors) you could just log the players near the AE terminal. If the player detector returns coordinates and facing you could probably figure out who exactly is using the terminal, even with several players in the vicinity. What you want to do should be (mostly) possible, but it would probably be a bit complex for a first project.
Edited on 29 June 2014 - 06:25 AM
Posted 29 June 2014 - 08:03 AM
How could I go about doing such a thing? I really just want to log whats coming in and out of the network to be honest :P/>Yes it is possible, however it would require the computer to keep a record of everything that is in the AE network, and then periodically (say once a second) check the levels again for any differences. there will be no way for you to validate who took the items so even when you take them your program would log those items. same as any automation you have that may remove/add items along with auto-crafting etc.
It sounds good and all but is there any way you could get me started? Like you said yourself it does sound a bit complex but all I really need to know is how to log the time, item that was taken, and the date as well. You dont have to code the entire script but steering me to the right direction would be nice. :)/>Hmmm…I'm not sure offhand how the coding would work, but I'm reasonably sure you could use an OpenCC Sensors player detector and whenever a change is detected in the AE network; log the changes, the time, and the players in the area. With multiple player sensors you could narrow it down to areas around your AE terminals. What you want to do might be possible, but it would probably be a bit complex for a first project.
Edited on 29 June 2014 - 02:44 PM
Posted 30 June 2014 - 05:32 AM
Hello. I recently posted a thread about making an AE Network manager. Nonetheless I have made a lot of progress, but I have a problem with two things and I was wondering if you guys could help me. :)/>
Now, here is the first problem. I added a feature where if the ME Controller is NOT present then it will prompt it. I'm trying to make it real-time so if it gets removed the program would notify it. I tried using 'while true do' but it just spammed "ME Controller is NOT present!"
I am trying to make it where if it does get removed then it would notify you that is has been..well removed.
here is the code:
Now this only checks if its present once. I'm trying to make it where it would check it continuously without having massive spam of text. Could you help me?
Now for my second problem. I am also trying to setup a way to show how much bytes is left in the Network. Now normally if you have an ME storage(s) in the drive it would say it..BUT if you dont have any storages in the Drive it would just prompt saying "00". Now im trying to get it to be where if its 00 then it would say (tgegs)
heres the code:
Now, here is the first problem. I added a feature where if the ME Controller is NOT present then it will prompt it. I'm trying to make it real-time so if it gets removed the program would notify it. I tried using 'while true do' but it just spammed "ME Controller is NOT present!"
I am trying to make it where if it does get removed then it would notify you that is has been..well removed.
here is the code:
mec = peripheral.wrap("bottom")
if (peripheral.isPresent("bottom")) then
term.setTextColor(colors.green)
print("ME Controller is present")
else
term.setTextColor(colors.red)
print("ME Controller is NOT present!")
sleep(2)
print(" ")
print("PC shutting down..make sure ME controller is present (under pc)")
sleep(5)
Now this only checks if its present once. I'm trying to make it where it would check it continuously without having massive spam of text. Could you help me?
Now for my second problem. I am also trying to setup a way to show how much bytes is left in the Network. Now normally if you have an ME storage(s) in the drive it would say it..BUT if you dont have any storages in the Drive it would just prompt saying "00". Now im trying to get it to be where if its 00 then it would say (tgegs)
heres the code:
local mec = peripheral.wrap("bottom")
local totalf = mec.getFreeBytes()
local totalb = mec.getTotalBytes()
math = mec.getFreeBytes()*100/mec.getTotalBytes()
function test(num, idp)
local mult = 10^(idp or 0)
end
term.setTextColor(colors.purple)
print("Free Space:")
if mec.getFreeBytes == 00 then
print(totalf,0," bytes (No ME Drive Loaded)")
else
print(totalf,0," bytes")
end
print(" ")
print("Total Space:")
print(totalb,0," bytes")
sleep(0)
This doesn't work by the way. :P/> Could anyone help me?Posted 30 June 2014 - 05:35 AM
Threads merged.
Posted 30 June 2014 - 06:05 AM
Now, here is the first problem. I added a feature where if the ME Controller is NOT present then it will prompt it. I'm trying to make it real-time so if it gets removed the program would notify it. I tried using 'while true do' but it just spammed "ME Controller is NOT present!"
I am trying to make it where if it does get removed then it would notify you that is has been..well removed.
here is the code:mec = peripheral.wrap("bottom") if (peripheral.isPresent("bottom")) then
I suggest you reverse the two above statements and place them in an if statement. Wrapping before knowing if there is a peripheral there can result in errors later.
if peripheral.isPresent("bottom") then
mec = peripheral.wrap("bottom")
term.setTextColor(colors.green)
print("ME Controller is present")
else
term.setTextColor(colors.red)
print("ME Controller is NOT present!")
print(" ")
print("PC shutting down..make sure ME controller is present (under pc)")
sleep(5)
end
If you want it to check repeatedly, you'd probably want to put it in a 'while' or 'repeat' loop. To have it check while doing other things, you'll want to take a look at the parallel api
Now for my second problem. I am also trying to setup a way to show how much bytes is left in the Network. Now normally if you have an ME storage(s) in the drive it would say it..BUT if you dont have any storages in the Drive it would just prompt saying "00". Now im trying to get it to be where if its 00 then it would say (tgegs)
heres the code:This doesn't work by the way. :P/> Could anyone help me?local mec = peripheral.wrap("bottom") local totalf = mec.getFreeBytes() local totalb = mec.getTotalBytes() math = mec.getFreeBytes()*100/mec.getTotalBytes() function test(num, idp) local mult = 10^(idp or 0) end term.setTextColor(colors.purple) print("Free Space:") if mec.getFreeBytes == 00 then print(totalf,0," bytes (No ME Drive Loaded)") else print(totalf,0," bytes") end print(" ") print("Total Space:") print(totalb,0," bytes") sleep(0)
I don't know if this will solve the problem, but I did notice several things you should address…
First, please indent your code - it'll make it easier to read and edit. By indenting your code I found a function that isn't even being called. It can probably just be removed.
Second, your print statements appear to be incorrectly formatted. 'print' (to my knowledge) takes one argument - what is to be printed. If you are trying to concatenate, you would use '..' (two dots)
print(totalf .. " bytes (No ME Drive Loaded)")
Next…even though you don't end up using your 'math' variable anywhere, you should rename it to something else if you are going to keep that part in your code. 'math' is an api and using that name for your variable essentially disables all calls to the math api for your program (if you later chose to use that api). In general it's bad practice to use api names as variable names unless you are intending to replace the api functionality.
math = mec.getFreeBytes()*100/mec.getTotalBytes()
Instead use something like…
storagePercent = mec.getFreeBytes()*100/mec.getTotalBytes()
Finally…
if mec.getFreeBytes == 00 then
I don't know if it would make a difference, but have you tried this…
if mec.getFreeBytes == 0 then
Hope that helps :)/>
Edited on 30 June 2014 - 04:15 AM
Posted 30 June 2014 - 06:07 AM
perhaps making mec.getFreeBytes a function call might help :P/> comparing a function pointer to a number will always return false.I don't know if it would make a difference, but have you tried this…if mec.getFreeBytes == 0 then
Posted 30 June 2014 - 06:12 AM
*drops head in shame* … rather embarrassed I missed that…perhaps making mec.getFreeBytes a function call might help :P/> comparing a function pointer to a number will always return false.
@xRegret change this…
if mec.getFreeBytes == 0 then
to this…
if mec.getFreeBytes() == 0 then
That way you are calling the function (and comparing to its output), instead of comparing to the function pointer
Edited on 30 June 2014 - 04:20 AM