Somewhat more a CC programming questions I guess:
Bit of a nub when it comes to programming and run into a problem that I am having a hard time searching for answers for.
I am using this to read the contents of a file on a Floppy disk:
Code:
local FloorFile = fs.open("disk/floor", "r")
if FloorFile then
ThisFloor = FloorFile.readLine()
print("This floor: "..ThisFloor)
FloorFile.close()
else
print("No Floor File/disk found")
return
end
This appears to work fine. The file just contains a single digit number(indicating the floor at which the computer in question is located at)
Later however I want use this stored variable, for example:
Code:
local buttoncolours={}
for k=1, #buttontext do
buttoncolours[k]=8192 --green
end
buttoncolours[ThisFloor]=32 --lime
I would assume this would save the colour green in all the tables positions and then overwrite the one which matches the floor the computer is on with lime, but for some reason it doesn't.
I am guessing it is caused by it considers the number read from the file as a string and not a numerical value(and thereby creates a new entry with the string as key)? If so how would I go about translating it from this string(of one digit number) to the real number?