[SOLVED] STI Not Working?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 6
- Joined: Tue Mar 01, 2022 4:18 pm
[SOLVED] STI Not Working?
Hey All,
I'm currently struggling to get my tiled map to load properly. I followed a Youtube video ( https://youtu.be/dZzAxYrUMRg ) and it still doesn't work. I tried troubleshooting it myself and it still isn't working.
This is the error message I get:
Error
main.lua:28: attempt to call global 'sti' (a nil value)
Traceback
[love "callbacks.lua"]:228: in function 'handler'
main.lua:28: in function 'load'
[love "callbacks.lua"]:136: in function <[love "callbacks.lua"]:135>
[C]: in function 'xpcall'
[C]: in function 'xpcall'
I'm not sure what it is exactly trying to tell me and so I am lost and requesting some help.
I have attached the main.lua file I am using so hopefully that can help you guys with helping me.
I'm currently struggling to get my tiled map to load properly. I followed a Youtube video ( https://youtu.be/dZzAxYrUMRg ) and it still doesn't work. I tried troubleshooting it myself and it still isn't working.
This is the error message I get:
Error
main.lua:28: attempt to call global 'sti' (a nil value)
Traceback
[love "callbacks.lua"]:228: in function 'handler'
main.lua:28: in function 'load'
[love "callbacks.lua"]:136: in function <[love "callbacks.lua"]:135>
[C]: in function 'xpcall'
[C]: in function 'xpcall'
I'm not sure what it is exactly trying to tell me and so I am lost and requesting some help.
I have attached the main.lua file I am using so hopefully that can help you guys with helping me.
- Attachments
-
- main.lua
- (2.45 KiB) Downloaded 261 times
Last edited by DoggylovesLove2D on Sat Mar 05, 2022 1:25 am, edited 1 time in total.
Re: STI Not Working?
Hi!
i suposse that you only gave the main.lua (and no the rest of files) on purpuse.
i never used that library 'sti' or watched that video but i took a quick look at your code and saw two problems:
first, you have love.load() defined two times, like this:
and thats a problem bc when you define a function two times, it gets replaced, for example:
will print 2 bc the first time the function got defined, it got told to say 1, but we defined it again so it overwrites all the code of the function to print (2)
so you only should have all your load code in just one on love.load()
and the second thing i found is a bumb mistake that also annoyed me more than one time :
LOCAL
in your code you did this to define sti:
and local means that the variable you define will exist only on that block
so in this case the block starts with
and ends when you end the function
and inside this block you define sti with local
meaning that sti will only exist on that block and attemping to call it outside that block will return nil
so when you try to call sti in the line 28, youre not calling a library, youre calling nil.
just delete the 'local' on line 7
fixing those two issues will(hopefully) stop löve to throw the error you mensioned!
here's a link to the lua manual about local variables and blocks if you need it:
https://www.lua.org/pil/4.2.html
hope it helped!
i suposse that you only gave the main.lua (and no the rest of files) on purpuse.
i never used that library 'sti' or watched that video but i took a quick look at your code and saw two problems:
first, you have love.load() defined two times, like this:
Code: Select all
-- Load some default values
function love.load() --1st time---
--code
end
function love.load() --2nd time---
map = sti("maps/map1.lua")
end
and thats a problem bc when you define a function two times, it gets replaced, for example:
Code: Select all
function uwu()
print(1)
end
function uwu()
print(2)
end
uwu()
so you only should have all your load code in just one on love.load()
and the second thing i found is a bumb mistake that also annoyed me more than one time :
LOCAL
in your code you did this to define sti:
Code: Select all
local sti = require "libraries/sti"
so in this case the block starts with
Code: Select all
function love.load()
and inside this block you define sti with local
meaning that sti will only exist on that block and attemping to call it outside that block will return nil
so when you try to call sti in the line 28, youre not calling a library, youre calling nil.
just delete the 'local' on line 7
fixing those two issues will(hopefully) stop löve to throw the error you mensioned!
here's a link to the lua manual about local variables and blocks if you need it:
https://www.lua.org/pil/4.2.html
hope it helped!
Code: Select all
for i, v in pairs(problems) do
fix(v)
end
-
- Prole
- Posts: 6
- Joined: Tue Mar 01, 2022 4:18 pm
Re: STI Not Working?
Hello there,
Thanks for your help, but weirdly I am still facing some issues
here is the error code:
Error
libraries/sti/utils.lua:195: Could not open file ../GameLove2D/map.png. Does not exist.
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'newImageData'
libraries/sti/utils.lua:195: in function 'fix_transparent_color'
libraries/sti/init.lua:106: in function 'init'
libraries/sti/init.lua:48: in function 'sti'
main.lua:8: in function 'load'
[love "callbacks.lua"]:136: in function <[love "callbacks.lua"]:135>
[C]: in function 'xpcall'
[C]: in function 'xpcall'
and also I'll provide all the files, I thought I did in the previous post but I guess not
Thanks for your help, but weirdly I am still facing some issues
here is the error code:
Error
libraries/sti/utils.lua:195: Could not open file ../GameLove2D/map.png. Does not exist.
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'newImageData'
libraries/sti/utils.lua:195: in function 'fix_transparent_color'
libraries/sti/init.lua:106: in function 'init'
libraries/sti/init.lua:48: in function 'sti'
main.lua:8: in function 'load'
[love "callbacks.lua"]:136: in function <[love "callbacks.lua"]:135>
[C]: in function 'xpcall'
[C]: in function 'xpcall'
and also I'll provide all the files, I thought I did in the previous post but I guess not
Re: STI Not Working?
You cannot use ".." in file paths in LÖVE.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
-
- Prole
- Posts: 6
- Joined: Tue Mar 01, 2022 4:18 pm
Re: STI Not Working?
Is there a way to change it?
Re: STI Not Working?
I haven't used Tiled or STI, but you may have to get Tiled to export the data without ".." in the paths in the first place (unless you wanna make modifications to the STI library itself to resolve paths containing ".." automatically). Try having the Tiled files in the same folder as the images being used when you export the data.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: STI Not Working?
upload a full .zip or .love file of your game and we can take a look.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
-
- Prole
- Posts: 6
- Joined: Tue Mar 01, 2022 4:18 pm
Re: STI Not Working?
Will do. I didn't realize I had to zip the file to be able to share it
- Attachments
-
- MyGame2 - Copy.zip
- (471.06 KiB) Downloaded 280 times
Re: STI Not Working?
ok
i made a quick search for STI
and looks like STI lets you use Tiled for the map creation
but looks like the map you exported with Tiled isn't written in LUA. you need to click on 'Export as' and select LUA format
this is shown on the minute 10 of the video
i made a quick search for STI
and looks like STI lets you use Tiled for the map creation
but looks like the map you exported with Tiled isn't written in LUA. you need to click on 'Export as' and select LUA format
this is shown on the minute 10 of the video
Code: Select all
for i, v in pairs(problems) do
fix(v)
end
Re: STI Not Working?
yeah, your map.lua is just a renamed xml file.. it needs to be an actual lua file. File > Export As > Lua
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 8 guests