Awesome, happy it worked out!dpkgluci wrote: ↑Thu Aug 01, 2024 8:21 pm I printed it but got nil, and the ground tile above the spike is impossible since the player is standing on top of a spike, it doesnt touch any ground tiles
But I resolved this! I used the type (class) property! it's not a custom property, but you can put strings on it, so I marked all my spike boxes with spike and all my ground ones with ground and now with this filterCode: Select all
local collidablefilter = function(_, other) if other.type == "spike" then return "cross" elseif other.type == "ending" then return "slide" elseif other.type == "coin" then return "cross" else return "slide" end end
Need help with Bump.lua Filters
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Need help with Bump.lua Filters
Re: Need help with Bump.lua Filters
Hi again! I am having a lot of trouble figuring out how to call a function when certain collision type occurrs, I am trying to call the function death() (which I already coded and works) when the player touches the spikes. how is it made most of the time?
-
- Party member
- Posts: 559
- Joined: Wed Oct 05, 2016 11:53 am
Re: Need help with Bump.lua Filters
If you consider my first post in this thread, when running world:move on your player, you'd do:
If it's another object (like a bullet) colliding with the player, you can do:
Basically, let world:move resolve, and then do the appropriate things when looping through the collisions (dying, taking damage, touching a goal, touching collectibles, etc).
Code: Select all
local newX, newY, cols, len = world:move (player, targetX, targetY, playerFilter)
for i = 1, len do
local other = cols[i].other
if other.type == "isPlayerKillingCollision" then
death()
return
end
end
Code: Select all
for i = 1, len do
local other = cols[i].other
if other.type == "isPlayer" then
other:death() -- assuming you can access the death function on the player object like this
return
end
end
Re: Need help with Bump.lua Filters
The code crashes, I don't know what to do
the for seems to be malformed, love says
the for seems to be malformed, love says
Code: Select all
Error: Syntax error: assets/scripts/player.lua:133: 'in' expected near 'do'
Re: Need help with Bump.lua Filters
Oh I just named some variables differently. Thanks mrfariator!!
Who is online
Users browsing this forum: No registered users and 3 guests