Trying to load a Tiled map with STI

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Sonic
Prole
Posts: 11
Joined: Tue Jan 02, 2018 6:25 pm
Contact:

Trying to load a Tiled map with STI

Post 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!
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Trying to load a Tiled map with STI

Post by zorg »

You're missing the quote marks, that should be a string.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Sonic
Prole
Posts: 11
Joined: Tue Jan 02, 2018 6:25 pm
Contact:

Re: Trying to load a Tiled map with STI

Post by Sonic »

where do i put them?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Trying to load a Tiled map with STI

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Trying to load a Tiled map with STI

Post 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.
Sonic
Prole
Posts: 11
Joined: Tue Jan 02, 2018 6:25 pm
Contact:

Re: Trying to load a Tiled map with STI

Post 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?
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Trying to load a Tiled map with STI

Post 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.
Sonic
Prole
Posts: 11
Joined: Tue Jan 02, 2018 6:25 pm
Contact:

Re: Trying to load a Tiled map with STI

Post 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
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Trying to load a Tiled map with STI

Post 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 :)
Sonic
Prole
Posts: 11
Joined: Tue Jan 02, 2018 6:25 pm
Contact:

Re: Trying to load a Tiled map with STI

Post by Sonic »

I cant send you the whole file containing everything, if you need another file from me just tell me.
Attachments
main.lua
(965 Bytes) Downloaded 121 times
init.lua
(36.18 KiB) Downloaded 132 times
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests