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

Turtle Trading Station [0.3.0]

Started by unobtanium, 27 May 2013 - 04:45 PM
unobtanium #1
Posted 27 May 2013 - 06:45 PM


Hello Minecraft- and ComputerCraft-Community,

i am here to present you my Turtle Trading Station (TTS), which makes trading with other people easier and more compact then ever before (maybe).

Shoutoutbox:
If i make changes to the code, without changing the version of the program i will write these in the shoutoutbox. Sometimes i will write in some news and informations as well. Before posting a bug, please check if it is listed in the shoutoutbox allready and download the code again.

Everybody who used the 0.1.0 version have to delete their created trades. I am sorry :s
Fixed computer and turtle program after adding exchange money! Works fine now again :D/>


What does the Turtle Trading Station?
Using this program in a multiplayer world, makes trading with other players very easy. Including password secured admin section and an user friendly overview about everything, helps the player to get into it right away.
Add trades, fill chests, get items, change chest slot amount, and easy information access to the turtle if everything is running okay.



TURTLE TRADING STATION BETA 0.3.0

Pastebin:

Computer:
Md5UXKbP
Turtle:
NunH2naj



Features:

admin screen
- password secured
- change various settings
- create trades
- refill chests
- get items out of the chests
- get quickly information how the turtle is doing
- refuel the turtle

customer screen
- trades are sorted: supply and demand
- shows list of possible trades depending on the selected supply and demand
- clear definition of what the customer has to do and what he buys for what
- key presses only lowers the failure of the customers

turtle & trading
- quick moving between the chests
- can be place a distance away to protect what is in the chests
- handles exchange money
- handles big trades with items stacks over 16 slots (turtle maximal slots in the inventory)
- detects:
– if the customer wanted to cheat and put in the wrong kind of item
– if the customer didn't even placed an item in the chest
– if the trade is even possible with the amount of items insert
– how many times the trade is possible depending on the insert items, the amount of items and the left free space in the chests



Installation:
Label your turtle and computer to let it save the programs and save files.

label set <name>

If the HTTP API is enabled, you can use the pastebin import. Simply type the following words into your turtle.
Computer:
pastebin get Md5UXKbP startup
Turtle:
pastebin get NunH2naj startup


How to use:
Build a nice trading area like shown at the picture at the beginning of this post. The dimensions of the chests can be 4x4 on two sides, but you can lower this amount if you know allready, that you dont have so many demands and offers.
Spoiler

You also have to place a chest - or better a double chest - underneath the turtle. The block above the chest has to be a non-solid block for example a stair.
Spoiler

Or use an enderchest:
Spoiler

Place a modem on the turtle and on the top side of the computer.
After installing both programs, on the computer and on the turtle, you can run the programs. I recommend using "startup" so they can automatically resume after you reload a chunk.
The computer asks for a password. Type in some letters (!) of your choice and finish with Enter. The password wont be visible until you hit Enter. An overview menu shows you the computer id. Enters the computers ID into the turtles screen and take the turtle's id and enter it into the computer. This let's them communicate with each other. Then you can tipe in a welcome text for the customers. Say hello or/and the newest and hottest purchases to the people. That is your place to be creative.
You can change the password, the turtle id and the welcome text in the admin menu under "Options".

The turtle now waits for incoming messages. The computer shows the admin menu with multiple options:



1 - Start
This will leave the admin menu and start up the customer one, where everybody can go and buy items.
You can leave the customer menu by simply tiping your passwort.
Spoiler

2 - Add
This is going to add a new trade. You have to answer som questions:
Which item do you want? Demand
Which item do you have and give? Offer
Be sure that you write the names correctly!
Then how many items you want and then give. (E.g. You want 1 Iron Ingot and give 8 Oak Wood)
If you dont have a chest with the demand or offer item it will ask for an indicator item. Place it in the chest and hit Enter.
Your trade should be created.


3 - Get
If you are having items from trades in your chests, you can select the item and the amount here and the turtle will go and grab them for you. Do not take items out of the chests by yourself!

4 - Refill
If some chests are not full enough to make some serious trading, you should check this menu out. Select an item type and place the items in the chest (not the accual item chest!) and hit Enter.
The turtle will fill them into the correct chest.

5 - Refuel
Place some coal into the chest and the turtle will refuel it.
Be aware that the turtle wont work correctly if it doesnt have fuel in it anymore!

6 - Slots
If you are using double chests or an other type of chest from an other mode, you can set the amount of slots in them here. This will keep the overview for the turtle and sends you a message if a chest is full.

