Jump to content




Readin power from an energycell.


  • You cannot reply to this topic
12 replies to this topic

#1 luckcolors

  • Members
  • 10 posts

Posted 06 January 2015 - 12:24 AM

Hello!
i'm trying to use direwolf20 reactor control program.[Lua] reactor - Pastebin.com
(Dire's button api for making the program work. http://pastebin.com/wuUbEdgY )
But i'm in tekkit 1.6.4 v1.2.9f and i have to use energycells for energy storage.
As i readed here energycells use the same call .getEnergyStored and .getMacEnergyStored for getting the stored energy ammount.
But i tried simply changing the peripheral name but it didn't work.
Can someone help me to get this working?
Thanks in advance. :)
here's the function that checks the stored ammount of energy:
function checkEn()
   local tempEnergy = 0
   energyStored = p.getEnergyStored()
   energyMax = p.getMaxEnergyStored()
   energyStoredPercent = math.floor((energyStored/energyMax)*100)
   RFProduction = r.getEnergyProducedLastTick()
   fuelUse = r.getFuelConsumedLastTick()
   fuelUse = math.floor(fuelUse*100)
   fuelUse = fuelUse/100
   coreTemp = r.getFuelTemperature()
   reactorOnline = r.getActive()
   tempEnergy = p.getEnergyStored()
   sleep(0.1)
   energy = (p.getEnergyStored()-tempEnergy)/2
end


#2 Dustmuz

  • Members
  • 174 posts
  • LocationDenmark

Posted 06 January 2015 - 05:43 AM

what kind of error are you getting when running the program?

#3 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 07 January 2015 - 09:01 PM

Use this to find what methods can be used with the energy cells.

--#For cells connected to the computer

for a,v in pairs(rs.getSides()) do
  if peripheral.isPresent(v) and peripheral.getType(v) == "cofhenergycell" then
	print(textutils.tabulate(peripheral.getMethods(v)))
  end
end


--#For cells connected by modem

local modem = "modemside" --Change to side of modem
for a,v in pairs(modem.getNamesRemote()) do
  if peripheral.isPresent(v) and peripheral.getType(v) == "cofhenergycell" then
	print(textutils.tabulate(peripheral.getMethods(v)))
  end
end

Edited by Dragon53535, 07 January 2015 - 09:01 PM.


#4 blipman17

  • Members
  • 92 posts

Posted 08 January 2015 - 12:24 AM

I'm currently watching a stream with Fireball1725 and Direwolf20, direwolf has said that his code is buggy.
I presume he will make a better release later.
so, just hold on.

He also said that he releases each version of his code under a different pastebin URL.

#5 luckcolors

  • Members
  • 10 posts

Posted 08 January 2015 - 03:51 PM

Ok thanks guys

View PostDragon53535, on 07 January 2015 - 09:01 PM, said:

Use this to find what methods can be used with the energy cells.

--#For cells connected to the computer

for a,v in pairs(rs.getSides()) do
  if peripheral.isPresent(v) and peripheral.getType(v) == "cofhenergycell" then
	print(textutils.tabulate(peripheral.getMethods(v)))
  end
end


--#For cells connected by modem

local modem = "modemside" --Change to side of modem
for a,v in pairs(modem.getNamesRemote()) do
  if peripheral.isPresent(v) and peripheral.getType(v) == "cofhenergycell" then
	print(textutils.tabulate(peripheral.getMethods(v)))
  end
end
also the first code doesn't print anything it just closes

#6 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 08 January 2015 - 08:39 PM

View Postluckcolors, on 08 January 2015 - 03:51 PM, said:

Ok thanks guys

View PostDragon53535, on 07 January 2015 - 09:01 PM, said:

Use this to find what methods can be used with the energy cells.

--#For cells connected to the computer

for a,v in pairs(rs.getSides()) do
  if peripheral.isPresent(v) and peripheral.getType(v) == "cofhenergycell" then
	print(textutils.tabulate(peripheral.getMethods(v)))
  end
end


--#For cells connected by modem

local modem = "modemside" --Change to side of modem
for a,v in pairs(modem.getNamesRemote()) do
  if peripheral.isPresent(v) and peripheral.getType(v) == "cofhenergycell" then
	print(textutils.tabulate(peripheral.getMethods(v)))
  end
end
also the first code doesn't print anything it just closes
Did you not read the comment? If the energy cell is not connected to the side of the computer, it's not going to do anything, for the second one, what did it print out?

#7 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 08 January 2015 - 10:28 PM

View PostDragon53535, on 07 January 2015 - 09:01 PM, said:

Use this to find what methods can be used with the energy cells.

Psst, why not use peripheral.getNames(), and have the code throw an error if it fails to find the desired peripheral?

It wouldn't surprise me if the block can't even be used as a peripheral in that mod cocktail. Dunno.

