Simple Tiled Implementation - STI v1.2.3.0
-
- Citizen
- Posts: 73
- Joined: Thu May 25, 2017 1:43 pm
Re: Simple Tiled Implementation - STI v0.18.2.1
Stupid question incoming. How do I do that? or Where do I do that?
Re: Simple Tiled Implementation - STI v0.18.2.1
You want to print out all the data in that table to see what's in there, so use the following code at the top of your function.
Code: Select all
for k, v in pairs(other.properties) do
print(k, v)
end
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é
-
- Citizen
- Posts: 73
- Joined: Thu May 25, 2017 1:43 pm
Re: Simple Tiled Implementation - STI v0.18.2.1
Printing out nothing except "Player true".
Re: Simple Tiled Implementation - STI v0.18.2.1
So there is no "collidable" property. Make sure you're passing the right properties table into your function.
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é
-
- Citizen
- Posts: 73
- Joined: Thu May 25, 2017 1:43 pm
Re: Simple Tiled Implementation - STI v0.18.2.1
This is my code
Am I missing something here?
Code: Select all
filter = function(item, other)
for k,v in pairs(other.properties) do
print(k,v)
end
if other.properties.collidable then
return "slide"
elseif other.properties.Player then
return "cross"
end
end
P.x, P.y, Cols, len = world:move(P,P.x,P.y,filter)
Re: Simple Tiled Implementation - STI v0.18.2.1
Yes, but it seems like the "other" variable you are passing in to your function is not correct. Do you have a .love file I can look at?
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é
-
- Citizen
- Posts: 73
- Joined: Thu May 25, 2017 1:43 pm
Re: Simple Tiled Implementation - STI v0.18.2.1
Here it is, the code is on the player file. Im sorry if my code is a bit messy
Re: Simple Tiled Implementation - STI v0.18.2.1
First off, I have a couple pointers.
1) Lua's module system isn't quite the same as system paths so when you require a module, you should use "." instead of "/". This helps with caching and other such things.
2) Your code seems to have both spaces and tabs for indenting. It doesn't really matter which you choose (I prefer tabs), but you should be consistant with it, it'll make your code a lot easier to read.
3) Avoid using global variables if you can. Declaring globals all over the place can make it difficult to trace your code and see where things are coming from, and you can get into a problem where you might accidentally assign a value to a variable you already declared in another file which could corrupt your data.
4) I'm not sure which editor you use, but most editors (VS Code, Atom, Sublime) shoudl have an extension for "lua-check". lua-check is a real time lua syntax linter and error checker that can be installed via LuaRocks which could also help you clean up your code. I use it quite heavily and it definitely helps me write cleaner code.
Now, regarding your actual issue, I can't seem to track down the problem. It looks like you are passing that filter into your bump world but the "other" variable's properties are empty as far as I can tell. This suggests to me that the data you are checking against is not the data you are expecting. What exactly are you trying to accomplish here, anyway?
1) Lua's module system isn't quite the same as system paths so when you require a module, you should use "." instead of "/". This helps with caching and other such things.
Code: Select all
sti = "libs.sti"
3) Avoid using global variables if you can. Declaring globals all over the place can make it difficult to trace your code and see where things are coming from, and you can get into a problem where you might accidentally assign a value to a variable you already declared in another file which could corrupt your data.
4) I'm not sure which editor you use, but most editors (VS Code, Atom, Sublime) shoudl have an extension for "lua-check". lua-check is a real time lua syntax linter and error checker that can be installed via LuaRocks which could also help you clean up your code. I use it quite heavily and it definitely helps me write cleaner code.
Now, regarding your actual issue, I can't seem to track down the problem. It looks like you are passing that filter into your bump world but the "other" variable's properties are empty as far as I can tell. This suggests to me that the data you are checking against is not the data you are expecting. What exactly are you trying to accomplish here, anyway?
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é
-
- Citizen
- Posts: 73
- Joined: Thu May 25, 2017 1:43 pm
Re: Simple Tiled Implementation - STI v0.18.2.1
(The IDE that Im using is zerobrane) What Im trying to accomplish is that theres gonna be 3 parts of the player, that wont collide with each other but collides with walls, there also gonna be gates which the 3 parts of the player can go through depending on there color. Thanks for the pointers!
Re: Simple Tiled Implementation - STI v0.18.2.1
I think you need to examine your data. When I pairs through other.properties, it is empty. I don't really know what else I can say other than to examine your data and make sure you're passing in what you think you are.
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: No registered users and 3 guests