7 - Options
Change your password, the turtle id and the welcome text here.

8 - Get Info
Checks if the turtle has everything it needs. You shouldn't ignore this one, so hit it everytime until it says it is fine.

9 - Help
Links you back to this forum post. Just in case, if someone needs serious help :s

0 - Quit
:(/>
Quits just the computer program. You have to terminate the turtle program by holding STRG + T for some seconds.


Advanced Usage:
You can place an enderchest down and have the turtle and computer saperated. Be aware that the turtle and computer have to be in range to communicate over rednet with each other.

On the bottom left of the admin menu, you can see the computer id.

You can delete all trades by tiping in the computer's and turtle's screen:

delete ttsVariables
delete ttsTrades

If the turtle says "access denied", reboot your computer/turtle and try again.

If the computer doesnt react anymore, shutdown the turtle and the computer with STRG + T and restart them again. If the problem still occurs send me a message here!

You can change the side on which the modem of the computer goes in the code itself.
Download the file and edit it with "edit <nameYouGaveTheFile>".
At the first line you can change the "top" to another side: "bottom", "left", "right", "back". Dont forget to use brackets!

The computer safes just the trades, including the amount of the items and the item names. The turtle knows which kind of item and how many are in the chests. I may change this to speed some parts of the purchases for the customer up.


Updates
SpoilerBeta 0.3.0
- added the turtle to detect if a chest cant handle any more items depending on the trade times possible, the insert items, the items left in the chest

Beta 0.2.0
- improved the text shown; doesnt cut off on the end of the screen
- added individual welcome text feature which gets shown for the customer



Found a bug, got an error or something didnt worked?

Something is strange or you even get a error message, please fill in this following layout and post it in this post:
Does the problem still occures if tts gets redownloaded:
FTB Version:
Singleplayer or Multiplayer:
Error Code:
What happened:

This is helping me a lot to quickly find where your problem is and hopefully how to fix it. If you get an error please write it down too. Mention which programs you where using and what/how many items in the turtle and chests were.

More programs made by myself:
Smart Programmer — Easily create loopable programs ingame without lua commands
ULTIMATE WOOD CHOPPER — Set up a farm to chop wood or cut down single 1x1 or 2x2 trees.
Turtle Interactions - Simply naviagate the turtle with a menu
Two High Door - Opens one or more two high doors over rednet.
Items Sorting Turtle — Set up a sorting layout with chests and let it sort items for you. Perfect for Quarries!

Facebook:
https://www.facebook...362726857167297


That's it! I hope i didn't forget anything.
Because the program is still in beta i cant say that it is bugfree!
If there are any questions, suggestions, errors or bugs, feel free to leave a comment to improve this program pack.
Thank you for your attention.
UNOBTANIUM

PS: I am going to add more pictures and maybe even a video to this.
PSS: This program was a mess to set up. Give it some love :'(
SyberSmoke #2
Posted 29 May 2013 - 02:43 PM
Combine this with Thaumcrafts Runed Stone and you have a pretty fool proof system. Is the block above the chest a half block? Because last I tried, a block over a chest keeps the player from opening the chest.

Suggestion: Functionality for a charging station. If the turtle returns to a single place each time it finishes, then the user can place, or the turtle could place a charging station there with access to a power source. That way fuel is not needed. :-)
unobtanium #3
Posted 29 May 2013 - 03:32 PM
You mean wardened blocks? Yeah, thats the spirit :P/>
And yes it has to be a stair block to open up the chest. Or at least a non-solid one. Got it wrong on the picture, but i realized it too late :D/>

Well, dont know where to put a charging station :s
I think everybody has a stack of coal, charcoal or bucket of lava. This should keep the turtle running quiet a while accually.
SyberSmoke #4
Posted 29 May 2013 - 04:08 PM
Well it just depends on where the turtle rests most of the time. If it comes to rest in front of the chest, then placing a charging station there with just a single solar cell would be more then enough to charge it forever.

Corrections by the way:
Place a modem on the turtle and on the top, bottom, left or right side of the computer.
After installing both programs, on the computer and on the turtle, you can run the programs. I recommend using "startup" so they can automatically resume after you reload a chunk.
The computer asks for a password. Type in some letters (!) of your choice and finish with Enter. The password wont be visible until you hit Enter. An overview menu shows you the computer id. Enters the computers ID into the turtles screen and take the turtle's id and enter it into the computer. This let's them communicate with each other.
You can change the password and the turtle id in the admin menu under "Options".

