LUAAdvisors

From SC4D Encyclopaedia
Revision as of 14:19, 9 September 2012 by sc4e>Whatevermind (Created page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


The Advisor Definitions Script defines the Advisor Details. File 25094

Specification

Starting Block

dofile("filename.lua")
  -- The usual dofile includes before parsing

advisor_base_template = create_template
({
   class_id = 0,
   id = 0, 
   advice_type = 0,
   caption = "",
   name = "",
})
  -- Creates a base template which can have values declared in the advisors block for each advisor.
  
advisors = {n = 0}
  -- Set current advisor number to 0 to begin file.

function advisors : new (init_table, base_table, flat)   -- function definition
   local t = advisor_base_template : new (init_table, base_table, flat)
   local i = getn(self) +1
   self[i] = t               -- add the table to the main advisors' repository
   self . n = self . n + 1   -- update the table count
   return t
end

Advisors Block

Repeating section.

mysim_advisor = advisors : new     -- Creates a new advisor type for use in other sections.
({
   class_id = hex2dec('4a1dbbbf'), -- Class ID for this advisor type.
   id = advisor_ids.NULL,          -- This one will be ingnored by the game.
}, nil, nil)                       -- Unused since this is creating a type.

advisors : new 
({
   class_id = hex2dec('6a5f8755'),       -- Class ID used in-game for the advisor.
   id = advisor_ids.HEALTH_EDUCATION,    -- Type from definitions LUA.
   advice_type = advice_types.HEALTH_EDUCATION, -- Type from LUA.
   caption = "text@aa49638a Health & Education Advisor", -- Text of Advisor title.
   name = "text@0a75f82b",               -- Text of Advisor Name.
}
, department_advisor                     -- Advisor type as defined in above type section,
,1)                                      -- Flat value, model treated as flat model or not.
                                            No real noticeable difference from changing this.