Page 76 of 92

Re: Simple Tiled Implementation - STI v0.18.2.1

Posted: Sat Apr 28, 2018 3:29 pm
by KyleFlores1014
Stupid question incoming. How do I do that? or Where do I do that?

Re: Simple Tiled Implementation - STI v0.18.2.1

Posted: Sun Apr 29, 2018 8:27 am
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

Re: Simple Tiled Implementation - STI v0.18.2.1

Posted: Sun Apr 29, 2018 11:38 am
by KyleFlores1014
Printing out nothing except "Player true".

Re: Simple Tiled Implementation - STI v0.18.2.1

Posted: Sun Apr 29, 2018 11:40 am
by Karai17
So there is no "collidable" property. Make sure you're passing the right properties table into your function.

Re: Simple Tiled Implementation - STI v0.18.2.1

Posted: Sun Apr 29, 2018 11:43 am
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?

Re: Simple Tiled Implementation - STI v0.18.2.1

Posted: Sun Apr 29, 2018 11:48 am
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?

Re: Simple Tiled Implementation - STI v0.18.2.1

Posted: Sun Apr 29, 2018 1:38 pm
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 370 times

Re: Simple Tiled Implementation - STI v0.18.2.1

Posted: Sun Apr 29, 2018 5:06 pm
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?

Re: Simple Tiled Implementation - STI v0.18.2.1

Posted: Sun Apr 29, 2018 5:39 pm
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!

Re: Simple Tiled Implementation - STI v0.18.2.1

Posted: Sun Apr 29, 2018 5:43 pm
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.