Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Search the Community

Showing results for tags 'program'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • OpenComputers
    • Announcements
    • Feedback
    • IRC
  • Code Central
    • Support
    • Showcase
    • Tutorials
  • Addons & More
    • Addons Mods
    • Architectures
    • OpenEngineering Task Force
  • General
    • Lounge
    • Forum Games
    • Showcase
    • Servers
  • Archives
    • Public Archives

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Minecraft


GitHub


IRC


Fediverse ID


Location


Interests

Found 16 results

  1. Ok!!! Hello! So... I was going along. Coding more for the OpenComputer RFTools Dialing Program when I found out about DRONES! I immediately went and checked them out, and found out there "Basically the microcontrollers of robots." Witch I was sorta sad that you cant have a hard drive on them and so forth, Plus you only have a limited space in the bios that the drone runs on. Anyway, I wanted to find a way to run all the stuff remotely so the drone wouldn't have to do any of the processing. Like a separate computer would tell the drone what to do over a wireless network, but because I wanted it to work at whatever distance I then just used linked cards. This is the bios I use to run the drone: local d = component.proxy(component.list("drone")()) local t = component.proxy(component.list("tunnel")()) while true do local evt,_,sender,_,_,name,cmd,a,b,c = computer.pullSignal() if evt == "modem_message" and name == d.name() then if cmd == "gst" then t.send(d.name(),"gst",d.getStatusText()) end if cmd == "sst" then t.send(d.name(),"sst",d.setStatusText(a)) end if cmd == "mov" then d.move(a,b,c) end if cmd == "gos" then t.send(d.name(),"gos",d.getOffset()) end if cmd == "gve" then t.send(d.name(),"gv",d.getVelocity()) end if cmd == "gmv" then t.send(d.name(),"gmv",d.getMaxVelocity()) end if cmd == "gac" then t.send(d.name(),"ga",d.getAcceleration()) end if cmd == "sac" then d.setAcceleration(a) end if cmd == "glc" then t.send(d.name(),"glc",d.getLightColor()) end if cmd == "slc" then d.setLightColor(a) end if cmd == "dct" then local b, s = d.detect(a) t.send(d.name(),"dct",b,s) end if cmd == "cmp" then t.send(d.name(),"c",d.compare(a)) end end end LINK TO PASTEBIN: https://pastebin.com/cfgsdmQJ So you would run and create the programs on a separate computer or tablet. This made it much easier for me to code it plus I get to use all my APIs! Here is the start of a drone control program: local t = require("component").tunnel --or modem if thats what you use local event = require("event") function doDrone(dronename,dronecommand,arg1,arg2,arg3) t.send(dronename,dronecommand,arg1,arg2,arg3) _, _, _, _, _, name, command, respond1, respond2 = event.pull("modem_message") return {name, command, respond1, respond2} end doDrone("DAVE","mov",0,3,0) --this would make it move up there blocks! All the commands, like "mov", and what arguments they need, and how they respond are in the drone control bios above! (One above the one above, so like two above) I plan on adding support for all the drop components like navigation and such, Or you could do that yourself!
  2. I created a reddit browser for OC. Here is a video: [LINK] It uses my image encoding alghoritm that makes images draw rather fast on OC. (The actual image encoding is done on a remote server, because doing it in game would be too slow.) Source code for both server and client To get it working in game, download libfif.lua and redditViewer.lua onto a OpenOS installation and just run redditViewer.
  3. Hakz_Studioz

    Help

    I made a microcontroller program that works with computer craft, but it doesn’t work. Please help. The program is in pastebin.com/L2WBivB5 The error is: bad argument #1 (string expected, got nil). Please help! -Hakz Studioz
  4. So... I'm back...you know radars are expensive... that makes radar upgrades for each drone more expensive...which defeats the purpose of having a dispensable army. This is my attempt at fixing this issue: Instead of having each of your drone fly around with equipment worth half of the US military budget, why not have a single radar and a computer to tell the swarm where to buzz around?. Here's the new stuff that you need: a Waypoint block named "yeet" -- or something else if you want, just don't forget to change it in the code Radar block --from computronics a computer-- preferably a server or something that can give you a portable interface to type in your commands atleast a tier 2 drone --for the survivalists note: they run out of power fast if you dont give them the right upgrades tho... thats why I prefer creative cases 1 Navigation upgrade for each drone and the code: this goes into your computer: local component = require("component") local event = require("event") local serialization= require("serialization") local computer= require("computer") local radar = component.radar local modem = component.modem modem.open(2412) modem.broadcast(2412,"n= component.proxy(component.list('navigation')())") modem.broadcast(2412,"d= component.proxy(component.list('drone')())") modem.broadcast(2412,"rbt= component.proxy(component.list(‘robot’)())") modem.broadcast(2412,"function sleep(timeout) checkArg(1, timeout, 'number', 'nil') local deadline = computer.uptime() + (timeout or 0) repeat computer.pullSignal(deadline - computer.uptime()) until computer.uptime() >= deadline end") local function sleep(timeout) checkArg(1, timeout, "number", "nil") local deadline = computer.uptime() + (timeout or 0) repeatcomputer.pullSignal(deadline - computer.uptime()) until computer.uptime() >= deadline end while true do local cmd=io.read() if not cmd then return end if cmd=="BZZ" then print("Target: ") tag=io.read() print("Drone No.: ") srm=io.read() repeat local cmd=select(1,event.pull(1)) for k, v in ipairs(radar.getEntities()) do if v.name==tag then x= v.x y=v.y z=v.z end if v.y>0 then y=v.y+1 end end modem.broadcast(2412,"for k, v in ipairs (n.findWaypoints(100)) do if v.label=='yeet' and d.name()=='"..srm.."' then a=-v.position[1]-'"..x.."'+ math.random(-3,3) math.abs(a) if ( -v.position[1]>"..x..") then a=-a elseif(-v.position[1]<="..x..")then a=math.abs(a) end b=-v.position[2]-'"..y.."'+ math.random(-3,3) math.abs(b) if ( -v.position[2]>"..y..") then b=-b elseif(-v.position[2]<="..y..")then b=math.abs(b) end c=-v.position[3]-'"..z.."'+ math.random(-3,3) math.abs(c) if ( -v.position[3]>"..z..") then c=-c elseif(-v.position[3]<="..z..")then c=math.abs(c) end d.move(a,b,c) end end") print (x,y,z)sleep(0.5) until cmd=="key_down" end if cmd=="SWARM" then print("Target: ") tag=io.read() repeat local cmd=select(1,event.pull(1)) for k, v in ipairs(radar.getEntities()) do if v.name==tag then x= v.x y=v.y z=v.z end if v.y>0 then y=v.y+1 end end modem.broadcast(2412,"for k, v in ipairs (n.findWaypoints(100)) do if v.label=='yeet' then a=-v.position[1]-'"..x.."'+ math.random(-3,3) math.abs(a) if ( -v.position[1]>"..x..") then a=-a elseif(-v.position[1]<="..x..")then a=math.abs(a) end b=-v.position[2]-'"..y.."'+ math.random(-3,3) math.abs(b) if ( -v.position[2]>"..y..") then b=-b elseif(-v.position[2]<="..y..")then b=math.abs(b) end c=-v.position[3]-'"..z.."'+ math.random(-3,3) math.abs(c) if ( -v.position[3]>"..z..") then c=-c elseif(-v.position[3]<="..z..")then c=math.abs(c) end d.move(a,b,c) end end") print (x,y,z)sleep(0.5) until cmd=="key_down" end if cmd=="RETURN" then print("Target: ") tag=io.read() repeat local cmd=select(1,event.pull(1)) for k, v in ipairs(radar.getEntities()) do if v.name==tag then x= v.x y=v.y z=v.z end if v.y>0 then y=v.y+1 end end modem.broadcast(2412,"for k, v in ipairs (n.findWaypoints(100)) do if v.label=='yeet' then a=-v.position[1]-'"..x.."' math.abs(a) if ( -v.position[1]>"..x..") then a=-a elseif(-v.position[1]<="..x..")then a=math.abs(a) end b=-v.position[2]-'"..y.."' math.abs(b) if ( -v.position[2]>"..y..") then b=-b elseif(-v.position[2]<="..y..")then b=math.abs(b) end c=-v.position[3]-'"..z.."' math.abs(c) if ( -v.position[3]>"..z..") then c=-c elseif(-v.position[3]<="..z..")then c=math.abs(c) end d.move(a,b,c) end end") print (x,y,z)sleep(0.5) until cmd=="key_down" end print(select(6, event.pull(3, "modem_message"))) end and for the drone (nothing really changed): local m=component.proxy(component.list("modem")()) local d=component.proxy(component.list("drone")()) d.setLightColor(0x00FFE8) -- the first character 's' of the method should have been in lower case d.setStatusText(d.name()) -- same here... my bad m.open(2412) m.setWakeMessage("RISE") local function respond(...) local args=table.pack(...) pcall(function() m.broadcast(2412, table.unpack(args)) end) end local function receive() while true do local evt,_,_,_,_,cmd=computer.pullSignal() if evt=="modem_message" then return load(cmd) end end end while true do local result,reason=pcall(function() local result,reason=receive() if not result then return respond(reason) end respond(result()) end) if not result then respond(reason) end end Back in the days where everything was simple, like when I made the original code, each drone had a Radar upgrade that tells it where everybody is relative to the drone itself... this had to change... The drones have to rely on a reference point to know where they are in space. With the waypoint block pointed to the radar block the drones can know their relative distance from the radar. (It should work wherever you place it, just have the side with the particle effects touch the radar block) With the radar knowing where entities are in space relative to the itself the computer can tell the drones where an entity is from the radars perspective. With some quick maths the drones know where an entity is relative to themselves.... and thats how science works... COMMANDS SO FAR: BZZ -- call a drone to fly randomly around you or another entity note: energy drains really fast when you let it fly around too long... SWARM -- calls the whole swarm to do the same thing RETURN -- calls the whole swarm to your feet. Much easier than going on a scavenger hunt for your lost drones have F.U.N. PS: the drones should all be powered on before running the program
  5. Hi, are you tired of your mundane minions? do you have a s@$# ton of drones and have no idea what to do with them? are you tired of havi- you know what here's the code for your Drone Army (I don't know what else to say to convince you that this is a program worth playing with): Le client.lua (this goes in your tablet): local component = require("component") local event = require("event") local serialization= require("serialization") local computer= require("computer") local modem = component.modem modem.open(2412) modem.broadcast(2412,"r= component.proxy(component.list('radar')())") modem.broadcast(2412,"n= component.proxy(component.list('navigation')())") modem.broadcast(2412,"d= component.proxy(component.list('drone')())") modem.broadcast(2412,"function sleep(timeout) checkArg(1, timeout, 'number', 'nil') local deadline = computer.uptime() + (timeout or 0) repeat computer.pullSignal(deadline - computer.uptime()) until computer.uptime() >= deadline end") local function sleep(timeout) checkArg(1, timeout, "number", "nil") local deadline = computer.uptime() + (timeout or 0) repeat computer.pullSignal(deadline - computer.uptime()) until computer.uptime() >= deadline end while true do local cmd=io.read() if not cmd then return end if cmd=="ALLFLW" then -- # all follow print("Target: ") tag=io.read() repeat local cmd=select(1,event.pull(1)) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name== '" ..tag.. "' then x= v.x + math.random(-3,3) y=v.y + math.random(-3,3) z=v.z + math.random(-3,3) d.move(x,y,z) end end") sleep(0.5) until cmd=="key_down" end if cmd=="FLW" then -- # specific drone print("Target: ") tag=io.read() print("Drone No.: ") srm=io.read() repeat local cmd=select(1,event.pull(1)) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name== '" ..tag.. "' and d.name()== '"..srm.."' then x= v.x + math.random(-3,3) y=v.y + math.random(-3,3) z=v.z + math.random(-3,3) d.move(x,y,z) end end") sleep(0.5) until cmd=="key_down" end if cmd=="ALLMOV" then --# all move print("x: ") x=io.read() print("y: ") y=io.read() print("z: ") z=io.read() modem.broadcast(2412," d.move("..x..","..y..","..z..")") end if cmd=="MOV" then --# specific drone print("Drone No.: ") srm=io.read() print("x: ") x=io.read() print("y: ") y=io.read() print("z: ") z=io.read() modem.broadcast(2412,"if d.name()== '"..srm.."' then d.move("..x..","..y..","..z..") end") end if cmd=="STK" then -- # stalk print("Target: ") tag=io.read() print("Drone No.: ") srm=io.read() repeat local cmd=select(1,event.pull(1)) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name== '"..tag.. "' and d.name()== '"..srm.."' then x= v.x + 15*((math.random(1,2)*2)-3) y=v.y + 15 z=v.z + 15*((math.random(1,2)*2)-3) d.move(x,y,z) sleep(0.5) end end") until cmd=="key_down" end if cmd=="GOTO" then --# converge at target position print("Target: ") tag=io.read() print("Drone No.: ") srm=io.read() modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name== '" ..tag.. "' and d.name()== '"..srm.. "' then d.move(v.x,v.y,v.z) end end") end if cmd=="ALLGOTO" then -- # all converge at target position print("Target: ") tag=io.read() modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name== '" ..tag.. "' then d.move(v.x,v.y,v.z) end end") end if cmd=="SET8" then --# make 8 drones from swarm converge at target position, used to set up shield and other stuff that I have yet to think about. print("Target: ") tag=io.read() t={1,2,3,4,5,6,7,8,9,10,11,12,13,14} local n = #t while n >= 2 do local k = math.random(n) t[n], t[k] = t[k], t[n] n = n - 1 end modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[1].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[2].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[3].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[4].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[5].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[6].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[7].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[8].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) while true do print("What Is Thy Bidding?") bid=io.read() if bid=="X" then --# use this to adjust drone alignment modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[1].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[2].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[3].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[4].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[5].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[6].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[7].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[8].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) end if bid=="OK" then break end if bid=="PORTAFORT" then--# builds a simple 5X2X5 wall (complete with small entrances/exits) around the set center with any block in the drones inventory slot 1, you need atleast 30 blocks (that's atleast 4 for each drone (technically 2 of them only need 3 blocks but you don't need to bother with that)) modem.broadcast(2412,"if d.name()== '"..t[1].."' then d.move(2,2,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[1].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,-1) sleep(0.00005) d.place(0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then d.move(2,2,-2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,-1) sleep(0.00005) d.place(0) end") sleep(3) modem.broadcast(2412,"if d.name()== '"..t[6].."' then d.move(-2,2,2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[6].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,-1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,1) sleep(0.00005) d.place(0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then d.move(-2,2,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,-1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.place(0) sleep(0.00005) d.move(0,0,1) sleep(0.005) d.place(0) end") sleep(4) modem.broadcast(2412,"if d.name()== '"..t[3].."' then d.move(2,2,2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[3].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(-1,0,0) sleep(0.3) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.move(1,0,0) sleep(0.3) d.place(0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then d.move(-2,2,-2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(1,0,0) sleep(0.3) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.00005) d.move(-1,0,0) sleep(0.3) d.place(0) end") sleep(3) modem.broadcast(2412,"if d.name()== '"..t[7].."' then d.move(0,2,-2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[7].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(1,0,0) sleep(0.2) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.2) d.place(0) sleep(0.00005) d.move(-1,0,0) sleep(0.2) d.place(0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then d.move(0,2,2) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then repeat local dis=select(2, d.detect(0)) d.move(0,-1,0) until dis=='solid' d.move(0,5,0) sleep(0.00005) d.select(1) sleep(0.00005) d.place(0) sleep(0.00005) d.move(-1,0,0) sleep(0.2) d.place(0) sleep(0.00005) d.move(0,1,0) sleep(0.2) d.place(0) sleep(0.00005) d.move(1,0,0) sleep(0.2) d.place(0) end") sleep(0.5) end end end if cmd=="SET9" then --# make 9 drones from swarm converge at target position, used to set up carpet bombing and other stuff that I have yet to think about. print("Target: ") tag=io.read() t={1,2,3,4,5,6,7,8,9,10,11,12,13,14} local n = #t while n >= 2 do local k = math.random(n) t[n], t[k] = t[k], t[n] n = n - 1 end modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[1].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[2].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[3].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[4].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[5].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[6].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[7].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[8].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[9].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) while true do print("What Is Thy Bidding?") bid=io.read() if bid=="X" then --# use this to adjust drone alignment modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[1].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[2].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[3].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[4].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[5].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[6].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[7].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[8].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) modem.broadcast(2412,"for k, v in ipairs(r.getEntities()) do if v.name=='"..tag.."' and d.name()== '"..t[9].."' then d.move(v.x,v.y,v.z) end end") sleep(0.5) end if bid=="OK" then break end if bid=="SETPLANT" then --# have atleast 1 redstone torch at inventory slot 2 and 1 TNT block at slot 3 for each drone... modem.broadcast(2412,"if d.name()=='"..t[1].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[2].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[3].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[4].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[5].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[6].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[7].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[8].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") modem.broadcast(2412,"if d.name()=='"..t[9].."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") end if bid=="MAT" then --#covers a 33X33 area with 9 drones print("N,S,E,W") dir=io.read() if dir=="N" then -- #-Z modem.broadcast(2412,"if d.name()== '"..t[1].."' then d.move(0,0,-20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then d.move(-10,0,-20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[3].."' then d.move(10,0,-20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then d.move(0,0,-30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then d.move(-10,0,-30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[6].."' then d.move(10,0,-30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[7].."' then d.move(0,0,-40) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then d.move(10,0,-40) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[9].."' then d.move(-10,0,-40) end") sleep(0.5) end if dir=="S" then -- #Z modem.broadcast(2412,"if d.name()== '"..t[1].."' then d.move(0,0,20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then d.move(-10,0,20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[3].."' then d.move(10,0,20) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then d.move(0,0,30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then d.move(-10,0,30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[6].."' then d.move(10,0,30) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[7].."' then d.move(0,0,40) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then d.move(10,0,40) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[9].."' then d.move(-10,0,40) end") sleep(0.5) end if dir=="E" then -- #+X modem.broadcast(2412,"if d.name()== '"..t[1].."' then d.move(20,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then d.move(20,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[3].."' then d.move(20,0,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then d.move(30,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then d.move(30,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[6].."' then d.move(30,0,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[7].."' then d.move(40,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then d.move(40,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[9].."' then d.move(40,0,0) end") sleep(0.5) end if dir=="W" then -- #+X modem.broadcast(2412,"if d.name()== '"..t[1].."' then d.move(-20,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[2].."' then d.move(-20,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[3].."' then d.move(-20,0,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[4].."' then d.move(-30,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[5].."' then d.move(-30,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[6].."' then d.move(-30,0,0) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[7].."' then d.move(-40,0,-10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[8].."' then d.move(-40,0,10) end") sleep(0.5) modem.broadcast(2412,"if d.name()== '"..t[9].."' then d.move(-40,0,0) end") sleep(0.5) end end end end if cmd=="PLANT" then --# have atleast 1 redstone torch at inventory slot 2 and 1 TNT block at slot 3... print("Drone No.: ") srm=io.read() modem.broadcast(2412,"if d.name()=='"..srm.."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") end if cmd=="BUNKERBUST" then --# yeah, you need more redstone torches and TNT... print("Drone No.: ") srm=io.read() repeat local cmd= select(1,event.pull(3)) modem.broadcast(2412,"if d.name()=='"..srm.."' then while select(2,d.detect(0))=='air' do local dis=select(2,d.detect(0)) d.move(0,-1,0) sleep(0.00005) if dis~='air' then break end end sleep(0.5) if select(2,d.detect(0))=='solid' then d.move(0,1,0) d.select(2) d.place(0) d.select(3) d.place(0) d.select(1) end end") sleep(0.5) until cmd=="key_down" end if cmd=="HUSH" then--# kill command modem.broadcast(2412," computer.shutdown()") end if cmd=="RISE" then --# wake message, you need to restart client after using this command modem.broadcast(2412,"RISE") end print(select(6, event.pull(3, "modem_message"))) end Le BRAIN.lua (this goes in the drone) local m=component.proxy(component.list("modem")()) local d=component.proxy(component.list("drone")()) d.setLightColor(0x00FFE8) -- Edit the first character of the method should have been in lowercase d.setStatusText(d.name()) -- Same here my B m.open(2412) m.setWakeMessage("RISE") local function respond(...) local args=table.pack(...) pcall(function() m.broadcast(2412, table.unpack(args)) end) end local function receive() while true do local evt,_,_,_,_,cmd=computer.pullSignal() if evt=="modem_message" then return load(cmd) end end end while true do local result,reason=pcall(function() local result,reason=receive() if not result then return respond(reason) end respond(result()) end) if not result then respond(reason) end end here you'll also need these to work with: atleast 64 TNT blocks atleast 64 redstone torches atleast 64 building materials (blocks preferably) Creative drone Case (sorry survivalists, I couldn't find a way to put it all in a T2 case ) Computronics 1.6.6 for 1.12.2 Radar upgrade heres: a link to the add-on:https://files.vexatos.com/?dir=Computronics/dev (ps: you need to go into the computronics config file and set the radar range to atleast 50 blocks and set it to return coordinates to true) 5X T3 Battery upgrade (or you can use less if you use more solar upgrades) Inventory upgrade Inventory controller upgrade T3 CPU 2X T3.5 Memory wireless network card (you'll need atleast 14 of these drones named from '1' to '14' ) and a creative tablet (might as well... or if your upto it, you can use a regular tablet) oh yeah I almost forgot: some of the commands: FLW-- # call a specific drone to follow (randomly flys about) ALLFLW-- # all follow ( they all randomly fly about) MOV-- # call a specific drone to move ALLMOV-- # all move GOTO-- # call a specific drone to converge at a target ALLGOTO--# all will converge at target STK-- # call a specific drone to stalk a target (its default is to follow a target 15 blocks above) PLANT--# have atleast 1 redstone torch at inventory slot 2 and 1 TNT block at slot 3... BUNKERBUST --# does the samething as PLANT but throws it in a loop yeah, you need more redstone torches and TNT... HUSH --# kill command RISE--# wake message (you need to restart client after using this command) ---for the following type in 'X' to re-center drones and 'OK' to break out of 'SET' (you'll know what I mean )--- SET8--# make 8 drones from swarm converge at target position, used to set up fort and other stuff that I have yet to think about. PORTAFORT--# builds a simple 5X2X5 wall (complete with small entrances/exits) around the set center with any block in the drones inventory slot 1, you need atleast 30 blocks (that's atleast 4 for each drone (technically 2 of them only need 3 blocks but you don't need to bother with that)) SET9--# make 9 drones from swarm converge at target position, used to set up carpet bombing and other stuff that I have yet to think about. MAT --#covers a 33X33 area with 9 drones SETPLANT--# have atleast 1 redstone torch at inventory slot 2 and 1 TNT block at slot 3 for each drone... have fun causing Havoc and chaos and this might be the first and last time I write a program for opencomputers... Byeeeee
  6. Hello, (I don't speak english very well, sorry in advance for errors) I need a program to controll an iron with the in-game time. But i d'ont know how to ask to the computer the in-game time, someone can build a simple program to turn on redstone signal at 6AM, and turn it off at 8PM ? I need the program will be easy to understand, and esay ton configure, annotations are good for this Thank you in advance, bye !
  7. Railgun1

    Drone Dog sitting

    Hello everyone ! I would like a program that could allow a drone to walk my dog autonomously around a building for example, but i not being good at coding on opencomputer, I ask your help Thanks you for you help ^^ i wait you ^^
  8. Ok!!! Hello! So... I was going along. Coding more for the OpenComputer RFTools Dialing Program when I found out about DRONES! I immediately went and checked them out, and found out there "Basically the microcontrollers of robots." Witch I was sorta sad that you cant have a hard drive on them and so forth, Plus you only have a limited space in the bios that the drone runs on. Anyway, I wanted to find a way to run all the stuff remotely so the drone wouldn't have to do any of the processing. Like a separate computer would tell the drone what to do over a wireless network, but because I wanted it to work at whatever distance I then just used linked cards. This is the bios I use to run the drone: local d = component.proxy(component.list("drone")()) local t = component.proxy(component.list("tunnel")()) while true do local evt,_,sender,_,_,name,cmd,a,b,c = computer.pullSignal() if evt == "modem_message" and name == d.name() then if cmd == "gst" then t.send(d.name(),"gst",d.getStatusText()) end if cmd == "sst" then t.send(d.name(),"sst",d.setStatusText(a)) end if cmd == "mov" then d.move(a,b,c) end if cmd == "gos" then t.send(d.name(),"gos",d.getOffset()) end if cmd == "gve" then t.send(d.name(),"gv",d.getVelocity()) end if cmd == "gmv" then t.send(d.name(),"gmv",d.getMaxVelocity()) end if cmd == "gac" then t.send(d.name(),"ga",d.getAcceleration()) end if cmd == "sac" then d.setAcceleration(a) end if cmd == "glc" then t.send(d.name(),"glc",d.getLightColor()) end if cmd == "slc" then d.setLightColor(a) end if cmd == "dct" then local b, s = d.detect(a) t.send(d.name(),"dct",b,s) end if cmd == "cmp" then t.send(d.name(),"c",d.compare(a)) end end end LINK TO PASTEBIN: https://pastebin.com/cfgsdmQJ So you would run and create the programs on a separate computer or tablet. This made it much easier for me to code it plus I get to use all my APIs! Here is the start of a drone control program: local t = require("component").tunnel --or modem if thats what you use local event = require("event") function doDrone(dronename,dronecommand,arg1,arg2,arg3) t.send(dronename,dronecommand,arg1,arg2,arg3) _, _, _, _, _, name, command, respond1, respond2 = event.pull("modem_message") return {name, command, respond1, respond2} end doDrone("DAVE","mov",0,3,0) --this would make it move up there blocks! All the commands, like "mov", and what arguments they need, and how they respond are in the drone control bios above! (One above the one above, so like two above) I plan on adding support for all the drop components like navigation and such, Or you could do that yourself!
  9. Heavy Cat

    component help

    im making a program, but commands that work in the lua interpreter dont inside a custom program. how do i fix this?
  10. I'm working on a small bit of code that reads from a IC2 power storage block and displays it's current and maximum storage. I also want it to toggle a Reactor based on either a keypress or a CLI menu option. As the code has to refresh a LOT, I think a keypress option is the easiest way, but I can't, for the life of me, figure it out. Here's what I have so far... os.execute("cls") -- Hook the component local component = require("component") local term = require("term") local side = require("sides") local keyboard = require("keyboard") local event = require("event") local rs = component.redstone local batbox = component.cesu local board = component.keyboard function toggleBox() if rs.getOutput(side.top) == 18 then rs.setOutput(side.top, 0) else rs.setOutput(side.top, 18) end end local function keyCheck() while true do e = event.pull(1, "key_up") if e == "enter" then toggleBox() elseif e == "back" then running = false end end end keyChecker = coroutine.create(keyCheck) function main() running = true while true do -- Get the tank information, results are in table format local tInfo = batbox local cap = tonumber(batbox.getCapacity()) local fill = tonumber(batbox.getStored()) -- Output as you want... a very simple way: print("CESU Power Levels and Controls") print("Energy Stored : "..fill) print("CESU Capacity : "..cap) print("\n Press Enter to toggle reactor.") print("Press Back to return to OpenOS.") term.setCursor(1,1) end end main() And yes, I now see the redundancy of having "cls" there, when I have 'term.setCursor(1,1)' there... What is it that I am missing?
  11. I need to run a program on a robot using os.execute or similar and then collect a return value (a slot number). I've tried the 'return' keyword but the program just spits out the normal "true" saying the program ran, but nothing else. The code I have now is: #component declarations and requires statements for robot and inventory controller lookingFor = args[1] for i=1,robot.inventorySize()do robot.select(i) item = invcon.getStackInInternalSlot() if item ~= nil then itemName = item['label'] end if lookingFor == itemName then return i end end return 0 Anyone know if this is possible, and if so how to do it?
  12. This is the program. local component = require("component") local sensor = component.motion_sensor local sides = require("sides") local io = require("io") local term = require("term") local event = require("event") sensor.setSensitivity(0.2) local range=1 ------ Functions ----- function close() local rs1 = component.proxy("bebe4c8f-a23e-4e7a-baec-be0124a0b598") rs1.setOutput(sides.right,0) os.sleep(1) for address in component.list("redstone",true) do local rs = component.proxy(address) rs.setOutput(sides.top,15) end end function open() for address in component.list("redstone",true) do local rs = component.proxy(address) rs.setOutput(sides.top,0) end os.sleep(1) local rs1 = component.proxy("bebe4c8f-a23e-4e7a-baec-be0124a0b598") rs1.setOutput(sides.right,15) end function openMan() open() print("Closing it in 8 seconds") os.sleep(8) close() end function detect() print("Detecting...") while true do local _,_,x,y,z,name=event.pull("motion") if math.abs(x)<=tonumber(range) and math.abs(y)<=tonumber(range) and math.abs(z)<=tonumber(range) then if name == "AetherEus" then open() print("Detected:",name) print("Closing the staircase in 10 seconds") os.sleep(10) close() return false end end end end close() ---- end ---- ---- Menu ---- if component.isAvailable("motion_sensor") then repeat print("Aileen:Program Started. What do I do now?") print("1.Open the staircase.\n2.Star detection mode.\n3.Close the staircase.\n4.Close the program.") local inst=io.read("*n") if inst==1 then term.clear() print("Aileen: Opening.") openMan() os.sleep(1) detect() end if inst==2 then term.clear() print("Aileen: Starting detection mode.") detect() end if inst==4 then term.clear() print("Aileen: Closing the program.") term.clear() end if inst==3 then term.clear() print("Aileen: Closing the staircase.") close() end until inst == 4 else print("Plug in the motion sensor!!!") end return 0 It's simple it activates or deactivates a redstone machanism that opens up a path to a staircase. The two things I want to fix or add is 1. A way to manually cancel the detecting process. 2.Fix that the motion sensor takes to long to detect or I need to jump a lo to make it work.
  13. I love the tape drive and .dfpwm system that comes with Computronics, however, how could you make it portable like an iPod? I've been contemplating this for a while, anyone else have an idea?
  14. In computercraft there is this command: shell.getRunningProgram() This command returns the path and filename of the program that executed it. I wonder if there's a command in OpenComputers that does the same
  15. I decided to write two programs. One to broadcast whatever you type and another to receive broadcasts. The one that broadcasts, works perfectly. But the receiving one doesn't. It gets the broadcasts, but doesn't display the how I want. Instead of saying a whole broadcast, it says "modem_message" and the code is shown below. component = require("component") event = require("event") print("Pulling broadcasts from port 25565") while true do os.sleep(.5) --To make sure it doesn't repeat single messages component.modem.open(25565) x = event.pull("modem") --Doing it like this =event.pull("modem") brings errors print(x) end Any solution?
  16. Wanted a good subject to learn more about OpenComputer programming, this definitely worked. CompressCobble Uses a minimal Robot to continually compress Cobblestone, up to Octouple Compressed Cobblestone. Uses about 83 cobblestone per second, or 7.2 million per day. (If you want more, put four Robots around a Charger, each with its own cobblegen.) Stores over 225 Octouple Compressed Cobblestone internally before quitting. May optionally be put in chest above Robot for extend run time. Cheap in power, up to 3 RF per tick. A couple of Solar Panel Upgrades may be enough. You can use a Generator Upgrade as well. Checks to see if needed components are available and will list any problems. Can be run on a 'headless' (no screen, graphics card or keyboard) Robot to save on resources. Enough compressed cobblestone for a Deep Dark Portal or Bedrockium Drum in much less then a day. Minimum Robot Required: Tier 1 Computer Case Tier 1 CPU Tier 1.5 Memory Tier 1 Hard Drive with OpenOS installed (suggest adding this at the same time) 2 Chest Upgrades: Tier 1 robot needs a Tier 1 Upgrade Container Crafting Upgrade: Tier 1 robot needs a Tier 2 Upgrade Container Some way to keep it powered, I suggest a Charger DOWNLOAD: Link to Dropbox Folder, v1.5 as of 23 March 2015. Thanks to Sangar for help with getting events working! Edit: Almost forgot 'no pics, no clicks'!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.