Posted 02 March 2015 - 06:42 PM
I am setting up a program that grabs variables from a config file, lets call it "server.cfg"
config reads like this:
when I load the config and print the value of floors like this:
I get this output:
my program works fine when I do this:
but when I call it in a varriable and compare it to a value like this:
I get an error that says:
what am I missing?
Edit: can this thread be closed, I got it using the tonumber function, forgot it existed untill i made this post, final code looks like this:
config reads like this:
floors = 5
when I load the config and print the value of floors like this:
config.open("server.cfg")
print(config.read("floors"))
I get this output:
5
my program works fine when I do this:
config.open("server.cfg")
floors = 5
if floors >= 5 then
do something
end
but when I call it in a varriable and compare it to a value like this:
config.open("server.cfg")
floors = config.read("floors")
if floors >= 5 then
do something
end
I get an error that says:
attempt to compare string with number expected, got string
what am I missing?
Edit: can this thread be closed, I got it using the tonumber function, forgot it existed untill i made this post, final code looks like this:
config.open("server.cfg")
floors = tonumber(config.read("floors"))
if floors >= 5 then
do something
end
Edited on 02 March 2015 - 05:51 PM