Difference between revisions of "LUAAdvisors"

From SC4D Encyclopaedia
Jump to navigation Jump to search
sc4e>Whatevermind
(Created page)
 
m (2 revisions imported)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{MTS2}}
+
The '''Advisor Definitions Script''' defines the Advisor Details. The [[TGI]] for this file is ''0xca63e2a3,0x4a5e8ef6,0xff456218''.
  
The '''Advisor Definitions Script''' defines the Advisor Details. File 25094
+
==Specification==
 +
This [[LUA]] file contains a starting block, followed by the Main Advisor Table, which includes all of the advisor definitions.
  
==Specification==
 
 
===Starting Block===
 
===Starting Block===
 
+
The file begins with the usual round of ''dofile'' includes.
 
<pre>
 
<pre>
 
dofile("filename.lua")
 
dofile("filename.lua")
  -- The usual dofile includes before parsing
+
</pre>
  
 +
This is immediately followed by a template that is used for the advisor definitions later in the file.
 +
<pre>
 
advisor_base_template = create_template
 
advisor_base_template = create_template
 
({
 
({
Line 18: Line 20:
 
   name = "",
 
   name = "",
 
})
 
})
  -- Creates a base template which can have values declared in the advisors block for each advisor.
+
</pre>
 
+
 
 +
===Main Advisor Table===
 +
The next section of the file is the beginning of the main advisor table. This table includes the definitions for all of the advisors in the game. It begins by resetting the advisor count to zero, then defining some functions to enable the use of the above template in the following definitions.
 +
<pre>
 
advisors = {n = 0}
 
advisors = {n = 0}
 
   -- Set current advisor number to 0 to begin file.
 
   -- Set current advisor number to 0 to begin file.
  
function advisors : new (init_table, base_table, flat)  -- function definition
+
function advisors : new (init_table, base_table, flat)  -- Function definition
 
   local t = advisor_base_template : new (init_table, base_table, flat)
 
   local t = advisor_base_template : new (init_table, base_table, flat)
 
   local i = getn(self) +1
 
   local i = getn(self) +1
   self[i] = t              -- add the table to the main advisors' repository
+
   self[i] = t              -- Add the table to the main advisors' repository
   self . n = self . n + 1  -- update the table count
+
   self . n = self . n + 1  -- Update the table count
 
   return t
 
   return t
 
end
 
end
 
</pre>
 
</pre>
  
===Advisors Block===
+
This is then followed by two sections, the '''department_advisor''' and '''mysim_advisor''' sections, which themselves contain the actual advisor definitions for each of the two types of advisors. Each section begins with an opening category definition. Here the ''mysim_advisor'' is shown as an example:
Repeating section.
 
  
 
<pre>
 
<pre>
mysim_advisor = advisors : new    -- Creates a new advisor type for use in other sections.
+
mysim_advisor = advisors : new    -- Creates a new advisor type for use in the definitions to follow.
 
({
 
({
 
   class_id = hex2dec('4a1dbbbf'), -- Class ID for this advisor type.
 
   class_id = hex2dec('4a1dbbbf'), -- Class ID for this advisor type.
   id = advisor_ids.NULL,          -- This one will be ingnored by the game.
+
   id = advisor_ids.NULL,          -- This one will be ignored by the game.
 
}, nil, nil)                      -- Unused since this is creating a type.
 
}, nil, nil)                      -- Unused since this is creating a type.
 +
</pre>
 +
 +
Following the category definition is a series of entries for each of the advisors of that type. The example below shows the format of these entries.
  
advisors : new  
+
<pre>
({
+
advisors : new (
   class_id = hex2dec('6a5f8755'),       -- Class ID used in-game for the advisor.
+
{
   id = advisor_ids.HEALTH_EDUCATION,   -- Type from definitions LUA.
+
   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.
 
   advice_type = advice_types.HEALTH_EDUCATION, -- Type from LUA.
 
   caption = "text@aa49638a Health & Education Advisor", -- Text of Advisor title.
 
   caption = "text@aa49638a Health & Education Advisor", -- Text of Advisor title.
   name = "text@0a75f82b",               -- Text of Advisor Name.
+
   name = "text@0a75f82b",                   -- Text of Advisor Name.
 
}
 
}
, department_advisor                     -- Advisor type as defined in above type section,
+
, department_advisor                         -- Advisor type as defined in above category definition,
,1)                                     -- Flat value, model treated as flat model or not.
+
,1)                                         -- Flat value, model treated as flat model or not.
                                            No real noticeable difference from changing this.
+
                                                No real noticeable difference from changing this.
 
</pre>
 
</pre>
  
 +
The file simply ends after the last advisor definition.
  
 
[[Category:Modding]]
 
[[Category:Modding]]
 
[[Category:MTS2]]
 
[[Category:MTS2]]

Latest revision as of 21:40, 3 August 2019

The Advisor Definitions Script defines the Advisor Details. The TGI for this file is 0xca63e2a3,0x4a5e8ef6,0xff456218.

Specification

This LUA file contains a starting block, followed by the Main Advisor Table, which includes all of the advisor definitions.

Starting Block

The file begins with the usual round of dofile includes.

dofile("filename.lua")

This is immediately followed by a template that is used for the advisor definitions later in the file.

advisor_base_template = create_template
({
   class_id = 0,
   id = 0, 
   advice_type = 0,
   caption = "",
   name = "",
})

Main Advisor Table

The next section of the file is the beginning of the main advisor table. This table includes the definitions for all of the advisors in the game. It begins by resetting the advisor count to zero, then defining some functions to enable the use of the above template in the following definitions.

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

This is then followed by two sections, the department_advisor and mysim_advisor sections, which themselves contain the actual advisor definitions for each of the two types of advisors. Each section begins with an opening category definition. Here the mysim_advisor is shown as an example:

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

Following the category definition is a series of entries for each of the advisors of that type. The example below shows the format of these entries.

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 category definition,
,1)                                          -- Flat value, model treated as flat model or not.
                                                No real noticeable difference from changing this.

The file simply ends after the last advisor definition.