Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Get something from file — Gideros Forum

Get something from file

edited May 2016 in General questions
Hi

I have some trouble undestanding how to get something from a .txt file. Can anyone point me to some good reading or tutorials on this as this things I found on the forum did not really explain it enough for me??

I have 3 things I need to solve in my app:
1. Saving a variable from inside the app for later use (next time the user opens the app)
2. I have up to 150 images.
3. I have up to 150 texts with up to 200 words

At the moment I am looking at solving 2 and hope that could also be used for 3.

@pie said I could look into this code for a way to have my image references in a textfile instead of naming them all in the LUA code. But I only get it to return a nil-value... I am not sure if it does what I am trying to achieve.
function getPackTextures(packname)
    local textures = {}
    local file = io.open(packname..".txt")
    if file then
        local parsed
        for line in file:lines() do
            parsed = line:split(", ")) 
            textures[#textures+1] = parsed[1]
        end
        -- now variable textures contains all texture names from pack
    else
        print("no pack found")
    end
    return textures
end
In the tutorial section I found a tutorial on saving/loading data But it just show some code and dosn't really explain what is happening... what is w+ and |D|
local file=io.open("|D|settings.txt","w+")
file:write(Player .. "\n")
file:write(Score .. "\n")
file:write(HiScore .. "\n")

Comments

Sign In or Register to comment.