Page 91 of 92

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Sun Jul 10, 2022 9:59 pm
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.

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Sun Jul 10, 2022 11:45 pm
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)?

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Sun Jul 10, 2022 11:59 pm
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.

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Wed Jul 13, 2022 12:49 am
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!

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Sun Aug 21, 2022 4:15 pm
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

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Fri Sep 02, 2022 12:50 pm
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

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Wed Sep 14, 2022 7:06 pm
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

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Sun Oct 30, 2022 9:02 pm
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

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Mon Oct 31, 2022 2:02 am
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.

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Fri Nov 04, 2022 7:31 pm
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