Add flexibility to addSpot and addZone functions

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

Add flexibility to addSpot and addZone functions

#1 Post 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.
<DarkGod> lets say it's intended

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Add flexibility to addSpot and addZone functions

#2 Post by darkgod »

done
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

Re: Add flexibility to addSpot and addZone functions

#3 Post 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?
<DarkGod> lets say it's intended

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Add flexibility to addSpot and addZone functions

#4 Post by darkgod »

Both ? ;)
If there is an "additional" property use it otherwise populate as your second example
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Post Reply