Need help with Bump.lua Filters

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
cip
Prole
Posts: 15
Joined: Wed Jun 07, 2023 5:44 pm

Re: Need help with Bump.lua Filters

Post by cip »

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 filter

Code: 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
Awesome, happy it worked out!
dpkgluci
Prole
Posts: 8
Joined: Wed Jul 31, 2024 10:05 pm

Re: Need help with Bump.lua Filters

Post by dpkgluci »

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?
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: Need help with Bump.lua Filters

Post by MrFariator »

If you consider my first post in this thread, when running world:move on your player, you'd do:

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
If it's another object (like a bullet) colliding with the player, you can do:

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
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).
dpkgluci
Prole
Posts: 8
Joined: Wed Jul 31, 2024 10:05 pm

Re: Need help with Bump.lua Filters

Post by dpkgluci »

The code crashes, I don't know what to do

the for seems to be malformed, love says

Code: Select all

Error: Syntax error: assets/scripts/player.lua:133: 'in' expected near 'do'
dpkgluci
Prole
Posts: 8
Joined: Wed Jul 31, 2024 10:05 pm

Re: Need help with Bump.lua Filters

Post by dpkgluci »

Oh I just named some variables differently. Thanks mrfariator!!
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests