Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.9.3

Post by Karai17 »

I've updated STI to return "false" instead of "nil" for tile positions where there is no tile, so that should at least fix some issues.

In your particular case, I also needed to add a check for the mouse that it was within bounds of the map. Check the attached file, it has the updated STI and it works well. :)
Attachments
test-sti.love
(20.09 KiB) Downloaded 182 times
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.9.2

Post by Karai17 »

ds84182 wrote:No, I managed to fix the problem though. framework.clear is called but it doesn't clear the actual canvas, instead it was clearing the screen.
I submitted a real fix to this issue.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
DmL
Prole
Posts: 18
Joined: Fri Nov 21, 2014 9:09 am

Re: Simple Tiled Implementation - STI v0.9.4

Post by DmL »

I only read over the last few posts on the topic, so if this is addressed somewhere, I do apologize.
I have had a couple of problems with the codebase, which I have worked around, but would like some clarification on.

First:
You mentioned that you set empty tiles to false in the newest version. The older version works correctly for me but this new change leaves me with:
"map.lua : line 296 - attempt to index local 'tile' (a boolean value)"
Changing line 524 (approx.) in map.lua from:

Code: Select all

map[y][x] = false
to:

Code: Select all

map[y][x] = nil
gets it running again. Can you help me understand this?

Secondly, on line approx. 300 in the collidable layer property of the calculateObjectPosition(object, tile) method of the Map:initWorldCollision(world) function, changing:

Code: Select all

x		= x * self.width + tile.offset.x,
y		= y * self.height + tile.offset.y,
to:

Code: Select all

x		= x * tile.width + tile.offset.x,
y		= y * tile.height + tile.offset.y,
fixes a huge gap (200 pixels for a 24x24 tile) between collision objects.

Anyway, this is mostly academic. Thank you so much for your library, it has helped me tremendously, and it was easy enough to add userdata to the tiles for collision callbacks, etc, although I am just figuring all this out. : )
Xianbaum
Prole
Posts: 2
Joined: Thu Dec 11, 2014 5:40 pm

Re: Simple Tiled Implementation - STI v0.9.4

Post by Xianbaum »

Hey, I'm trying to learn how to use STI and so I tried compiling with the initWorldCollision example and it gives an error.

I tried exporting from Tiled 10.2 initially and then Tiled 10.1. It is a single-layer 100x100 map, tiles 16x16, with certain tiles having the property collidable=true I'm using the latest version.

Here is the code I'm using to compile

Code: Select all

local sti = require "sti"

function love.load()
    -- Grab window size
    windowWidth = love.graphics.getWidth()
    windowHeight = love.graphics.getHeight()

    -- Set world meter size (in pixels)
    love.physics.setMeter(16)

    -- Load a map exported to Lua from Tiled
    map = sti.new("assets/maps/map1")

    -- Prepare physics world (horizontal and vertical gravity)
    world = love.physics.newWorld(0, 0)

    -- Prepare collision objects
    collision = map:initWorldCollision(world)
end
And here is the error:

Code: Select all

Error: sti/map.lua:270: bad argument #1 to 'ipairs' (table expected, got nil)
stack traceback:
	[C]: in function 'ipairs'
	sti/map.lua:270: in function 'initWorldCollision'
	main.lua:19: in function 'load'
	[string "boot.lua"]:407: in function <[string "boot.lua"]:399>
	[C]: in function 'xpcall'
Xianbaum
Prole
Posts: 2
Joined: Thu Dec 11, 2014 5:40 pm

Re: Simple Tiled Implementation - STI v0.9.4

Post by Xianbaum »

Hey guys, in regards to the problem above, changing line 269 from

Code: Select all

			elseif tile.properties.collidable == "true" then
to

Code: Select all

			elseif tile.properties.collidable == "true" and self.tileInstances[gid]~=nil then
fixes this. Turns out, the reason it's nil is simply because if there a tile with the property "collidable=true" that is not placed on the map, then self.tileInstances[gid] will be nil for that tile.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.9.4

Post by Karai17 »

Cool, I'll be sure to fix this soon!
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
CrackedP0t
Citizen
Posts: 69
Joined: Wed May 07, 2014 4:01 am
Contact:

Re: Simple Tiled Implementation - STI v0.9.4

Post by CrackedP0t »

Two questions: How would I draw the map to the entire screen regardless of its resolution, and how easy would implementing bump.lua alongside STI be?
/人 ◕‿‿◕ 人\
Here, have an umlaut. Ö
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.9.4

Post by Karai17 »

Do you mean to scale the map up or down to fit the screen, or just draw everything, ignoring culling?

I have not used bump.lua, give it a go and report back.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
CrackedP0t
Citizen
Posts: 69
Joined: Wed May 07, 2014 4:01 am
Contact:

Re: Simple Tiled Implementation - STI v0.9.4

Post by CrackedP0t »

Scaling it to fit the screen

bump.lua integration shouldn't be too hard
/人 ◕‿‿◕ 人\
Here, have an umlaut. Ö
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.9.4

Post by Karai17 »

Local scale = window_height / (map.height * map.tileheight)
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: No registered users and 4 guests