Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Wireless Reading Turtle Smeltery Automation (CLIENT)
- programName="smelt"
- programVersion="1.0"
- protocol="ST0"
- hostname="SmeltingTurtle"
- oreName=""
- oreAmount="588"
- args = {...}
- function FindPeripheral(p)
- pFound = false
- side = ""
- local pList = peripheral.getNames()
- for i = 1, #pList do
- if peripheral.getType(pList[i]) == p then
- pFound = true
- side = pList[i]
- end
- end
- if pFound then
- return side
- else
- return false
- end
- end
- if FindPeripheral("modem") == false then
- print("Modem not Found")
- return
- else
- modemSide = FindPeripheral("modem")
- end
- rednet.open(modemSide)
- turtleid = rednet.lookup(protocol,hostname)
- -- Check if turtle is active
- if turtleid then
- -- Continue
- else
- print("Turtle Not Found.")
- return
- end
- -- Check for Arguments
- if args[1] then
- oreName = args[1]
- if args[2] then
- if tonumber(args[2]) > 1024 then
- args[2] = 1024
- end
- oreAmount = tonumber(args[2])
- else
- -- oreAmount stays the same.
- end
- print("Telling Turtle to smelt "..oreAmount.." of "..oreName)
- else
- print("Usage: "..programName.." (ore name) [ore amount]")
- return
- end
- --Sending messages to Turtle.
- rednet.send(turtleid, oreName, protocol)
- rednet.send(turtleid, oreAmount, protocol)
- --Awaiting Response.
- id2, response = rednet.receive(protocol)
- if response == "NO_ORE" then
- print("Ore not found.")
- return
- elseif response == "SUCCESS" then
- id3, amountDone = rednet.receive(protocol)
- print("Successfully smelted "..amountDone.." "..oreName)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement