Jump to content




CC EU Storage

computer command lua

5 replies to this topic

#1 xTheChosen0ne

  • Members
  • 12 posts

Posted 17 June 2015 - 04:44 PM

Hey guys, i use TekkitLite. At first, sorry for my bad english, i am german :D

I have the following problem: I want to make a program, which allows me to see how much EU is in a MFE actually. I used CCSensors, and tried to make it alone, but i just can't find a method to read the Power Level.

I want, that the MFE stops giving out Energy when it has less then 10000 EU.




Thank you
Greetz

#2 Dustmuz

  • Members
  • 174 posts
  • LocationDenmark

Posted 17 June 2015 - 04:51 PM

im using openperipherals (MC 17.10)

i just wrap my MFE with a modem (thats how i do it)
and then i can do something like this

local MFE = peripheral.wrap(name of MFE)

while true do
  local ener = MFE.getEnergyStored()
  if ener <= 10000 then
   "something"
  else
   "something else"
  end
  sleep(1)
end



#3 xTheChosen0ne

  • Members
  • 12 posts

Posted 18 June 2015 - 12:08 PM

View PostDustmuz, on 17 June 2015 - 04:51 PM, said:

im using openperipherals (MC 17.10)

i just wrap my MFE with a modem (thats how i do it)
and then i can do something like this

local MFE = peripheral.wrap(name of MFE)

while true do
  local ener = MFE.getEnergyStored()
  if ener <= 10000 then
   "something"
  else
   "something else"
  end
  sleep(1)
end


Thank you. This dont works for me, maybe i misunderstands something. I can't find the variable peripheral.getEnergyStored() in the CCwiki.
Please help.

#4 xTheChosen0ne

  • Members
  • 12 posts

Posted 18 June 2015 - 01:14 PM

I think i know the problem. "mfe.getEnergyStored()" and "mfe.getEUCapacity" for example, don't works.
It always says "attempt to index ? (a nil value)". I don't know why. And yes, i did "mfe=peripheral.wrap("SIDE")" before.
But i dont know, why it is like that.

#5 Dustmuz

  • Members
  • 174 posts
  • LocationDenmark

Posted 18 June 2015 - 02:13 PM

you need to wrap your peripheral

mfe.getEnergyStored("side") would always return nil.. as "side" isnt where your MFE is..

the program i made was only to show you how to do it..
you would still need to know where your MFE is..
lets make another example..

your computer is right next to the MFE.. (left side of the computer, is where the MFE is)

local MFE = peripheral.wrap("left")

while true do
  local ener = MFE.getEUStored()
  if ener <= 10000 then
   print("less than 10K")
  else
   print("more than 10K")
  end
  sleep(1)
end


this code should work (did for me on my test setup)

#6 xTheChosen0ne

  • Members
  • 12 posts

Posted 18 June 2015 - 07:01 PM

View PostDustmuz, on 18 June 2015 - 02:13 PM, said:

you need to wrap your peripheral

mfe.getEnergyStored("side") would always return nil.. as "side" isnt where your MFE is..

the program i made was only to show you how to do it..
you would still need to know where your MFE is..
lets make another example..

your computer is right next to the MFE.. (left side of the computer, is where the MFE is)

local MFE = peripheral.wrap("left")

while true do
  local ener = MFE.getEUStored()
  if ener <= 10000 then
   print("less than 10K")
  else
   print("more than 10K")
  end
  sleep(1)
end


this code should work (did for me on my test setup)

Thank you, my problem is solved. The problem is, MFE is no peripheral. I placed a sensor, and it works now.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users