Jump to content


Rewok's Content

There have been 93 items by Rewok (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#199683 Tank Monitor code

Posted by Rewok on 30 November 2014 - 02:21 PM in Ask a Pro

I have no idea what you wrote...



#199643 Basic turbine computer port to redstone port adaptor 1.0

Posted by Rewok on 29 November 2014 - 11:46 PM in Programs

Basic turbine computer port to redstone port adaptor 1.0


Heya everyone.

As you may know, Big reactors turbines do not have a redstone port as of right now. This code is an easy work around using a computer port instead. It's notjing fancy put it gets the job done.

Features:
-Adaptabillity with wired modems

--Basic side determintation for wrapping
function getDeviceSide(deviceType)
  deviceType = deviceType:lower()

  for i, side in pairs(rs.getSides()) do
    if (peripheral.isPresent(side)) then
	  if (string.lower(peripheral.getType(side)) == deviceType) then
	    return side;
	   end
	  end
	 end
	
	 return nil;
    end
  
--Peripheral wrapping
function wrapThis(thing, f)
  local wrapped = nil
  while wrapped == nil and f <= 100 do
    wrapped = peripheral.wrap(thing.."_"..f)
    f = f + 1
   end
  
   if wrapped == nil then
   side = getDeviceSide(thing)
   if side ~= nil then
	 return peripheral.wrap(side)
	 else
	 return nil
	 end
    else
	  return wrapped
    end
   end

--Finding turbine
local turbine = wrapThis("BigReactors-Turbine", 0)
  if turbine == nil then
    sleep(5)
    finished = true
    os.reboot()
end

--Redstone emitor
while true do
if turbine.getActive() then
rs.setOutput("right", true)
else
rs.setOutput("right", false)
end
sleep(5)
end



#197930 Tank Monitor code

Posted by Rewok on 08 November 2014 - 09:36 PM in Ask a Pro

View PostDustmuz, on 08 November 2014 - 07:41 PM, said:

im using 1.7.10 of MC atm. and as Dog is saying.. OpenP doesnt support much yet..

im atm also coding a tank monitor combined with a power control / monitor
so will keep an eye in this thread.

Sure, the more coders, the more game breaking



#197919 Tank Monitor code

Posted by Rewok on 08 November 2014 - 05:55 PM in Ask a Pro

I tried editing this. For the moment I don't have computer craft. Could you see if this seems good?

I put --Edited where I started to edit and --Edit finish where I finished to edit

--[[ Tank Monitor ]]--
local fluidTank -- tank
local mon		  -- monitor
for _,side in pairs(rs.getSides()) do												    -- this calls redstone.getSides() to look at each side of the computer
  if peripheral.isPresent(side) then													  -- if we find a perhiperal, we then try to identify if it's one of the peripherals we're looking for...
    if peripheral.getType(side) == "monitor" then							    -- if we find a monitor...
		  mon = peripheral.wrap(side)														    -- ...we wrap it
    elseif peripheral.getType(side) == "openblocks_tank" then    -- if we find an openblocks tank...
		  fluidTank = peripheral.wrap(side)											    -- ...wrap it
    elseif peripheral.getType(side) == "rcirontankvalvetile" then -- if we find a railcraft iron tank...
		  fluidTank = peripheral.wrap(side)											    -- ...wrap it
    elseif peripheral.getType(side) == "net_minecraft_src_buildcraft_factory_tiletank" then -- if we find a buildcraft tank...
		  fluidTank = peripheral.wrap(side)											    -- ...wrap it
    elseif  peripheral.getType(side) == "modem" then					  -- if we find a modem, we...
		  if not peripheral.call(side,"isWireless") then						  -- ...eliminate wireless modems and...
		    for _,device in pairs(peripheral.call(side,"getNamesRemote")) do -- ...look for network attached peripherals
				  if string.sub(device,1,15) == "openblocks_tank" or string.sub(device,1,19) == "rcirontankvalvetile" or string.sub(device,1,45) == "net_minecraft_src_buildcraft_factory_tiletank" then -- if we find a tank...
				    fluidTank = peripheral.wrap(device)						    -- ...wrap it
   if true then --Edited
    x = yes
   elseif false then
    x = no --Edit finish
				  elseif string.sub(device,1,7) == "monitor" then			    -- if we find a monitor...
				    mon = peripheral.wrap(device)											    -- ...wrap it
				  end
		    end
		  end
    end
  end
end
mon.setTextScale(2) -- valid text scales are 0.5, 1, 2, 3, 4, 5
mon.clear()
mon.setCursorPos(1,1)
if x == yes then --Edited
mon.write("Tank 1:")
elseif x == no then
mon.write("No tanks found") --Edit finish
repeat																							  -- do the following repeatedly until we match the 'until' parameter
  local tankInfo = fluidTank.getTankInfo("unknown")	    -- get tank's info
  local tankStats = tankInfo[1]										    -- take just the table of info we want from the info returned by the tank
  local yPos = 2																				  -- set cursor Y position variable
  for k,v in pairs(tankStats) do												  -- start parsing the tank's information table
    mon.setCursorPos(1,yPos)													  -- set cursor position
    mon.write(tostring(k) .. ": " .. tostring(v) .. "  ") -- display key and value information for tank
    yPos = yPos + 1																	    -- increment cursor Y position variable
  end
  sleep(1)																						  -- sleep for 1 second before refreshing the tank info
until yPos == 1000																		  -- if our cursor Y position variable ever == 1000 we end



#197916 Tank Monitor code

Posted by Rewok on 08 November 2014 - 05:04 PM in Ask a Pro

I see, for the moment I've tried using the code in the newly updated 1.7.10 Direwolf pack. I'll be going back to the 1.6.4 packs so that when it mod is fully updated, it will work. Alright?

Edit: Also I'm plaining on trying to edit the code so that it will only say "Tank 1" when it finds one and "No tanks found" if it didn't find one.



#197854 Tank Monitor code

Posted by Rewok on 08 November 2014 - 12:07 AM in Ask a Pro

Alright Thanks, I am currently using the newly updated direwolf20 pack which uses unstable mods(I think). Right now it's 1.7.10



#197850 Tank Monitor code

Posted by Rewok on 07 November 2014 - 11:34 PM in Ask a Pro

Just 1.6



#197846 Tank Monitor code

Posted by Rewok on 07 November 2014 - 11:14 PM in Ask a Pro

1.6



#197838 Tank Monitor code

Posted by Rewok on 07 November 2014 - 10:03 PM in Ask a Pro

For the moment I'm using:

Computer Craft: 1.6

Open Peripheral Core: 0.5.0

Open Peripheral Addons: 0.2.0

A tank from Buildcraft 6.1.3



#197828 Tank Monitor code

Posted by Rewok on 07 November 2014 - 08:27 PM in Ask a Pro

Alright, Let's get back into this

--[[ Tank Monitor ]]--
local fluidTank -- tank
local mon	   -- monitor
for _,side in pairs(rs.getSides()) do							 -- this calls redstone.getSides() to look at each side of the computer
  if peripheral.isPresent(side) then							  -- if we find a perhiperal, we then try to identify if it's one of the peripherals we're looking for...
    if peripheral.getType(side) == "monitor" then				 -- if we find a monitor...
	  mon = peripheral.wrap(side)								 -- ...we wrap it
    elseif peripheral.getType(side) == "openblocks_tank" then	 -- if we find an openblocks tank...
	  fluidTank = peripheral.wrap(side)						   -- ...wrap it
    elseif peripheral.getType(side) == "rcirontankvalvetile" then -- if we find a railcraft iron tank...
	  fluidTank = peripheral.wrap(side)						   -- ...wrap it
    elseif peripheral.getType(side) == "net_minecraft_src_buildcraft_factory_tiletank" then -- if we find a buildcraft tank...
	  fluidTank = peripheral.wrap(side)						   -- ...wrap it
    elseif  peripheral.getType(side) == "modem" then			  -- if we find a modem, we...
	  if not peripheral.call(side,"isWireless") then			  -- ...eliminate wireless modems and...
	    for _,device in pairs(peripheral.call(side,"getNamesRemote")) do -- ...look for network attached peripherals
		  if string.sub(device,1,15) == "openblocks_tank" or string.sub(device,1,19) == "rcirontankvalvetile" or string.sub(device,1,45) == "net_minecraft_src_buildcraft_factory_tiletank" then -- if we find a tank...
		    fluidTank = peripheral.wrap(device)				   -- ...wrap it
		  elseif string.sub(device,1,7) == "monitor" then		 -- if we find a monitor...
		    mon = peripheral.wrap(device)						 -- ...wrap it
		  end
	    end
	  end
    end
  end
end
mon.setTextScale(2) -- valid text scales are 0.5, 1, 2, 3, 4, 5
mon.clear()
mon.setCursorPos(1,1)
mon.write("Tank 1:")
repeat												    -- do the following repeatedly until we match the 'until' parameter
  local tankInfo = fluidTank.getTankInfo("unknown")	   -- get tank's info
  local tankStats = tankInfo[1]						   -- take just the table of info we want from the info returned by the tank
  local yPos = 2										  -- set cursor Y position variable
  for k,v in pairs(tankStats) do						  -- start parsing the tank's information table
    mon.setCursorPos(1,yPos)							  -- set cursor position
    mon.write(tostring(k) .. ": " .. tostring(v) .. "  ") -- display key and value information for tank
    yPos = yPos + 1									   -- increment cursor Y position variable
  end
  sleep(1)											    -- sleep for 1 second before refreshing the tank info
until yPos == 1000									    -- if our cursor Y position variable ever == 1000 we end

So as you said, Let's use this as a base. There seems to be an "Atempt to call nil" Issue at line 32 though



#185250 Help with disk to disk copying.

Posted by Rewok on 23 June 2014 - 01:49 PM in Ask a Pro

What happened is that the file exists but whey I do cd disk> talk it says there exists no file with that name



#185246 Help with disk to disk copying.

Posted by Rewok on 23 June 2014 - 01:29 PM in Ask a Pro

I don't think that worked...



#185236 Help with disk to disk copying.

Posted by Rewok on 23 June 2014 - 12:01 PM in Ask a Pro

First. I'm trying to copy from a treasure disk to a blank disk.
Second I did: cd disk>copy



#185164 Help with disk to disk copying.

Posted by Rewok on 22 June 2014 - 09:20 PM in Ask a Pro

Hey.
I'm having a problem copying the program "Talk" from a floppy disk to another,
I'm getting the error: 13: Access denied,
Is there anyway to fix this?
Thanks
-Zatilla7



#178287 Tank Monitor code

Posted by Rewok on 13 May 2014 - 03:06 PM in Ask a Pro

And I'm back. Sorry I had alot of tests to do and had to study



#176353 Tank Monitor code

Posted by Rewok on 02 May 2014 - 09:57 PM in Ask a Pro

Good night



#176348 Tank Monitor code

Posted by Rewok on 02 May 2014 - 09:48 PM in Ask a Pro

I will do that tomorrow

I need to sleep



#176342 Tank Monitor code

Posted by Rewok on 02 May 2014 - 09:30 PM in Ask a Pro

I have no idea what you mean



#176337 Tank Monitor code

Posted by Rewok on 02 May 2014 - 08:33 PM in Ask a Pro

Well that explains it

Alright so shall we finish the code?



#176327 Tank Monitor code

Posted by Rewok on 02 May 2014 - 07:25 PM in Ask a Pro

Well the only thing really is how sub string works



#176254 Tank Monitor code

Posted by Rewok on 02 May 2014 - 11:21 AM in Ask a Pro

for i = 1, #validTanks do																			   -- first we look for tanks (we re-use 'i' since we're done with it above)
  if validTanks[i] == string.sub(device,1,#validTanks[i] ) then -- if we find a tank that is in the validTanks table...
	    fluidTank = peripheral.wrap(device)					    -- ...we wrap it
  end
end
Sounds about right?



#176181 Tank Monitor code

Posted by Rewok on 01 May 2014 - 10:52 PM in Ask a Pro

string.sub(#validTanks,1,[size=4]7)[/size]
Like that?



#176178 Tank Monitor code

Posted by Rewok on 01 May 2014 - 10:46 PM in Ask a Pro

string.sub(<#validTanks>,<1>,<#validTanks>)
No idea what I did there



#176154 Tank Monitor code

Posted by Rewok on 01 May 2014 - 08:20 PM in Ask a Pro

for i = 1,#thisTable do  -- we start our loop by counting from 1 (since 1 is the lowest entry number in Lua tables) - we use 'i' for our counting variable (our 'index')
  if thisTable[i] == side**what we are looking for** then  -- if table entry 'i' == **what we are looking for** then
	    fluidTank = peripheral.wrap(side)  -- do what we need to do
  end
end
And the code to be removed...
    elseif peripheral.getType(side) == "openblocks_tank" then	 -- if we find an openblocks tank...
	  fluidTank = peripheral.wrap(side)						   -- ...wrap it
    elseif peripheral.getType(side) == "rcirontankvalvetile" then -- if we find a railcraft iron tank...
	  fluidTank = peripheral.wrap(side)						   -- ...wrap it
    elseif peripheral.getType(side) == "net_minecraft_src_buildcraft_factory_tiletank" then -- if we find a buildcraft tank...
	  fluidTank = peripheral.wrap(side)						   -- ...wrap it
 
About right?



#176069 Tank Monitor code

Posted by Rewok on 01 May 2014 - 11:36 AM in Ask a Pro

for i = 1,#thisTable do  -- we start our loop by counting from 1 (since 1 is the lowest entry number in Lua tables) - we use 'i' for our counting variable (our 'index')
  if thisTable[i] == **what we are looking for** then  -- if table entry 'i' == **what we are looking for** then
	fluidTank = peripheral.wrap(side)  -- do what we need to do
  end
end
Thats all I got...