Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
KyleFlores1014
Citizen
Posts: 73
Joined: Thu May 25, 2017 1:43 pm

Re: Simple Tiled Implementation - STI v0.18.2.1

Post by KyleFlores1014 »

Stupid question incoming. How do I do that? or Where do I do that?
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.18.2.1

Post by Karai17 »

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é
KyleFlores1014
Citizen
Posts: 73
Joined: Thu May 25, 2017 1:43 pm

Re: Simple Tiled Implementation - STI v0.18.2.1

Post by KyleFlores1014 »

Printing out nothing except "Player true".
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.18.2.1

Post by Karai17 »

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é
KyleFlores1014
Citizen
Posts: 73
Joined: Thu May 25, 2017 1:43 pm

Re: Simple Tiled Implementation - STI v0.18.2.1

Post by KyleFlores1014 »

This is my code

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)
Am I missing something here?
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.18.2.1

Post by Karai17 »

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é
KyleFlores1014
Citizen
Posts: 73
Joined: Thu May 25, 2017 1:43 pm

Re: Simple Tiled Implementation - STI v0.18.2.1

Post by KyleFlores1014 »

Here it is, the code is on the player file. Im sorry if my code is a bit messy
game.love
(6.63 MiB) Downloaded 496 times
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.18.2.1

Post by Karai17 »

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.

Code: Select all

sti = "libs.sti"
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?
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
KyleFlores1014
Citizen
Posts: 73
Joined: Thu May 25, 2017 1:43 pm

Re: Simple Tiled Implementation - STI v0.18.2.1

Post by KyleFlores1014 »

(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!
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.18.2.1

Post by Karai17 »

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é
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests