Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Michael

Energy Stored

Question

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

image.thumb.png.b1d51645c128b5ae373690e7d104e8e4.pngimage.thumb.png.dd8c47bdb1ec11f75cabbfafa4fbd9a7.png

Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 1
  • Solution

Well, this means the ic2_te_mfsu component doesn't have the getMaxEnergyStored method. The reason the crash occures after click is that you fetch the values after pulling a touch event (before the first update, the default value is used, i.e. 0).

To get a list of available methods, run the following command in the OpenOS shell:

components -l ic2_te_mfsu | less

 

Link to post
Share on other sites
  • 0
7 hours ago, Fingercomp said:

Well, this means the ic2_te_mfsu component doesn't have the getMaxEnergyStored method. The reason the crash occures after click is that you fetch the values after pulling a touch event (before the first update, the default value is used, i.e. 0).

To get a list of available methods, run the following command in the OpenOS shell:


components -l ic2_te_mfsu | less

 

Thanks for the response, as suggested I ran this code and was displayed this output

image.thumb.png.9697c0ec0ca02b4453333c1994e67a8b.png

So i changed my code based on this, as seen bellow

image.png.b8d4d69c5ec29c79313f36863287808a.png

but unfortunately

image.thumb.png.c4bbebf475d19f757ca8d84fa6cafbbc.png

Link to post
Share on other sites

Join the conversation

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.