Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
Sarcose
Prole
Posts: 48
Joined: Wed Jul 08, 2015 12:09 am

Re: Simple Tiled Implementation - STI v1.2.3.0

Post by Sarcose »

Hi! I'm not sure if this question has been asked previously but if I have an object layer with tiles indicating entities (for visibility), is it possible to remove or hide those tiles after the entities have been loaded? Looking through the exported raw lua of the map, I can see these are contained in an "objectgroup" layer alongside other objects like points and rectangles (which can be toggled visible or not visible as expected), yet their draw function does not seem to be related to those. Replacing the layer draw callback or even removing them from layer.objects doesn't seem to do anything to stop them from being drawn.

e.g. say I have an object layer foo with tile object bar, and ingame I use it to instantiate "bar_thing" and want to now remove or hide bar from foo.

Are they drawn to a permanent canvas somewhere or something? I can't seem to find them anywhere in the map generated by STI - dumping the map.layer[foo].objects table, and the map.objects table, allows me to locate bar, but dumping the map.tiles table does not provide any identifying info.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v1.2.3.0

Post by Karai17 »

There is no permanent canvas or the likes. Are you using collisions at all? Perhaps they are being added to your bump/box2d world and then they are being drawn using those plugins' draw calls (usually only used for debugging)?
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Sarcose
Prole
Posts: 48
Joined: Wed Jul 08, 2015 12:09 am

Re: Simple Tiled Implementation - STI v1.2.3.0

Post by Sarcose »

Karai17 wrote: Sun Jul 10, 2022 11:45 pm There is no permanent canvas or the likes. Are you using collisions at all? Perhaps they are being added to your bump/box2d world and then they are being drawn using those plugins' draw calls (usually only used for debugging)?
I just was coming back to edit/post that I figured it out. It was the SpriteBatches (which, I have to realize, was talked about JUST the page before, sorry about that). Thanks for the rapid response!

For anyone interested my code for "disappearing" the tile items in question is as follows. Remaking the SpriteBatch won't be necessary in my case as individual scenes will be relatively small anyway, so this is a quicker solution for me:

Code: Select all

	
--somewhere above; everytime I grab the item info from the object in question I added object.delete = true
--L = layer
--self.activemap is the map instance created by STI
local newobjectlist = {}	
for i=1,#L.objects do
	local obj = L.objects[i]
	if not L.objects[i].delete then
		newobjectlist[#newobjectlist+1] = L.objects[i] 
	else
		local batch = self.activemap.tileInstances[obj.gid][1].batch --pertinent info for tileInstances is hardcoded to [1]
		local id = self.activemap.tileInstances[obj.gid][1].id
		batch:set(id, 0, 0, 0, 0, 0)	  --set the sprite in the batch to have equal vertices, causing the GPU to not render it
	end
end
L.objects = newobjectlist --compress the layer object list to remove those object instances
Anyway, thanks for the amazing library! I took a weekend to implement it and went from struggling with a handspun map editor to almost completely done Tiled mapping with multiple layers, collision, triggers and animations! Like the amount of progress I made in the past few days using STI has been mindblowing compared to my prior pace.
lvulcanis
Prole
Posts: 1
Joined: Fri Oct 18, 2019 3:51 pm

Re: Simple Tiled Implementation - STI v1.2.3.0

Post by lvulcanis »

pauljessup wrote: Tue Apr 05, 2022 1:57 pm Okay, I got a response- what you need to do now in version 1.8 is go to preferences, click on "Embed Tilesets on Export". It doesn't allow you to embed a tileset directly in the map anymore in the editor, it's only done on export.
THANK YOU SO MUCH FOR THIS! I've just started working with STI and was stuck with this error but your tip helped me making my map to work!
OtherBlue
Prole
Posts: 1
Joined: Sun Aug 21, 2022 4:06 pm

Re: Simple Tiled Implementation - STI v1.2.3.0

Post by OtherBlue »

pauljessup wrote: Tue Apr 05, 2022 1:57 pm Okay, I got a response- what you need to do now in version 1.8 is go to preferences, click on "Embed Tilesets on Export". It doesn't allow you to embed a tileset directly in the map anymore in the editor, it's only done on export.
thanks for this

saved a newbie's life
RealCrayfish
Prole
Posts: 3
Joined: Thu Sep 01, 2022 7:48 pm
Location: Somewhere in the Bri'ish lands
Contact:

Re: Simple Tiled Implementation - STI v1.2.3.0

Post by RealCrayfish »

I've been trying to load my map using STI however when I run Map:draw() the map is missing 2 columns on the right and 1 row on the bottom (see image). How would I go around fixing this?

Extra Info, .love file and Image linked in this thread: viewtopic.php?f=4&t=93712
User avatar
Nawias
Prole
Posts: 9
Joined: Sun Apr 10, 2022 4:13 pm
Location: Poland

Re: Simple Tiled Implementation - STI v1.2.3.0

Post by Nawias »

Does it work with Tiled 1.9? Or are you still recommending Tiled 1.2.x? (that's what I read on the repo)
Quick edit: I know it works with 1.9, I made a basic map and compiled it, just I want to know if there's some features of Tiled that are not supported here and I'm better off with 1.2
User avatar
coz
Prole
Posts: 4
Joined: Sat Sep 10, 2022 10:48 pm

Re: Simple Tiled Implementation - STI v1.2.3.0

Post by coz »

Nawias wrote: Wed Sep 14, 2022 7:06 pm Does it work with Tiled 1.9? Or are you still recommending Tiled 1.2.x? (that's what I read on the repo)
Quick edit: I know it works with 1.9, I made a basic map and compiled it, just I want to know if there's some features of Tiled that are not supported here and I'm better off with 1.2
I don't think the author is monitoring this thread; I'd advise to contact him though other means.

That being said, I am using Tiled 1.2 just in case, but I didn't really have issues with 1.9
User avatar
coz
Prole
Posts: 4
Joined: Sat Sep 10, 2022 10:48 pm

Re: Simple Tiled Implementation - STI v1.2.3.0

Post by coz »

Actually, after checking https://thorbjorn.itch.io/tiled I can tell that there are certainly features that are not supported. For example, I can't find a 'type' or 'class' property for objects. Likewise, the site tells that the terrain definition changed in Tiled 1.5, so I suppose that old terrains won't load.
pauljessup
Party member
Posts: 356
Joined: Wed Jul 03, 2013 4:06 am

Re: Simple Tiled Implementation - STI v1.2.3.0

Post by pauljessup »

Type and class are supported, I use them a hell of a lot. It's part of the table for the object when it's brought in. Here's an example-

Code: Select all

for i,v in ipairs(self.objects) do
     if v.class=="streetLamp" then
        ---Do something here
    end
end
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests