Page 1 of 2

Trying to load a Tiled map with STI

Posted: Tue Jan 02, 2018 7:00 pm
by Sonic
I am new to coding and scripting, I ran into a problem when trying to load my map. I tried to find the solution myself, but nothing seemed to work. The error was:

s_ti/sti/init.lua:44: attempt to perform arithmetic on global 'st_i' (a nil value)

Full code: https://gist.github.com/BansheeSonic/01 ... e9f4d8aa63
If you can send me a fixed version, that would be great.

Thanks for helping!

Re: Trying to load a Tiled map with STI

Posted: Tue Jan 02, 2018 8:13 pm
by zorg
You're missing the quote marks, that should be a string.

Re: Trying to load a Tiled map with STI

Posted: Wed Jan 03, 2018 4:57 pm
by Sonic
where do i put them?

Re: Trying to load a Tiled map with STI

Posted: Wed Jan 03, 2018 5:30 pm
by zorg

Code: Select all

local map = setmetatable(love.filesystem.load(st_i/sti/map.lua)(), Map)
Unless you're using notepad, even the syntax highlighter tells you that something's off; that whole thing should be a string.

Code: Select all

local map = setmetatable(love.filesystem.load('st_i/sti/map.lua')(), Map)
Note that this doesn't guarantee that it'll work; it only fixes this one error; others may pop up.

Re: Trying to load a Tiled map with STI

Posted: Wed Jan 03, 2018 5:35 pm
by MadByte
Welcome to the forums.
You tried to edit the library itself, thats not how it works. To learn how you use it look at the quick example in the description of the library on github or try this tutorial.

If you're completely new to lua and LÖVE I would recommend you to learn the language (lua) and some basics with LÖVE before looking further into the matter.

Re: Trying to load a Tiled map with STI

Posted: Wed Jan 03, 2018 6:10 pm
by Sonic
I've been actually using that tutorial for my game, thats how I found out about STI. I still got an error on the same line: loader/sti/init.lua:44: attempt to call a nil value, is this one of the new errors that would pop up?

Re: Trying to load a Tiled map with STI

Posted: Wed Jan 03, 2018 6:17 pm
by MadByte
Your line

Code: Select all

local map = setmetatable(love.filesystem.load('st_i/sti/map.lua')(), Map)
seems to don't match up with the original line of the file of the library (newest on github), which is

Code: Select all

map = setmetatable(love.filesystem.load(map)(), Map)
I would say that this is the reason. maybe its a different version or you altered the path of the library (or the line above).
Make sure that there is the right file in your project folder, which should be ../st_i/sti/map.lua if the above line is correct.
If you still got problems feel free to upload your project.

Re: Trying to load a Tiled map with STI

Posted: Wed Jan 03, 2018 6:37 pm
by Sonic
I saw another post where someone added an addition folder to put the original STI file in, the only errors he had was just some typos. Thats why I tried the same thing but with my file names. I guess i'm wrong.

Heres the project: http://www.mediafire.com/folder/i7c4a8brwodf9/game

Re: Trying to load a Tiled map with STI

Posted: Wed Jan 03, 2018 6:41 pm
by MadByte
You can upload files on the forum next time, there is an attachments tab below the (full) text editor box.
If possible create an *.love file as stated here and upload it.
Also your mediafire folder just contains an mp3 song. You might want to double check that :)

Re: Trying to load a Tiled map with STI

Posted: Wed Jan 03, 2018 6:58 pm
by Sonic
I cant send you the whole file containing everything, if you need another file from me just tell me.