Jump to content


MayContainVennom's Content

There have been 23 items by MayContainVennom (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#190592 [CC Latest] MoarPeripherals

Posted by MayContainVennom on 10 August 2014 - 07:31 PM in Peripherals and Turtle Upgrades

Heyo,

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

View Postwieselkatze, on 06 August 2014 - 11:10 AM, said:

Voila! There is the code. (I finally arrived at home :P)

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

View Postflaghacker, on 06 August 2014 - 08:23 AM, said:

You have 2 nested for-loops with the same value, "i". I don't know if that's technically a problem - they could be conflicting - but it's certainly confusing.

Treid, it still seems to be happening



#190273 It should work

Posted by MayContainVennom on 06 August 2014 - 02:37 AM in Ask a Pro

Having the 27 row array would work for a while but the aim is to have everything that we spawn on the screen at all times. It wouldn't be long until we need more and it will still need to be two dimensional so the values can be updated. I'll PM you the info now



#190271 It should work

Posted by MayContainVennom on 06 August 2014 - 02:31 AM in Ask a Pro

There must be a better way. I'll give you the server details in PM if you want to have a look. I'm GMT and should be asleep but I really want to get it sorted so I'll jump back on if you want



#190269 It should work

Posted by MayContainVennom on 06 August 2014 - 02:26 AM in Ask a Pro

View PostNeywiny, on 06 August 2014 - 02:20 AM, said:

well I'll tell you what, I'd like to help you. this build is something I'd probably do eventually, so I figured why not help a brother out. Anyways, when this happens to me, I print everything physically possible to the computer. I'm talking print the data.name, the amount variable, anything that changes when it finds a new item, print it to a file or monitor or what have you just be able to read it. anything at all. then, look at the result. You should see a number or two not changing. Also keep in mind that I go overboard for debugging, yet am very curious in what you're doing since it's an actual "real world" application, as apposed to my creative-superflat builds. Please report back, and I'm serious. I want to know how it turned out and If I can help in any other way.

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

Heyo,
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 :)

Posted Image


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:

Use the fs api
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

Hello there,

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

0.2.1-preview8



#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

This is now producing:
Posted Image

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

View PostCometWolf, on 22 January 2014 - 02:41 PM, said:

tableInfo probably is, however the valuta held by the table (v) might not be. Running it through a pairs iterator will therefore give the error.

So were would I replace V to make it work?



#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

Hello there,

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

View PostEngineer, on 18 November 2013 - 03:56 PM, said:

A proper way of doing this is reading the whole file and putting it in a table, and with that you can request each line you will need from that file. The code isnt actually really hard:
option 1
option 2
Those two options do essentially the same. To get the last line, you just get the table of the length and use that as index:
local lastLine = lines[ #lines ]


Thanks for your help :D



#153349 Choosing A Specifc Line Within A File To Read

Posted by MayContainVennom on 18 November 2013 - 03:43 PM in Ask a Pro

Hello there,

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

Sorry about the delay, been at college all day. Will try out the new code and report back asap.

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

*UPDATE*

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

Ah crap, I knew it would be simple! Thanks a tonne, I'll go test it out now



#152906 Broken Player Detector

Posted by MayContainVennom on 14 November 2013 - 11:43 AM in Ask a Pro

On a multiplayer server, I have been creating a system whereby each door in a building has a player detector attached, and thereby only allowed players can open them. Each door has a computer which talks to a main server, holding the disk, and then the server returns either true/false if the user is allowed. The code appears to work, however it will only read the first line of the 'Allowed Users' file. I think this is a simple fix, however I cannot for the life of me see where it is. Any help would be much appreciated.

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

View PostKingdaro, on 30 August 2013 - 11:37 AM, said:

Once you turn on the disk's modem, it should be available to you, mounted under the /disk directory.

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

Hey guys,

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

Well the input would be somthing like !request 1 example. I need to take the!request out so the ME peripheral can pull out ID 1.



#142285 Removing Text From A String

Posted by MayContainVennom on 29 August 2013 - 06:30 PM in Ask a Pro

Hello there,

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?