Page 1 of 1

Add flexibility to addSpot and addZone functions

Posted: Fri Dec 03, 2010 8:39 pm
by yufra
I think it could be useful to store additional information in spots and zones, and since they are tables that is easy enough. I suggest addSpot and addZone functions grow another input variable that is a table that can be merged into the spot/zone table.

Code: Select all

		addSpot = function(dst, type, subtype, additional)
			local spot = {x=dst[1], y=dst[2], type=type or "static", subtype=subtype or "static"}
			table.update(spot, additional)
			self.spots[#self.spots+1] = spot
		end,
The Tiled plugin would of course be able to handle this extended functionality.

Re: Add flexibility to addSpot and addZone functions

Posted: Tue Dec 07, 2010 4:22 pm
by darkgod
done

Re: Add flexibility to addSpot and addZone functions

Posted: Thu Dec 09, 2010 5:53 pm
by yufra
I see two choices for adding this to Tiled, and would appreciate feedback. I will consider an example here where we want to add two additional table entries to the spot/zone, "period" equal to 10 and "amplitude" equal to 1. The first choice it to add one more Tiled property "additional" in the same way type and subtype are currently set up. In this case the "additional" Tiled property would be {period=10, amplitude=1}. The second choice would be to take all leftover Tiled properties and use those to populate the additional table. In this case we would add a "period" Tiled property with 10, and a "amplitude" Tiled property with 1. The advantage to the first method is we can also set up the additional table to be an array (indexed by number) more easily. The second method would make longer additional tables easier to read and edit in Tiled, though. Any preferences?

Re: Add flexibility to addSpot and addZone functions

Posted: Tue Dec 14, 2010 12:00 am
by darkgod
Both ? ;)
If there is an "additional" property use it otherwise populate as your second example