construction_postRunFn.lua

function data()
return {
  -- info
  -- categories
  -- options
  -- runFn

  postRunFn = function(settings, params)
		local con = api.type.ConstructionDesc.new()

		con.type = api.type.enum.ConstructionType.ASSET_DEFAULT
		con.description.name = _("My Construction")
		con.description.description = _("Build your construction")

		local templ = api.type.ConstructionTemplate.new()

    templ.availability = api.type.MetadataMap.Availability.new()
	  templ.availability.yearFrom = 1825
		templ.availability.yearTo = 1925

		templ.desc.name = con.description.name
		templ.desc.description = con.description.description

		local dyn = api.type.DynamicConstructionTemplate.new()

		local par1 = api.type.ScriptParam.new()
		par1.key = "key_1"
		par1.name ="Key 1"
		par1.tooltip = "Key 1"
		par1.values = {"1", "2"}

		dyn.params[1] = par1

		templ.data = dyn

		con.constructionTemplates[1] = templ

		con.availability.yearFrom = 1825
		con.categories = { "misc" }
		con.order = 100
		con.skipCollision = false
		con.autoRemovable = false
		con.fileName = "myCon"
		con.updateScript.fileName = "construction/cons.updateFn"
		con.updateScript.params = {
			param1 = "param1",
		}
		con.preProcessScript.fileName = "construction/cons.preProcessFn"
		con.preProcessScript.params = {
			param1 = "param1",
		}
		con.upgradeScript.fileName = "construction/cons.upgradeFn"
		con.upgradeScript.params = {
			param1 = "param1",
		}
		con.createTemplateScript.fileName = "construction/cons.createTemplateFn"
		con.createTemplateScript.params = {
			param1 = "param1",
		}

		api.res.constructionRep.add("myCon", con, true)

		local con = api.res.constructionRep.get(api.res.constructionRep.find("myCon"))
		local par1 = api.type.ScriptParam.new()
		par1.key = "key_2"
		par1.name = "Key 2"
		par1.tooltip = "Key 2 (tooltip)"
		par1.values = {"1", "2", "3"}

		local templ = api.type.ConstructionTemplate.new()
		local dyn = api.type.DynamicConstructionTemplate.new()
		dyn.params[1] = par1

		templ.desc.name = _("My Construction")

		templ.data = dyn

		con.constructionTemplates[1] = templ
  end
}
end
generated by LDoc 1.4.3 Last updated 2021-03-22 16:05:52