The turtle now waits for incoming messages. The computer shows the admin menu with multiple options:


Also: What is the purpose of the double chest under the single pickup chest. That should be described some.
unobtanium #5
Posted 29 May 2013 - 05:03 PM
The turtle is most of the time in front of the pickup chest. But because it needs the space above and behind for the demand and offer chests, and underneath it the mysterious double chest. Where should be the charging station? One option would be using a solar turtle, which powers itself forever as well. This would need a non-solid block above the turtle :s

Thank you for the corrections <3

The mysterious double chest is for the turtle to store items for a short time if a customer is trading. Probably an overkill, but this let the turtle make big trades over 16 stacks of items. The turtle also can handle wrong items the customer put in the chest even if right items are in it. For example, create a trade: You give 1 iron Ingot for 8 Oak Wood (You, the admin)
Put 5 stacks of iron into the chest (i mean let the turtle refill it).
Then play customer, and insert a whole chest of oak wood. Place a stone block as well into it. The turtle will handle all of it :D/>
tashin #6
Posted 30 May 2013 - 03:27 AM
I keep getting startup:621: attempt to perform arithmetic __mul on nil and number when trying to perform a trade.
unobtanium #7
Posted 30 May 2013 - 08:07 AM
I messed around a bit and the communication between the turtle and computer was a bit bad. I improved it, but on the other hand it might be a bit slower. I tested it and it is working fine for me now.

I am also going to improve the language and positioning of the text on the screen. Some parts are cut off :(/>

I also let the turtle check, how much space is left in the chest, because right now, it doesnt care if the chest is full or not and then is messing up the next trade… i want to make it as resistent as possible, which it is allready, if you are experimenting with it a little bit.
D3matt #8
Posted 30 May 2013 - 10:38 PM
Does it store one trade per chest, or how does it work?
unobtanium #9
Posted 31 May 2013 - 07:57 AM
It stores one kind of item in each chest. Each chest/item can be used for multiple different trades. For example you have three chests:
Oak Wood
Iron Ingot
Charcoal
There are trades possible like this:
Oak Wood for Iron Ingot
Oak Wood for Charcoal
Iron Ingot for Oak Wood
Iron Ingot for Charcoal
Charcoal for Oak Wood
Charcoal for Iron Ingot

You can set the amount of each item in the trade individually, which means you can sell: 1 Iron Ingot for 8 Oak Wood, but you also can give the customer special purchases if he gives you more Wood at once: 10 Iron Ingot for just 72 Oak Wood instead of 80 Oak Wood.

If the customer chooses the 1 Iron Ingot for 8 Oak Wood and inserts 16 Oak Wood, the customer gets 2 Iron Ingot back. I think a lot is possible with this setup :D/>

edit:
And, with the same trade, if the customer inserts 20 Oak Wood he gets 2 Iron Ingot as well and the 4 Oak Wood overflow as exchange items back. So the customer doesnt even have to count the items by himself :D/>
unobtanium #10
Posted 03 June 2013 - 10:49 AM
Finally got into adding a new feature:
The turtle now detects if the demand chest cant handle the amount of items the customer insert. It checks how many free space is left in the chest and makes a new trade with less demand items. Otherwise it just says that there isnt a trade possible with this kind of item.
I may go ahead and let the computer safe this information and doesnt let it show any of these trades anymore until the admin takes items out.
But not today! Anyways, hope you enjoy :D/>
unobtanium #11
Posted 09 June 2013 - 09:27 AM
Fixed a bug where the computer program crash while loading information out of a file…
The turtle crashed as well at some point while trading. So i fixed that as well.

Hope you are having fun with it :D/>
Markusi13 #12
Posted 17 July 2013 - 08:45 AM
Pretty cool Program! But i cant build it on the server where i play because the have banned turtles ^^
Sajo99 #13
Posted 14 August 2013 - 09:15 AM
i get a error on turtle if i chose get info BUG!!
please fix it :D/>
unobtanium #14
Posted 14 August 2013 - 10:06 AM
This is going to be easy to find without no information about the error….
ebony #15
Posted 18 August 2013 - 05:42 AM
Very cool. How about adding a screen to show what items you can trade?
lordphoenixmh #16
Posted 06 September 2013 - 11:22 AM
Could you possible put up a video on how to setup the station itself AND how to teach the turtle which chest holds what. The picture is good, but I think a video would be better.