This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
LucasUK's profile picture

Computercraft / world items interaction (FTB)

Started by LucasUK, 03 December 2012 - 04:47 AM
LucasUK #1
Posted 03 December 2012 - 05:47 AM
Hello, on feed the beast - so no chest lock plugins or anything, just to my knowledge ic2 safe, and trade station.

I can make a secure application that users cannot escape, and store money amounts on a central secure server, which is inacessble to users. (under bedrock)

But - I need to be able to deposit or withdraw "money" using items. How can I setup this securely, (i.e swap a diamond for 100 credits) so that items are held in an inacessilbe location and can only be added or taken through code? Any ideas. Again, Feed the beast vanilla server.

Thanks
KillaVanilla #2
Posted 03 December 2012 - 01:49 PM
Hello, on feed the beast - so no chest lock plugins or anything, just to my knowledge ic2 safe, and trade station.

I can make a secure application that users cannot escape, and store money amounts on a central secure server, which is inacessble to users. (under bedrock)

But - I need to be able to deposit or withdraw "money" using items. How can I setup this securely, (i.e swap a diamond for 100 credits) so that items are held in an inacessilbe location and can only be added or taken through code? Any ideas. Again, Feed the beast vanilla server.

Thanks

You could use turtles and a navigation API to have a turtle move to the chest and pick up the items, for withdrawing.
However, for deposits, that's impossible without an ID detector; turtles can't tell the difference between a stack of dirt and a stack of diamonds.
Waaait. You could have a turtle contain "samples" of items. From there, all you need to do is use turtle.compareSlot. However, that somewhat limits the amount of "swappable" items, and poses a security risk, unless you find a way to separate the end-user and the "sorter" or "identifier" turtle. I'll code an example to show you what I mean.


function getWorth(slot)
	 -- Diamonds are worth 100 credits and are stored in slot 1
	 -- Gold is worth 75 credits and is stored in slot 2
	 -- Iron is worth 50 credits and is stored in slot 3
	 -- Leather is worth 10 credits and is stored in slot 4.
	 turtle.select(slot)
	 if turtle.compareTo(1) then -- it's a diamond
			 return 100
	 elseif turtle.compareTo(2) then -- it's gold
			 return 75
	 elseif turtle.compareTo(3) then -- it's iron
			 return 50
	 elseif turtle.compareTo(4) then -- it's leather
			 return 10
	 else
			 return 0
	 end
end

This is just a rough example.