I'm trying to set up a Opencomputers energy monitoring system that will control the energy level of an Industrialcraft2 mfsu by turning on 1 to 6 reactors but I'm having problems at the energy reading part.
Here is my code so far: https://pastebin.com/654kRYaf (ignore that getEnergyStored is commented out, I was testing something and uploaded to pastebin wrong version), but here is an abbreviated version with comments:
-------------start of script----------
local fill = 0 --predefine variable fill
local cap = 0 --predefine variable capacity
require 'normal' things (event, component, term, colors, sides)
local rs = component.redstone --Redstone I/O block
local mfsu = component.ic2_te_mfsu ---as shown when components is run
----------create writing------------------
---create writing and boxes
----------reset redstone (just in case) ----
set colors used to 0
-------------------------------------------
------------------------------------------------------------------------
while true do
local _,_,x,y = event.pull("touch") -----works up to this point
fill = mfsu.getEnergyStored() --find amount of energy in mfsu
cap = mfsu.getMaxEnergyStored() --find capacity of mfsu
print(fill, cap) ---print it (temp)
--------check user clicks squares and set redstone outputs--------
--//insert computer turn on reactors here (to do later)\\--
end ---end of script---
I plan to implement code that will turn off and on the reactors depending on the amount of energy in the mfsu but I havent been able to read the amount of energy in the mfsu to be able to make the calculations.
(the big empty space on the left of the screen is for a progress bar that is currently hidden, which depends on the amount of energy in the capacitor)
As you can see (bellow) the code works fine until the user clicks the screen, at which point it errors, the Max energy or current energy "returns a nil" and the code discontinues running. to my understanding this means that this doesn't exist therefore what is the current terminology?
I could find one that works but I wanted to make one myself.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Hello everyone,
I'm trying to set up a Opencomputers energy monitoring system that will control the energy level of an Industrialcraft2 mfsu by turning on 1 to 6 reactors but I'm having problems at the energy reading part.
Here is my code so far: https://pastebin.com/654kRYaf (ignore that getEnergyStored is commented out, I was testing something and uploaded to pastebin wrong version), but here is an abbreviated version with comments:
-------------start of script---------- local fill = 0 --predefine variable fill local cap = 0 --predefine variable capacity require 'normal' things (event, component, term, colors, sides) local rs = component.redstone --Redstone I/O block local mfsu = component.ic2_te_mfsu ---as shown when components is run ----------create writing------------------ ---create writing and boxes ----------reset redstone (just in case) ---- set colors used to 0 ------------------------------------------- ------------------------------------------------------------------------ while true do local _,_,x,y = event.pull("touch") -----works up to this point fill = mfsu.getEnergyStored() --find amount of energy in mfsu cap = mfsu.getMaxEnergyStored() --find capacity of mfsu print(fill, cap) ---print it (temp) --------check user clicks squares and set redstone outputs-------- --//insert computer turn on reactors here (to do later)\\-- end ---end of script---
I plan to implement code that will turn off and on the reactors depending on the amount of energy in the mfsu but I havent been able to read the amount of energy in the mfsu to be able to make the calculations.
(the big empty space on the left of the screen is for a progress bar that is currently hidden, which depends on the amount of energy in the capacitor)
As you can see (bellow) the code works fine until the user clicks the screen, at which point it errors, the Max energy or current energy "returns a nil" and the code discontinues running. to my understanding this means that this doesn't exist therefore what is the current terminology?
I could find one that works but I wanted to make one myself.
Minecraft v. 1.10.2
Age Of Engineering v. 1.1.2 (Twitch modpack)
OpenComputers v. 1.7.1.150
Link to post
Share on other sites