0 votes
by (2.9k points)
edited by

Hello all!

I have a question I am hoping there is a answer for.

I have a game, in that game I wish to allow players a way to trade via code ex,:  50 wood and 40 stone birjhfneshhbvukkjhb.

I wat it to create a letter key that when enters into the receiving end it adds whatever was wanted.

what concernes me is if it the trade is reversed (40 stone 50 wood) It will most likely make a new code.


I am using sugarcane and who ever knows how to do this would be a great help.



An example would be "A dark room". http://adarkroom.doublespeakgames.com


Save code


1 Answer

0 votes
by (180 points)
edited by
Sorry, but I cannot provide you with the code but only the mechanics to do what you want to do.

You can use hash codes like md5, sha1 etc to get what your unique codes.

you could use a template like this " value1SEPARATORobject1SEPARATORvalue 2SEPARATORobject2 "  and hash(md5) each of them and concatenates them.

For example:

40  => D645920E395FEDAD7BBBED0ECA3FE2E0

stone  => 0A840EF45467FB3932DBF2C2896C5CBF

50  => C0C7C76D30BD3DCAEFC96F40275BDC0A

wood   => 22811DD94D65037EF86535740B98DEC8

use a separator like - (hyphen)

your code = D645920E395FEDAD7BBBED0ECA3FE2E0-0A840EF45467FB3932DBF2C2896C5CBF-C0C7C76D30BD3DCAEFC96F40275BDC0A-22811DD94D65037EF86535740B98DEC8

modify your code acceptor function to split them using a separator and compare hash(md5) with allowable trade numbers and objects.

if you think the code is long, create your own encoder or decoder functions.

You would have noticed that  "50 wood and 40 stone" and "40 stone and 50 wood" will have different full codes. If you want them to work as same modify your acceptor function so that it can treat them same because you have their individual codes too.
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.