Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
modding:constructionbasics [2020/06/20 11:01] yoshi ↷ Page name changed from modding:constructions to modding:constructionbasics |
modding:constructionbasics [2021/07/04 01:11] yoshi [UpdateFn] |
{{:modding:constructions:parameter_icon_button.png?nolink&300|}} | {{:modding:constructions:parameter_icon_button.png?nolink&300|}} |
</div> | </div> |
Unlike the text buttons, the icon buttons display small images in TGA format. Unlike the text buttons, the list is currently left-aligned. If the list of buttons becomes wider than the parameter menu, it will wrap to another line. It is therefore advisable that the images for the buttons all have the same height. Also, the border of the buttons should be transparent so that you can see which option is currently selected. The file paths to the images are passed as a string list in the ''values'' parameter, the paths are relative to ''res/textures/''. | Unlike the text buttons, the icon buttons display small images in TGA format. Unlike the text buttons, the list is currently left-aligned. If the list of buttons becomes wider than the parameter menu, it will wrap to another line. It is therefore advisable that the images for the buttons all have the same height. Also, the border of the buttons should be transparent so that you can see which option is currently selected. The file paths to the images are passed as a string list in the ''values'' parameter, the paths are relative to ''res/textures/''. The tooltip is used for hovering over the parameter name. It is currently not possible to add tooltips for the individual icons. |
<code lua> | <code lua> |
{ | { |
In this function, the construction is configured and specified. You can use the content of the table ''params'' to configure the construction. It also contains the selection of the user parameters you have specified in the ''params'' list above. See the [[:modding:constructiontypes|list of construction types]] to find out, which additional properties are available in the ''params'' table depending on the construction type. | In this function, the construction is configured and specified. You can use the content of the table ''params'' to configure the construction. It also contains the selection of the user parameters you have specified in the ''params'' list above. See the [[:modding:constructiontypes|list of construction types]] to find out, which additional properties are available in the ''params'' table depending on the construction type. |
| |
The ''updateFn'' returns a data struct with several mandatory and many optional properties. They are described below. Please note, that the return data struct is refered as ''result''. | The ''updateFn'' returns a data struct with several mandatory and many optional properties. They are described below. Please note, that the return data struct is referred as ''result''. |
| |
=== Models === | === Models === |
| |
<div tip 100%> | <div tip 100%> |
There are two additional properties ''params.paramX'' and ''params.paramY'' that are controlled by keyboard keys. Per default the keys are <span key>O</span>/<span key>P</span> and <span key>Ü</span>/<span key>+</span>. They each have steps of 2π/32 so that 32 steps can be mapped to a full rotation around an axis. | There are two additional properties ''params.paramX'' and ''params.paramY'' that are controlled by keyboard keys. Per default the keys are <span key>O</span>/<span key>P</span> and <span key>Ü</span>/<span key>+</span> or <span key>[</span>/<span key>]</span> (depending on keyboard layout). They each have steps of 2π/32 so that 32 steps can be mapped to a full rotation around an axis. |
| |
To support rotation around all three axis, encapsulate the transformation matrix of the model with the ''rotateTransf'' function | To support rotation around all three axis, encapsulate the transformation matrix of the model with the ''rotateTransf'' function |
''transf = constructionutil.rotateTransf(params, { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 })''. | ''transf = constructionutil.rotateTransf(params, { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 })'' and make sure to import the ''constructionutil'' with ''local constructionutil = require "constructionutil"'' at the begin of the file (before ''function data()''). |
</div> | </div> |
| |
{ { -39.1, .0, .0 }, { -20.0, .0, .0 } }, -- node 1 (snap node) | { { -39.1, .0, .0 }, { -20.0, .0, .0 } }, -- node 1 (snap node) |
}, | }, |
snapNodes = { 1 } -- node 1 is allowed to snap to other edges of the same type | snapNodes = { 1 }, -- node 1 is allowed to snap to other edges of the same type |
freeNodes = {}, | freeNodes = {}, |
} | } |
The parameters for streets in the ''params'' block are: | The parameters for streets in the ''params'' block are: |
* ''type'' is a reference to a tracktype relative to ''res/config/track/''. | * ''type'' is a reference to a tracktype relative to ''res/config/track/''. |
| * ''hasBus'' is a boolean value. If set to ''false'', no bus lane will be built. If set to ''true'', a bus lane will be built. |
* ''tramTrackType'' is a string value. If set to ''"NO"'', no tramtracks will be built. If set to ''"YES"'', tram tracks will be built. If set to ''"ELECTRIC"'', tram tracks with catenary will be built. | * ''tramTrackType'' is a string value. If set to ''"NO"'', no tramtracks will be built. If set to ''"YES"'', tram tracks will be built. If set to ''"ELECTRIC"'', tram tracks with catenary will be built. |
| |
-- attach a signal to one of the above defined edges | -- attach a signal to one of the above defined edges |
result.edgeObjects = { | result.edgeObjects = { |
{ | { |
edge = 1, -- attach object to edge 1 | edge = 1, -- attach object to edge 1 |
param = .5, -- param along the edge | param = .5, -- param along the edge |
left = false, | left = false, |
model = "station/airport/asset/signal_runway_old.mdl" -- see res/models/model/ | model = "station/airport/asset/signal_runway_old.mdl" -- see res/models/model/ |
| } |
} | } |
</code> | </code> |
* ''left'' is set to false, if the object should be placed on the right side of the edge. ''true'' leads to objects on the left side. | * ''left'' is set to false, if the object should be placed on the right side of the edge. ''true'' leads to objects on the left side. |
* ''model'' is a reference to a ''.mdl'' file relative to ''res/models/model''. | * ''model'' is a reference to a ''.mdl'' file relative to ''res/models/model''. |
| |
| Please be aware that it is not possible to add more than one object per edge by script. |
| |
| |
* ''loop'' is a boolean value used to describe if the face is closed. If set to ''false'', the edge between last and first coordinate will not get a stroke paint. | * ''loop'' is a boolean value used to describe if the face is closed. If set to ''false'', the edge between last and first coordinate will not get a stroke paint. |
* ''alignmentOffsetMode'' specifies whether the offset is applied relative to the construction orientation (''"OBJECT"'') or the game world orientation (''"WORLD"''). | * ''alignmentOffsetMode'' specifies whether the offset is applied relative to the construction orientation (''"OBJECT"'') or the game world orientation (''"WORLD"''). |
* ''alignmentOffet'' contains the offset values in x and y direction. | * ''alignmentOffset'' contains the offset values in x and y direction. |
* ''alignmentDirMode'' specifies if the uv direction setting is applied relative to the construction orientation (''"OBJECT"'') or the game world orientation (''"WORLD"''). | * ''alignmentDirMode'' specifies if the uv direction setting is applied relative to the construction orientation (''"OBJECT"'') or the game world orientation (''"WORLD"''). |
* ''alignmentDir'' contains the direction rotation values in x and y axis. They are computed as ''tan2(y,x)'' to calculate the actual rotation. | * ''alignmentDir'' contains the direction rotation values in x and y axis. They are computed as ''tan2(y,x)'' to calculate the actual rotation. |
</code> | </code> |
| |
The ''labelText'' list contains a mapping of keys to value lists. The key number equals the id of the model in ''result.models'' that should be provided with some custom label texts. The list contains the strings. The first string is for the first label of the model, the second for the second model and so on. | The ''labelText'' list contains a mapping of keys to value lists. The key number equals the id of the model in ''result.models'' that should be provided with some custom label texts. The list contains the strings. The first string is for the first label of the model, the second for the second label of this model and so on. |
| |
| <div tip 100%> |
| To improve performance, for simple constructions that do not contain ground faces, terrain alignments, edges or depot/station/industry/town building definitions, there is no construction placed in the game but just the seperate mdls. These can not be configured afterwards or be deleted all at once. Furthermore these types of assets do not support the ''labelText'' custom texts from constructions. |
| </div> |
| |
\\ | \\ |
| |
<div page_next>[[:modding:constructiontypes|Construction Types]]</div> | <div page_next>[[:modding:constructiontypes|Construction Types]]</div> |