and smart to search through a text file to assign some values to variables.
here is an example text:
#charpic=patrick.png
#health=100
#type=enemy
#tileset=tiles/patrick_tile.png
what i would need is a script that searches one line, i thought i'd try this
Code: Select all
filename="patrick.txt"
file = io.input(filename, "r")
if file then
for line in file:lines() do
middle = string.sub(line, "=")
if middle then
key = string.sub(line, 2, middle-1)
result = string.sub(line, middle + 1)
character[key] = result
end
end
end
-- output etc
Code: Select all
pix=Image.load(character.charpic)
screen:blit(100,100,pix)
a.s.o.
also, my text is displayed with ascii characters that stand for tabs and breaks. is there a way to erase these?
because i think they are added to the variable .... perhaps ....
another question: is there a way to get rid of the "="s and to make it more flexible in case of a mistyping?thanks
--imhotep--