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

How to set a global variable unique to turtle

Started by sjones321, 15 March 2014 - 12:46 AM
sjones321 #1
Posted 15 March 2014 - 01:46 AM
I spent a little while (more than I want to admit) today working on this replacement refueling function trying to make it smarter. I think I have managed to cobble something that works. Though I realized after the fact that I would have a problem if I got more than one turtle going. I am attempting to set a global fuelLevel variable per turtle so that other programs can monitor fuel level. As can be seen right now it just sets one fuelLevel variable. I can't for the life of me figure out how to make one specific to each turtle. Also if you notice any other bits that can be improved or anything massively stupid let me know please. I am a fairly novice coder.

http://pastebin.com/yaP1Y5L3

Sorry in advance if I did something wrong.
oeed #2
Posted 15 March 2014 - 05:23 AM
I'm not quite sure what you mean. Global variables are only accessible by the turtle/computer your run the program on, you can't share data between computers (unless you use modems)
sjones321 #3
Posted 16 March 2014 - 06:29 AM
Ok now that's what I originally thought. Then as soon as I finished I freaked out and was like hold on wait a second. Ok yeah now that I think about it that makes sense. If anyone wants to look at the code and point out anything that's glaringly stupid I would appreciate it. Otherwise thanks for the response.