User:Bayo/Clean up scripts

From UFO:AI
< User:Bayo
Revision as of 19:09, 29 May 2012 by Bayo (talk | contribs) (Created page with "Idea is to clean up some part of the script. As a result, we can use an only one grammar for all our main scripts (ATM we only use the same tokenizer). It also can help later ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Idea is to clean up some part of the script. As a result, we can use an only one grammar for all our main scripts (ATM we only use the same tokenizer). It also can help later to convert script to XML if we decide to.

Problem with lists

Some part of the script use list inside blocks. It makes problems if we considere blocks a set of name-value (cause most of our script consider that).

For examples team_humans.ufo, music.ufo... and many more

	names {
		female {
			Aakriti
			Abeba
			Adina
			Afra
			Afua
		}
	}

We can intrudice a new keyword for lists. For example:

	names {
		female [
			"Aakriti"
			"Abeba"
			"Adina"
			"Afra"
			"Afua"
		]
	}

Or still use the "default" way. For example:

	names {
		female {
			name "Aakriti"
			name "Abeba"
			name "Adina"
			name "Afra"
			name "Afua"
		}
	}

Or another way?

Problem with element containing more than one value

Some part of the script a property is defined by a name and many values in a list way.

research.ufo (request_OR alien), or components.ufo are good examples.

components craft_ufo_scout {
	time	300
	item	alienmaterials			300	%
	item	antimatter				200	0
	item	craft_alien_propulsion	2	%
	item	craft_alien_astrogation	1	%
	item	craft_alien_detection	1	%
}

We can rework it in a "default" way (BTW i dont introduce "random" names, i dont know all this things mean):

components craft_ufo_scout {
	time	300
	item {
		type alienmaterials
		value 300
		unit "%"
	}
	item	{ type antimatter		amount	200	unit "0" }
	item	{ type craft_alien_propulsion	amount 2	unit "%" }
	item	{ type craft_alien_astrogation	amount 1	unit "%" }
	item	{ type craft_alien_detection	amount 1	unit "%" }
}