Either my tiled STI is broken or im an idiot
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Either my tiled STI is broken or im an idiot
For the record, this has been resolved. powerII was originally dumping the contents of STI directly into his root folder, so requiring "sti" was not possible. The setfenv issue occurred because requiring init.lua causes sti to behave oddly. It is important to leave sti and any other module that has an init.lua within a folder, and just require the folder.
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é
Re: Either my tiled STI is broken or im an idiot
Haven't tried yet, but for future and while on this subject, does this mean that one can't use: require "sti.init"? Or move sti/init.lua to sti.lua and still do: require "sti"?Karai17 wrote:It is important to leave sti and any other module that has an init.lua within a folder, and just require the folder.
I ask because support by default for ?/init.lua in the path has been removed in Lua itself, even if it's still kept in love2d, so I'm trying to avoid depending on it.
- slime
- Solid Snayke
- Posts: 3181
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Either my tiled STI is broken or im an idiot
init.lua can't be renamed without modifying STI's code I believe, but you should be able to do require("sti.init"): https://github.com/karai17/Simple-Tiled ... it.lua#L15pgimeno wrote:Haven't tried yet, but for future and while on this subject, does this mean that one can't use: require "sti.init"? Or move sti/init.lua to sti.lua and still do: require "sti"?
I believe package.path always looked for ?/init.lua in the system directories it looks in, but "./?/init.lua" (i.e. looking for init.lua relative to the current working directory) was actually added to package.path in Lua 5.3 ( http://www.lua.org/source/5.2/luaconf.h ... TH_DEFAULT versus http://www.lua.org/source/5.3/luaconf.h ... TH_DEFAULT ).pgimeno wrote:I ask because support by default for ?/init.lua in the path has been removed in Lua itself, even if it's still kept in love2d, so I'm trying to avoid depending on it.
Also keep in mind that LÖVE doesn't use package.path at all when looking for files in love.filesystem paths when require is used. LÖVE adds its own searcher to the package.loaders table (which require iterates over), and [wiki]love.filesystem.setRequirePath[/wiki] can be used in a similar manner to package.path.
A function (provided by Lua itself) which looks through package.path is also in the package.loaders table separately.
Re: Either my tiled STI is broken or im an idiot
You cannot remove init.lua or rename it to sti.lua. The file relies on another file within, map.lua, and the plugin files (optionally). The path finding in STI relies on the current file structure.
I highly doubt Lua would remove such a prominent feature and completely disrupt their whole ecosystem on a whim. ?/init.lua has been around for quite a long time, and very many modules are designed with that in mind. Namely anything that is larger than a single file.
I highly doubt Lua would remove such a prominent feature and completely disrupt their whole ecosystem on a whim. ?/init.lua has been around for quite a long time, and very many modules are designed with that in mind. Namely anything that is larger than a single file.
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é
Re: Either my tiled STI is broken or im an idiot
With my apologies in advance for the slight topic drift:
@slime:
The arguments in that post and the two linked posts sounded reasonable and I thought that it was a good policy to avoid depending on ./?/init.lua to be in the path.
@Karai17:
such that 'require "sti"' would work even if ./?/init.lua is not in the path.
Running: 'lua main.lua' results in:
while running 'love .' works without problems.
@slime:
Yes, that's what I meant. I must have misunderstood this post, then: http://lua-users.org/lists/lua-l/2009-04/msg00389.html and since it wasn't present in my Lua 5.1 and it's quite old, I assumed it was present before and removed.slime wrote:I believe package.path always looked for ?/init.lua in the system directories it looks in, but "./?/init.lua" (i.e. looking for init.lua relative to the current working directory) was actually added to package.path in Lua 5.3 ( http://www.lua.org/source/5.2/luaconf.h ... TH_DEFAULT versus http://www.lua.org/source/5.3/luaconf.h ... TH_DEFAULT ).
The arguments in that post and the two linked posts sounded reasonable and I thought that it was a good policy to avoid depending on ./?/init.lua to be in the path.
@Karai17:
Sorry, that's not what I was suggesting. I was suggesting to move sti/init.lua to sti.lua, such that the tree would look like:Karai17 wrote:You cannot remove init.lua or rename it to sti.lua.
Code: Select all
sti.lua (old sti/init.lua)
sti/map.lua
sti/plugins/box2d.lua
sti/plugins/bump.lua
Well, in Linux command line (Lua 5.1):Karai17 wrote:I highly doubt Lua would remove such a prominent feature and completely disrupt their whole ecosystem on a whim. ?/init.lua has been around for quite a long time, and very many modules are designed with that in mind. Namely anything that is larger than a single file.
Code: Select all
mkdir x
> x/init.lua
echo 'require "x"' > main.lua
Code: Select all
$ lua main.lua
lua: main.lua:1: module 'x' not found:
no field package.preload['x']
no file './x.lua'
no file '/usr/local/share/lua/5.1/x.lua'
no file '/usr/local/share/lua/5.1/x/init.lua'
no file '/usr/local/lib/lua/5.1/x.lua'
no file '/usr/local/lib/lua/5.1/x/init.lua'
no file '/usr/share/lua/5.1/x.lua'
no file '/usr/share/lua/5.1/x/init.lua'
no file './x.so'
no file '/usr/local/lib/lua/5.1/x.so'
no file '/usr/lib/i386-linux-gnu/lua/5.1/x.so'
no file '/usr/lib/lua/5.1/x.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
main.lua:1: in main chunk
[C]: ?
- slime
- Solid Snayke
- Posts: 3181
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Either my tiled STI is broken or im an idiot
As I demonstrated above, ".?/init.lua" is simply missing from the default package.path in Lua versions prior to 5.3 (it was added in 5.3). It does look for init.lua in its search paths outside of the current working directory though.pgimeno wrote:Well, in Linux command line (Lua 5.1):
The package.path on my Lua 5.1 interpreter is this:
Code: Select all
./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua
Who is online
Users browsing this forum: No registered users and 6 guests