Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Mi5KL
Prole
Posts: 4
Joined: Thu Sep 29, 2016 12:22 pm
Location: Nova Scotia, Canada
Contact:

Re: Simple Tiled Implementation - STI v0.16.0.3

Post by Mi5KL »

So I've followed the tutorial you link to in the OP but my player sprite isn't being drawn for some reason, any ideas why this might be? (its also kind of weird to see another Nova Scotian online randomly, small world I guess.)
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.16.0.3

Post by Karai17 »

Slime, one of the main devs of LOVE, is also from NS! :D Where abouts are you?

As for your issue, did you make a draw function for your custom layer?
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Mi5KL
Prole
Posts: 4
Joined: Thu Sep 29, 2016 12:22 pm
Location: Nova Scotia, Canada
Contact:

Re: Simple Tiled Implementation - STI v0.16.0.3

Post by Mi5KL »

I think so? I've pretty much copied the tutorial and the map loads and zooms in on where the player should be but the sprite isn't being drawn.
capture.JPG
capture.JPG (74.93 KiB) Viewed 4373 times
I'm pretty much right in the middle of Dartmouth; and I'm impressed, the only other time you see more Nova Scotians in one random part of the internet is when someone brings up the Halifax explosion.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.16.0.3

Post by Karai17 »

Can you link me your .love file?

I live a couple blocks from the Halifax Shopping Centre. :)
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Mi5KL
Prole
Posts: 4
Joined: Thu Sep 29, 2016 12:22 pm
Location: Nova Scotia, Canada
Contact:

Re: Simple Tiled Implementation - STI v0.16.0.3

Post by Mi5KL »

Yeah here you go, there's a few extra files in there that were just in the folder.
Attachments
GB.love
(18.59 KiB) Downloaded 106 times
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.16.0.3

Post by Karai17 »

Ah! So when you're creating the custom layer, you're keying it to the 8th slot in the table, but you only have 3 keys previously set! Just remove that 8 and it'll put it in the next available slot.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Mi5KL
Prole
Posts: 4
Joined: Thu Sep 29, 2016 12:22 pm
Location: Nova Scotia, Canada
Contact:

Re: Simple Tiled Implementation - STI v0.16.0.3

Post by Mi5KL »

Yup that did the trick, now I can do one of the dozens of other things I can do to make this a game.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.16.0.3

Post by Karai17 »

:D!
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
straydogstrut
Prole
Posts: 4
Joined: Mon Aug 22, 2016 10:12 pm

Re: Simple Tiled Implementation - STI v0.16.0.3

Post by straydogstrut »

EDIT: I believe i've resolved my original problem, but still unsure of correct usage as follows:

I mistakenly thought I wasn't accessing the 'collidable' custom property of the layer when actually the error was being thrown because the two rectangles i'd manually created didn't have a 'collidable' element. Using the Inspect helper was useful to figure out that properties was a table containing the 'collidable' custom property.

It seems using 'collidable' is the only property that will generate collisions for tiles/tile layers exported from Tiled - is this correct?

I could not get it to work with other custom properties on Tile/Layers in Tiled so am creating these other types manually in Lua with the same 'properties' table included (or adding same to the data I grab from a layer object). This seems a bit convoluted so think i'm i'm still misunderstanding.

Updated code as follows:

Code: Select all

love.load()
-- a custom collision object
hotspot = {
      x = 120, 
      y = 90,
      width = 16,
      height = 16,
      properties = { hotspot = 'true'}
   }
   
world:add(hotspot, hotspot.x, hotspot.y, hotspot.height, hotspot.width)

end

love.update(dt)
local playerFilter = function(item, other)
	print(inspect(other.properties))
	
		local kind = other.properties -- store a reference to the 'properties' table

		if kind.collidable then -- 'collidable' property exported from Tiled
			return 'slide'
		elseif kind.hotspot then -- 'hotspot' property set here in main.lua
			return 'cross'
		elseif kind.spring then -- 'spring' property set here in main.lua
			return 'bounce'
		end
		
	end

	-- move the player, obeying collisons
	player.x, player.y, cols, len = world:move(player, player.x, player.y, playerFilter)
end
Original query:
Hi all,

I'm using STI with the Bump plugin for a simple platformer i'm making. Collisions between the player and the world are working fine by default, however when I try to add the playerFIlter variable I run into trouble.

I understand that I need to set a 'type' for each other that can be collided with. If I create a simple box in love.load, I can successfully check for it by name like so:

Code: Select all

function love.load()
solidWall = {
      name = "solidWall",
      x = 32, 
      y = 100,
      width = 32,
      height = 32
   }
   
world:add(solidWall, solidWall.x, solidWall.y, solidWall.height, solidWall.width)
end

function love.update(dt)

player.x, player.y, cols, len = world:move(player, player.x, player.y, playerFilter)

end

function playerFilter(item, other)
    if   other.name   == 'solidWall'  then 
 	return 'slide'
    end
  -- else return nil
end
However, when I try to do similar for the collidable layer from Tiled (a tileLayer with a custom string property 'collidable' = 'true'), I get an error. I can see that the property in Map.lua is shown as 'collidable' so i'm not sure what i'm doing wrong. If I don't include this check, the playerFilter defaults to nil and my tileLayer is not collided with.
attempt to index field 'properties' a nil value

Code: Select all

if other.properties.collidable == 'true'   then 
    return 'slide'
end
I'd be grateful if anyone can shed some light on this, thanks
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.16.0.3

Post by Karai17 »

Hi, sorry for the late response. I'm glad you figured out part of your issue.

So the bump plugin does a search through your Tiled map for a property called "collidable" and if found, translates that data into bump data. There is nothing special about the word "collidable" other than it's what I chose to call the property when I was writing the box2d plugin, and the author of the bump plugin decided to use the same name for compatibility/interchangeability. Furthermore, the collidable property only matters when you are calling map:bump_init. Once you initialize your bump world, that property becomes unimportant. You can add new objects to your STI world and your bump world manually, wihtout needing to use a "collidable" property anywhere.

I don't know much about bump, but if there is more to it than basic collision then you are welcome to expand the plugin.
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: Ahrefs [Bot] and 4 guests