0 votes
asked 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

eyJ2ZXJzaW9uIjoxLjMsImZlYXR1cmVzIjp7ImxvY2F0aW9uIjp7InJvb20iOnRydWUsIm91dHNpZGUiOnRydWV9fSwic3RvcmVzIjp7Indvb2QiOjgyLCJ0ZWV0aCI6MywiZnVyIjozLCJiYWl0IjowLCJtZWF0IjozLCJjbG90aCI6MX0sImNoYXJhY3RlciI6e30sImluY29tZSI6eyJnYXRoZXJlciI6eyJkZWxheSI6MTAsInN0b3JlcyI6eyJ3b29kIjoxMH0sInRpbWVMZWZ0IjozfSwiYnVpbGRlciI6eyJkZWxheSI6MTAsInN0b3JlcyI6eyJ3b29kIjoyfSwidGltZUxlZnQiOjd9fSwidGltZXJzIjp7fSwiZ2FtZSI6eyJidWlsZGVyIjp7ImxldmVsIjo0fSwidGVtcGVyYXR1cmUiOnsidmFsdWUiOjQsInRleHQiOiJob3QifSwiZmlyZSI6eyJ2YWx1ZSI6NCwidGV4dCI6InJvYXJpbmcifSwiYnVpbGRpbmdzIjp7ImNhcnQiOjEsInRyYXAiOjMsImh1dCI6M30sInBvcHVsYXRpb24iOjEwLCJ3b3JrZXJzIjp7fSwib3V0c2lkZSI6eyJzZWVuRm9yZXN0Ijp0cnVlfX0sInBsYXlTdGF0cyI6e30sInByZXZpb3VzIjp7fSwib3V0Zml0Ijp7fSwiY29uZmlnIjp7ImxpZ2h0c09mZiI6ZmFsc2UsImh5cGVyTW9kZSI6dHJ1ZX0sImNvb2xkb3duIjp7ImdhdGhlckJ1dHRvbiI6Mi41LCJ0cmFwc0J1dHRvbiI6NTQuNX19

1 Answer

0 votes
answered 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.
...