- ComputerCraft | Programmable Computers for Minecraft
- → Rewok's Content
Rewok's Content
There have been 93 items by Rewok (Search limited from 10-February 22)
#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
#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
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.
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.
#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
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
--[[ 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
#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 endSounds about right?
#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 endAnd 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 endThats all I got...
- ComputerCraft | Programmable Computers for Minecraft
- → Rewok's Content



