Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --client
- component = require('component')
- event = require('event')
- robot = require('robot')
- computer = require('computer')
- serialization = require('serialization')
- shell = require("shell")
- red = component.redstone
- internet = component.tunnel
- inv = component.inventory_controller
- event.shouldInterrupt = function() return false end
- c={
- up=function(X)
- return fix(robot.up,X)
- end,
- down=function(X)
- return fix(robot.down,X)
- end,
- go=function(X)
- return fix(robot.forward,X)
- end,
- back=function(X)
- return fix(robot.back,X)
- end,
- left=function(X)
- return fix(robot.turnLeft,X)
- end,
- right=function(X)
- return fix(robot.turnRight,X)
- end,
- power=function()
- return (computer.energy()/computer.maxEnergy()*100).."% power"
- end,
- suck=function(X)
- local out=false
- for i=1,inv.getInventorySize(3) do
- out=robot.suck()
- end
- return out
- end,
- drop=function(X)
- for i=1,robot.inventorySize() do
- robot.select(i)
- robot.drop()
- end
- return true
- end,
- inf=function(X)
- local out=""
- for i=16*X-15,16*X do
- local item=inv.getStackInInternalSlot(i)
- if item then out=out..i..":"..item.label.."|"..item.size.."\n" end
- end
- return out
- end,
- use=function(X)
- return fix(robot.use,X)
- end,
- dig=function(X)
- return fix(robot.swing,X)
- end,
- }
- function smallfix(func)
- local J=0
- while J~=20 do
- J=J+1
- local a=func()
- if a then return true end
- end
- return false
- end
- function fix(func,arg)
- local out
- for i=1,arg do
- out=smallfix(func)
- if not out then break end
- end
- return out
- end
- function set_msg(msg)
- internet.send(msg)
- end
- function loop()
- local _,_,_,_,_,msg=event.pull("modem_message")
- print("s:"..msg)
- local msg,mult=string.match(msg,"(%a+)"),tonumber(string.match(msg,"(%d+)")) or 1
- if c[msg] then
- local nmsg=tostring(c[msg](mult))
- print("c:"..nmsg)
- set_msg(nmsg)
- else
- print("команда не найдена")
- set_msg("команда не найдена")
- end
- end
- function errorhandler(b)
- set_msg("c:ERROR: "..b)
- print("c:ERROR "..b)
- end
- while true do
- a,b=xpcall(loop)
- if not a then errorhandler(b) end --защита от дураков.
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement