STI help

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.
User avatar
superboySR
Prole
Posts: 24
Joined: Mon Feb 24, 2014 8:54 pm
Contact:

STI help

Post by superboySR »

So I'm trying to load a map in STI. I created a map.lua file and at the top I wrote local sti = require "amin.sti" because my init.lua file is located in sti and sti is located in the folder amin. But it is still not working? Help :cry:
Attachments
love2dgame.love
(22.49 KiB) Downloaded 138 times
"It's all about the game." - VGHS
User avatar
SneakySnake
Citizen
Posts: 94
Joined: Fri May 31, 2013 2:01 pm
Contact:

Re: STI help

Post by SneakySnake »

You need to understand what gets executed and when.

main.lua is the only file that gets executed by LÖVE (besides conf.lua).
If you want map.lua to run, you must require() it (or execute it in some other way).

This brings us to the next point.
Let's say you now require "map" at the top of main.lua.
The love.load() defined in map.lua will not get executed.
Why?
In Lua, if you define a function with the same name as an existing function, the new definition will override the existing function.
In this case, love.load() defined in main.lua will override love.load() defined in map.lua.
So how would you define a setup function for the map module?
One solution would be to create a map.load() function that you would explicitly call when you want to initialize the map module.
User avatar
superboySR
Prole
Posts: 24
Joined: Mon Feb 24, 2014 8:54 pm
Contact:

Re: STI help

Post by superboySR »

SneakySnake wrote:You need to understand what gets executed and when.

main.lua is the only file that gets executed by LÖVE (besides conf.lua).
If you want map.lua to run, you must require() it (or execute it in some other way).

This brings us to the next point.
Let's say you now require "map" at the top of main.lua.
The love.load() defined in map.lua will not get executed.
Why?
In Lua, if you define a function with the same name as an existing function, the new definition will override the existing function.
In this case, love.load() defined in main.lua will override love.load() defined in map.lua.
So how would you define a setup function for the map module?
One solution would be to create a map.load() function that you would explicitly call when you want to initialize the map module.
Thanks for that! But unfortunately I changed the map.lua love.load() into map.load() and I did require "map" in main.lua and it has the same problem :crazy:
"It's all about the game." - VGHS
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: STI help

Post by Karai17 »

You need to call map.load() from inside love.load().

Code: Select all

local map = require "map"

function love.load()
    map.load()
end
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
superboySR
Prole
Posts: 24
Joined: Mon Feb 24, 2014 8:54 pm
Contact:

Re: STI help

Post by superboySR »

Karai17 wrote:You need to call map.load() from inside love.load().

Code: Select all

local map = require "map"

function love.load()
    map.load()
end
I did that but same error. ;( :cry:
"It's all about the game." - VGHS
User avatar
superboySR
Prole
Posts: 24
Joined: Mon Feb 24, 2014 8:54 pm
Contact:

Re: STI help

Post by superboySR »

It seems my code still isn't working :cry: Can someone post an example? That would mean a lot :nyu:
"It's all about the game." - VGHS
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: STI help

Post by Karai17 »

I moved your stuff out of map.lua because it served no purpose there. STI now loads, but you didn't include a map file with it so you will need to put that back in.
Attachments
love2dgame.love
(22.72 KiB) Downloaded 131 times
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
superboySR
Prole
Posts: 24
Joined: Mon Feb 24, 2014 8:54 pm
Contact:

Re: STI help

Post by superboySR »

Karai17 wrote:I moved your stuff out of map.lua because it served no purpose there. STI now loads, but you didn't include a map file with it so you will need to put that back in.
Thanks! :awesome: I will carefully look at how it loads :ultrahappy:
"It's all about the game." - VGHS
User avatar
superboySR
Prole
Posts: 24
Joined: Mon Feb 24, 2014 8:54 pm
Contact:

Re: STI help

Post by superboySR »

Karai17 wrote:I moved your stuff out of map.lua because it served no purpose there. STI now loads, but you didn't include a map file with it so you will need to put that back in.
I'm not sure why it says file not found because it is located in amin/mapsa/map01 ? I think it has something to do with that it says this: file not found: amin/mapsa/map01.lua.
"It's all about the game." - VGHS
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: STI help

Post by Karai17 »

Because that file doesn't exist.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 5 guests