#8 luckcolors

  • Members
  • 10 posts

Posted 09 January 2015 - 06:44 PM

View PostDragon53535, on 08 January 2015 - 08:39 PM, said:

View Postluckcolors, on 08 January 2015 - 03:51 PM, said:

Ok thanks guys

View PostDragon53535, on 07 January 2015 - 09:01 PM, said:

Use this to find what methods can be used with the energy cells.

--#For cells connected to the computer

for a,v in pairs(rs.getSides()) do
  if peripheral.isPresent(v) and peripheral.getType(v) == "cofhenergycell" then
	print(textutils.tabulate(peripheral.getMethods(v)))
  end
end


--#For cells connected by modem

local modem = "modemside" --Change to side of modem
for a,v in pairs(modem.getNamesRemote()) do
  if peripheral.isPresent(v) and peripheral.getType(v) == "cofhenergycell" then
	print(textutils.tabulate(peripheral.getMethods(v)))
  end
end
also the first code doesn't print anything it just closes
Did you not read the comment? If the energy cell is not connected to the side of the computer, it's not going to do anything, for the second one, what did it print out?
output of the program modem : test:2 attempt to call nil (yes i changed the side to "up")
so i suppose that this version of thermal doesn't

#9 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 09 January 2015 - 07:39 PM

View Postluckcolors, on 09 January 2015 - 06:44 PM, said:

--snip--
output of the program modem : test:2 attempt to call nil (yes i changed the side to "up")
so i suppose that this version of thermal doesn't
That's an error with my code, let me actually find the part instead of trying to remember.

EDIT: DERP forgot to actually wrap the damn thing, use this code:

local modemside = "modemside" --Change to side of modem
local modem = peripheral.wrap(modemside)
for a,v in pairs(modem.getNamesRemote()) do
  if peripheral.isPresent(v) and peripheral.getType(v) == "cofhenergycell" then
	    print(textutils.tabulate(peripheral.getMethods(v)))
  end
end

Edited by Dragon53535, 09 January 2015 - 07:41 PM.


#10 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 09 January 2015 - 07:59 PM

Well, "up" isn't a valid side, but "top" is.

#11 luckcolors

  • Members
  • 10 posts

Posted 09 January 2015 - 10:29 PM

View PostDragon53535, on 09 January 2015 - 07:39 PM, said:

View Postluckcolors, on 09 January 2015 - 06:44 PM, said:

--snip--
output of the program modem : test:2 attempt to call nil (yes i changed the side to "up")
so i suppose that this version of thermal doesn't
That's an error with my code, let me actually find the part instead of trying to remember.

EDIT: DERP forgot to actually wrap the damn thing, use this code:

local modemside = "modemside" --Change to side of modem
local modem = peripheral.wrap(modemside)
for a,v in pairs(modem.getNamesRemote()) do
  if peripheral.isPresent(v) and peripheral.getType(v) == "cofhenergycell" then
		print(textutils.tabulate(peripheral.getMethods(v)))
  end
end

View PostLyqyd, on 09 January 2015 - 07:59 PM, said:

Well, "up" isn't a valid side, but "top" is.
ok so fixed the side using top and i changed the peripheal variable with cofh_thermalexpansion_energycell (i don't know if changing this did help)
and i figured out that the energycell uses the same method as the capacitor does
but now it prompt a new error : reactor :145 Parameter slot is missing.

Edited by luckcolors, 09 January 2015 - 10:53 PM.


#12 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 10 January 2015 - 12:19 AM

From what i can see, you're calling p.getEnergyStored and i'm not sure if it needs a parameter.

Change line 145 and 146 from this:
   energyStored = p.getEnergyStored()
   energyMax = p.getMaxEnergyStored()
to this:
   energyStored = p.getEnergyStored("unknown")
   energyMax = p.getMaxEnergyStored("unknown")


#13 luckcolors

  • Members
  • 10 posts

Posted 12 January 2015 - 02:13 PM

OK it worked thanks ! :) OK so i made this fix you can check it out here:
function checkEn()
   local tempEnergy = 0
   energyStored = p.getEnergyStored("unknown")
   energyMax = p.getMaxEnergyStored("unknown")
   energyStoredPercent = math.floor((energyStored/energyMax)*100)
   RFProduction = r.getEnergyProducedLastTick()
   fuelUse = r.getFuelConsumedLastTick()
   fuelUse = math.floor(fuelUse*100)
   fuelUse = fuelUse/100
   coreTemp = r.getFuelTemperature()
   reactorOnline = r.getActive()
   tempEnergy = p.getEnergyStored("unknown")
   sleep(0.1)
   energy = (p.getEnergyStored("unknown")-tempEnergy)/2
end
For applying this fix simply change the original check en function to make ut look like i posted above:
And again thanks for helping me :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users