66 posts
Location
Minecraft world
Posted 20 April 2017 - 05:17 PM
Hello so i'm trying to load a image but when i want to use x and y coordination's instead of numbers i want to use the variables from my tables like this.. ps image is correct because when i do paintutils.drawImage(lua_icon,
1,
1) it works instead of pos and ypos
function load(name)
local file = fs.open(name,"r")
local data = file.readAll()
file.close()
return textutils.unserialize(data)
end
tabl = load("root/system/configs/AppPos.conf")
--root/system/configs/AppPos.conf
print(tabl)
print(tabl.ypos)
print(tabl.xpos)
lua_icon = paintutils.loadImage("root/system/Apps/Lau_Shell/lua_shell.icon")
paintutils.drawImage(lua_icon, tabl.ypos, tabl.xpos)
Table
{
app = "Lua_Shell",
xpos = "10",
ypos = "5",
}
Edited on 20 April 2017 - 04:35 PM
66 posts
Location
Minecraft world
Posted 20 April 2017 - 05:23 PM
Forgot to mention it outputs:
5
10
expected image, x, y
797 posts
Posted 20 April 2017 - 05:44 PM
Your x and y positions are strings, not numbers. Remove the speech marks in the table:
{
app = "Lua_Shell",
xpos = 10,
ypos = 5,
}
I think you've mis-spelt 'Lua' in the image path, too ("root/system/Apps/Lau_Shell/lua_shell.icon").
Note, coordinates are generally (x, y) not (y, x), that is, how far across by how far down. It's just confusing to everyone to swap the names like you've done.
66 posts
Location
Minecraft world
Posted 20 April 2017 - 06:32 PM
Your x and y positions are strings, not numbers. Remove the speech marks in the table:
{
app = "Lua_Shell",
xpos = 10,
ypos = 5,
}
I think you've mis-spelt 'Lua' in the image path, too ("root/system/Apps/Lau_Shell/lua_shell.icon").
Note, coordinates are generally (x, y) not (y, x), that is, how far across by how far down. It's just confusing to everyone to swap the names like you've done.
Thanks it worked BUT when i use the table or do something with it then it automaitcly adds the "" back how can i prevent this?
797 posts
Posted 20 April 2017 - 06:58 PM
I'll need to see how you're saving the table and where you're getting the coords from. Most likely is that you're doing table.xpos = read() somewhere? If you change that to table.xpos = tonumber( read() ) it should fix it. If it doesn't, post the code where you're updating the values in the table and when you're saving it and I can help more.
66 posts
Location
Minecraft world
Posted 20 April 2017 - 07:14 PM
The thing is i'm not saving the code i'm just loading it btw here all the code from the file that is doing that
tabl = load("root/system/configs/AppPos.conf")
--root/system/configs/AppPos.conf
print(tabl)
print(tabl.ypos)
print(tabl.xpos)
lua_icon = paintutils.loadImage("root/system/Apps/Lau_Shell/lua_shell.icon")
paintutils.drawImage(lua_icon, tabl.ypos, tabl.xpos)
tab = {app = "Lua_Shell", xpos = "10", ypos = "5"}
save(tab, "root/system/configs/AppPos.conf")
66 posts
Location
Minecraft world
Posted 20 April 2017 - 07:29 PM
I'll need to see how you're saving the table and where you're getting the coords from. Most likely is that you're doing table.xpos = read() somewhere? If you change that to table.xpos = tonumber( read() ) it should fix it. If it doesn't, post the code where you're updating the values in the table and when you're saving it and I can help more.
The thing is i'm not saving the code i'm just loading it btw here all the code from the file that is doing thattabl = load("root/system/configs/AppPos.conf")–root/system/configs/AppPos.conf
print(tabl)print(tabl.ypos)print(tabl.xpos)lua_icon = paintutils.loadImage("root/system/Apps/Lau_Shell/lua_shell.icon")paintutils.drawImage(lua_icon, tabl.ypos, tabl.xpos)tab = {app = "Lua_Shell", xpos = "10", ypos = "5"}save(tab, "root/system/configs/AppPos.conf")
797 posts
Posted 20 April 2017 - 10:54 PM
Ehh, look at the last two lines again. Not saving it, you say? Remove the speech marks around the numbers and it'll work fine.