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

[Lua][Java][Question] "Currency" concept/Sending variables thru rednet

Started by pOke, 22 January 2013 - 06:52 AM
pOke #1
Posted 22 January 2013 - 07:52 AM
I am trying to create a currency system for the server I play on.
Instead of the money being blocks, or level points, I am trying to do it with computers and having the money "floating in the clouds"
To do this I believe I want to have a main computer with rednet enabled that is able to send/receive messages in response to other computers elsewhere.
My question is about the main computer which all other computers will communicate. The main computer has the the variables (i.e the "money") on it. So Player 1's "money" will be on there, and set to (however much money they have) 100 for example but when the computer at the food store makes a request to see Player 1's balance, the computer cannont respond with the variable in it that says Player 1's balance = 100, it just sends a string of the variables name. I am wondering is there something I can do to make it send the actual variable. If not, is there a basic method for converting a variable to the value it holds so I can send that.


Thanks!

-pOke
(Attached is my code, :)/> )
[attachment=958:currency1.txt]
Lyqyd #2
Posted 22 January 2013 - 08:21 AM
Take out the quotes around player1Balance in your rednet.send call. If that makes it complain about wanting a string, make it:


rednet.send(id, tostring(player1Balance))

tostring() will convert the numeric value to a string.
pOke #3
Posted 23 January 2013 - 02:14 PM
Thank you so much worked like a charm!