STI with Bump plugin

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.
knuxyl
Citizen
Posts: 52
Joined: Sat Aug 13, 2016 4:40 am

STI with Bump plugin

Post by knuxyl »

I am having a hard time understanding how to use the Bump plugin with Simple Tiled Implementation. The documentation is lacking.

I looked through the code of plugins/bump.lua and it seems to check for a custom property of tiles or objects called "collidable". if that is true, how do I interact with it? One of the other plugins is box2d. Is that another collision library I could use and which one would be best? Thanks!
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: STI with Bump plugin

Post by Sir_Silver »

In Tiled, you can set a custom property, specifically a bool, for either a tile or an entire layer called "collidable". If it is set to true, it will be added to the bump world, and will have "normal" collisions set up for you. I recommend using bump plugin because it's the only one I'm familiar with at all. =)
User avatar
DanielPower
Citizen
Posts: 50
Joined: Wed Apr 29, 2015 5:28 pm

Re: STI with Bump plugin

Post by DanielPower »

If you want to make a specific tile collidable, click the tile in your tileset pane, and then under the properties pane on the left, click the + icon, and create a new boolean property called collideable. Set this to true.

Once you've added collidable tiles in your tiled map, you need to load them in your game.

Code: Select all


local world = bump.newWorld()
local map = sti('mapfile.lua', {"bump"}) -- This loads the map file, and loads the bump plugin for STI
map:bump_init(world) -- This initializes the bump plugin, and loads all of your collidable tiles
That's it! Your world should no contain collidables for each of the collidable tiles in your Tiled map.
User avatar
DanielPower
Citizen
Posts: 50
Joined: Wed Apr 29, 2015 5:28 pm

Re: STI with Bump plugin

Post by DanielPower »

If you need more complicated collisions, for example, using two collision boxes for a corner wall, or a smaller collision box for a thin wall, you can open the Tile Collision Editor in Tiled, and create collision boxes for an individual tile. If these collision boxes exist, STI's bump plugin will load these boxes instead of just one for the entire tile.

For this editor, you may need to name each box something specific. When I originally committed this feature, you'd have to call each box "colBox", but I believe that's since been changed to "collideable" or something similar. Check out the Bump project on Github for specifics.
knuxyl
Citizen
Posts: 52
Joined: Sat Aug 13, 2016 4:40 am

Re: STI with Bump plugin

Post by knuxyl »

Thank yall very much. Is this all that is needed to interact with player.x and player.y?
knuxyl
Citizen
Posts: 52
Joined: Sat Aug 13, 2016 4:40 am

Re: STI with Bump plugin

Post by knuxyl »

DanielPower wrote: Fri Mar 17, 2017 11:05 am If you want to make a specific tile collidable, click the tile in your tileset pane, and then under the properties pane on the left, click the + icon, and create a new boolean property called collideable. Set this to true.

Once you've added collidable tiles in your tiled map, you need to load them in your game.

Code: Select all


local world = bump.newWorld()
local map = sti('mapfile.lua', {"bump"}) -- This loads the map file, and loads the bump plugin for STI
map:bump_init(world) -- This initializes the bump plugin, and loads all of your collidable tiles
That's it! Your world should no contain collidables for each of the collidable tiles in your Tiled map.
I tried the code above and it doesn't work. when I do the first line I get "global bump (a nil value)", like the plugin isn't being loaded. I'm even trying to call it after setting the map variable. I'm getting error after error trying to fix the code. I don't know what to do to get it to work.
User avatar
DanielPower
Citizen
Posts: 50
Joined: Wed Apr 29, 2015 5:28 pm

Re: STI with Bump plugin

Post by DanielPower »

Well, do you have the bump library loaded? You'll need to get bump.lua, put it into your game's directory, and load it into your game using

Code: Select all

local bump = require('bump')
You can't use STI's bump plugin unless you have bump loaded.
knuxyl
Citizen
Posts: 52
Joined: Sat Aug 13, 2016 4:40 am

Re: STI with Bump plugin

Post by knuxyl »

DanielPower wrote: Fri Mar 17, 2017 11:05 am If you want to make a specific tile collidable, click the tile in your tileset pane, and then under the properties pane on the left, click the + icon, and create a new boolean property called collideable. Set this to true.

Once you've added collidable tiles in your tiled map, you need to load them in your game.

Code: Select all


local world = bump.newWorld()
local map = sti('mapfile.lua', {"bump"}) -- This loads the map file, and loads the bump plugin for STI
map:bump_init(world) -- This initializes the bump plugin, and loads all of your collidable tiles
That's it! Your world should no contain collidables for each of the collidable tiles in your Tiled map.
So I need to know what kind of data should go in "bump_init(map, world)". I'm assuming map should be the map file that sti is loading, but I don't know what world is, especially since there isn't a bump.newWorld() function present. This is where it is giving me an error, Attempt to call method 'add' (a nil value) on this line in bump.lua

line 58

Code: Select all

world:add(t, t.x, t.y, t.width, t.height)
which is weird because another world:add is at line 41 and it doesn't give an error there.
knuxyl
Citizen
Posts: 52
Joined: Sat Aug 13, 2016 4:40 am

Re: STI with Bump plugin

Post by knuxyl »

DanielPower wrote: Fri Mar 17, 2017 4:27 pm Well, do you have the bump library loaded? You'll need to get bump.lua, put it into your game's directory, and load it into your game using

Code: Select all

local bump = require('bump')
You can't use STI's bump plugin unless you have bump loaded.
lol i thought the bump plugin was the full library. thanks ill try that
knuxyl
Citizen
Posts: 52
Joined: Sat Aug 13, 2016 4:40 am

Re: STI with Bump plugin

Post by knuxyl »

DanielPower wrote: Fri Mar 17, 2017 11:05 am If you want to make a specific tile collidable, click the tile in your tileset pane, and then under the properties pane on the left, click the + icon, and create a new boolean property called collideable. Set this to true.

Once you've added collidable tiles in your tiled map, you need to load them in your game.

Code: Select all


local world = bump.newWorld()
local map = sti('mapfile.lua', {"bump"}) -- This loads the map file, and loads the bump plugin for STI
map:bump_init(world) -- This initializes the bump plugin, and loads all of your collidable tiles
That's it! Your world should no contain collidables for each of the collidable tiles in your Tiled map.
I got it working with the bump tiles being drawn with map:bump_draw(world) but I'm not sure how to make player.x and player.y interact with it
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 7 guests