- ComputerCraft | Programmable Computers for Minecraft
- → MayContainVennom's Content
MayContainVennom's Content
There have been 23 items by MayContainVennom (Search limited from 29-March 23)
#190592 [CC Latest] MoarPeripherals
Posted by MayContainVennom on 10 August 2014 - 07:31 PM in Peripherals and Turtle Upgrades
I've attempted to install this on the recommended version of Direwolf pack, the first problem was an id conflict but we got that sorted straight away. after that it loaded fine but when we started to want to use them they were not returning anything, rightclicking on a computer with a keyboard would cause you to be kicked from the server with internal error as the problem. Also breaking the chatBox dosn't give back an item
#190311 It should work
Posted by MayContainVennom on 06 August 2014 - 11:22 AM in Ask a Pro
wieselkatze, on 06 August 2014 - 11:10 AM, said:
c = peripheral.wrap("container_chest_3") file = items redN = colors.brown -- Rednet On colour redNO = colors.black -- Rednet Off colour EnderC = colors.orange -- Colour left on Enderchest when counting redNS = "right" -- Rednet cable side redNE = colors.orange itemFile = {} function getItems() local items = c.getAllStacks() for k, v in pairs(items) do itemFile[v.name] = itemFile[v.name] and itemFile[v.name] + v.qty or v.qty end end function writeFile(line) local diskFile = fs.open("disk/items","w") for k, v in pairs(itemFile) do diskFile.write(k.." x "..v.."\n") end diskFile:close() end while true do print("Setting EnderChest") redstone.setBundledOutput(redNS,redN) print("Tranfering Items") sleep(1) redstone.setBundledOutput(redNS,redNO) getItems() writeFile() print("Written to file") redstone.setBundledOutput(redNS,redNE) sleep(1) redstone.setBundledOutput(redNS,redNO) print("item's sent to the ME") end
Much shorter and does the job.
So now no item should be duplicated etc..
Let me know if something still doesn't behave like it should
Seems to be working! Thanks a lot man.
#190308 It should work
Posted by MayContainVennom on 06 August 2014 - 10:35 AM in Ask a Pro
#190273 It should work
Posted by MayContainVennom on 06 August 2014 - 02:37 AM in Ask a Pro
#190271 It should work
Posted by MayContainVennom on 06 August 2014 - 02:31 AM in Ask a Pro
#190269 It should work
Posted by MayContainVennom on 06 August 2014 - 02:26 AM in Ask a Pro
Neywiny, on 06 August 2014 - 02:20 AM, said:
side note-is that the faithful texture pack?
Yes it is faithful. We ran some prints for debugging (Some of them are still in there) and the code is working completly fine. The problem being is that instead of overriding the line in the array it is creating another. For example If I put in 1 Steak on the first cycle and 2 on the second it would display it as:
3 X Steak 1 X Steak
When it should be:
3 X Steak
All of the arrays are cleared at the right time and as far as I can tell, we are adding the items correctly if it is already in the array.
#190266 It should work
Posted by MayContainVennom on 06 August 2014 - 01:10 AM in Ask a Pro
So I started this project that will enable me to get a listing of the items that pass through my spawner adding it to a text file which can later be reviewed online (Apache virtual host pointing to the file) or using monitors in game. I wrote the code along with a friend of mine and we got it working on a 2 dimensional array. Everything seems to be working but the fact that every time it Adds an item to the array that is already there it adds a new line for it. We have looked through the code and cannot see a reason for this to be happening. So I have come to you
The items enter the chest on the right from the spawner. After the system resets the Itemducts are activated using a rednet cable (Brown) after pulling for 10 seconds the computer changes it's output to black then proceeds to index the items that are in the chest in front of it (Using open peripherals). After indexing it rights to the file then activates Orange allowing the items to flow into the enderchest then starts over again.
c = peripheral.wrap("container_chest_3") file = items redN = colors.brown -- Rednet On colour redNO = colors.black -- Rednet Off colour EnderC = colors.orange -- Colour left on Enderchest when counting redNS = "right" -- Rednet cable side redNE = colors.orange itemFile = {} itemFile[1] = {} itemFile[1][1] = 0 itemFile[1][2] = 0 function getItems() for i = 1,27 do itemArray = {} if c.getStackInSlot(i) then print("See if anythings in there") data = c.getStackInSlot(i) amount = table.getn(itemFile) for i = 1,amount do if itemFile[i][1] == data.name then print("Is in the array") itemFile[i][2] = itemFile[i][2] + data.qty else print("Not in table D:") print(data.name..data.qty) table.insert(itemArray,data.name) table.insert(itemArray,data.qty) for key,value in ipairs(itemFile) do print(key, value) end table.insert(itemFile,itemArray) end end end end end function writeFile(line) local diskFile = fs.open("disk/items","w") amount = table.getn(itemFile) print(amount) for i = 2,amount do text = itemFile[i][2].." X " ..itemFile[i][1] print(itemFile[i][1]," ",itemFile[i][2]) diskFile.writeLine(text) end diskFile:close() end while true do print("Setting EnderChest") redstone.setBundledOutput(redNS,redN) print("Tranfering Items") sleep(10) redstone.setBundledOutput(redNS,redNO) getItems() writeFile() print("Written to file") redstone.setBundledOutput(redNS,redNE) sleep(10) redstone.setBundledOutput(redNS,redNO) print("item's sent to the ME") end
Any help is appricated,
Thanks a lot,
Vennom.
#165648 Reading a specific line with in a file
Posted by MayContainVennom on 21 February 2014 - 01:45 PM in Ask a Pro
CometWolf, on 21 February 2014 - 01:26 PM, said:
http://computercraft...ki/Fs_%28API%29
local file = fs.open("fileName","mode") -- mode in this case should be "r" file.readLine() --reads first line variableYouWant = file.readLine() -reads second line file.close -- close the file handle
This would work for that example but I wont be just calling for line 2. In the final version I will wanting to be calling 1 put of a possible 10 lines per computer, The example's I have seen turn it into a table then pull the line but I haven't been able to get them to work.
#165645 Reading a specific line with in a file
Posted by MayContainVennom on 21 February 2014 - 01:11 PM in Ask a Pro
I'be been looking around here and had a few test runs but still can't work it out. I need a function that can read one line from a file when called (For example readLine(filename,line). I found one thread that seemed to have it working but couldn't get it working on my end. If you are still unsure, If I have a file set up like this:
Line 1 Line 2
I want to be able to read this file and retrieve what is on the second line. If you could give me a hand with this I would be very thankful as it is a start to a large project of mine...
Thanks,
Vennom
#161557 [Open Blocks] [Open Peripherals] getTankInfo being seen as a string and not a...
Posted by MayContainVennom on 22 January 2014 - 03:06 PM in Ask a Pro
#161554 [Open Blocks] [Open Peripherals] getTankInfo being seen as a string and not a...
Posted by MayContainVennom on 22 January 2014 - 03:03 PM in Ask a Pro
I've had this output before and is no use to me... Were as what I was using before the post before had the actually values being produced
#161548 [Open Blocks] [Open Peripherals] getTankInfo being seen as a string and not a...
Posted by MayContainVennom on 22 January 2014 - 02:46 PM in Ask a Pro
#161542 [Open Blocks] [Open Peripherals] getTankInfo being seen as a string and not a...
Posted by MayContainVennom on 22 January 2014 - 02:29 PM in Ask a Pro
I'm currently trying to make a program to read how much Liquid XP I have in a tank. To start off with I did some research and found out that I need to use getTankInfo to pull the information and it will be brought down in a table. I've never really used tables before so went looking for some templates to get me started. all the ones I have found seem to be throwing up an error saying "bad argument: table expected, got string"
The code I'm trying to use now:
local tank = peripheral.wrap("back") local tableInfo = tank.getTankInfo("south") for k, v in pairs(tableInfo) do for x, y in pairs(v) do print(x .. ": " .. y) end end
It was found somwhere in the OpenBlocks thread and seemed to be working for the person who posted it. I cannot work out why this isnt returning a table when tableinfo is one.
Thanks for reading...
Vennom
#153413 Choosing A Specifc Line Within A File To Read
Posted by MayContainVennom on 19 November 2013 - 04:26 AM in Ask a Pro
Engineer, on 18 November 2013 - 03:56 PM, said:
local lines = {} local file = fs.open( "file", "r" ) for line in file.readLine do table.insert( lines, line ) end file.close()
local lines = {} local file = fs.open( "file", "r" ) local line = file.readLine() while line do table.insert( lines, line ) line = file.readLine() end file.close()
local lastLine = lines[ #lines ]
Thanks for your help
#153349 Choosing A Specifc Line Within A File To Read
Posted by MayContainVennom on 18 November 2013 - 03:43 PM in Ask a Pro
I am working on a code that incorporates the Small Net system from Miscperipherals to read the Last line within a file. The problem I am having is I don't know the fucntion or the way to select a line from that file. I tried file.readLine(x) but that doesn't allow you to select the line it just reads the first one.
Thanks,
Vennom.
function lineCount() local file = fs.open("disk/logs", "r") if file then local i = 0 while file.readLine() do i = i + 1 end file.close() print(i) return i end end function finding() line = lineCount() print(line.."x") local file = fs.open("disk/logs","r") local a = file.readLine(line) print(a) return a end function transmiting() local Venn = peripheral.wrap("smNetSender_0") local Edd = peripheral.wrap("smNetSender_1") local p = finding() Venn.send("smartHelemet",p) Edd.send("smartHelemet",p) end while true do transmiting() sleep(5) end
#153010 Broken Player Detector
Posted by MayContainVennom on 15 November 2013 - 02:36 PM in Ask a Pro
Thanks for your help
You guys are awesome! Got it all working perfectly, thanks so much! Turns out I'm a bit rusty on the whole programming lark haha
#152940 Broken Player Detector
Posted by MayContainVennom on 14 November 2013 - 05:03 PM in Ask a Pro
Now it's just plain jiggered, error code:
startup:5: attempt to call nil
It's getting requests from the door, however it appears to be having trouble reading from the file? I tried moving it from a disk to computer storage, however it still came up with the same error. The file is named correctly, and just contains a list of the players. Loading it manually in the lua console just returns an empty table.
#152909 Broken Player Detector
Posted by MayContainVennom on 14 November 2013 - 11:52 AM in Ask a Pro
#152906 Broken Player Detector
Posted by MayContainVennom on 14 November 2013 - 11:43 AM in Ask a Pro
Client (Computer on Door):
rednet.open("bottom") function allowed(player,authServer) rednet.send(authServer,player) id, message, distance = rednet.receive() if message then return true else return false end end function door(player,authServer) if allowed(player,authServer) then redstone.setOutput("top",true) sleep(4) redstone.setOutput("top",false) return true else return false end end function logger(player,logServer,state) if state then rednet.send(logServer,player.." was granted access "..os.time.." via computer "..os.getComputerID()) else rednet.send(logServer,player.." tried to get in at "..os.time.." via computer "..os.getComputerID()) end end function getPlayer() event, name = os.pullEvent("player") return name end function main() local authServer = 330 local logServer = 331 local player = getPlayer() if door(player,authServer) then logger(player,logServer,true) else logger(player,logServer,false) end end while true do main() end
Server (With disk):
rednet.open("bottom") function authorise(request) players = fs.open("disk/allowed","r") for player in players:lines() do if request == player then return true else return false end end end function receiveRequest() id, request, distance = rednet.receive() return id, request end function allowPlayer(door,state) rednet.send(door,state) end function main() local id, player = receiveRequest() if authorise(player) then allowPlayer(id,true) else allowPlayer(id,false) end end while true do main() end
#142377 [1.51+] Using Network Cables (for dummies)
Posted by MayContainVennom on 30 August 2013 - 11:40 AM in Tutorials
Kingdaro, on 30 August 2013 - 11:37 AM, said:
Peripherals connected to computers act exactly as if they were right next to the computer itself, just that instead of accessing it by side, you access it by name.
In the case of disk drives, sides aren't involved, so names aren't involved. Connecting a disk drive to a computer via peripheral cable automatically mounts it, just like placing it next to the computer.
I forgot to add it to my Network >.<
Letme go ahead and faceplam for a few hours.
#142373 [1.51+] Using Network Cables (for dummies)
Posted by MayContainVennom on 30 August 2013 - 11:16 AM in Tutorials
Is there a way I can edit a program on a floppy disk in a drive through a network? For instance I want to edit disk/test in drive_0 on a computer on the network. How would I go about doing this?
#142344 Removing Text From A String
Posted by MayContainVennom on 30 August 2013 - 07:32 AM in Ask a Pro
#142285 Removing Text From A String
Posted by MayContainVennom on 29 August 2013 - 06:30 PM in Ask a Pro
I am wanting to write a code that uses the ME bridge with the chat box that will let me pull items from my ME system by listening to chat. The problem I am having is that if you are not within a 64 block radius the chatbox can't use the tell function.( I'm on a SMP server) So the way I can see to solve this is to have the request and the item Id on the same line. So what I need to do is separate the calling command from the block ID within in variable is this possible?
- ComputerCraft | Programmable Computers for Minecraft
- → MayContainVennom's Content