User Tools

Site Tools

Urban Games

modding:constructionbasics

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
modding:constructionbasics [2020/07/07 21:39]
yoshi
modding:constructionbasics [2021/07/04 01:11] (current)
yoshi [UpdateFn]
Line 147: Line 147:
 {{: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>
 { {
Line 175: Line 175:
 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 ===
Line 206: Line 206:
  
 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>
  
Line 246: Line 246:
       { { -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 = {},
   }   }
Line 265: Line 265:
 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.
  
Line 290: Line 291:
 -- 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>
Line 359: Line 361:
   * ''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.
Line 403: Line 405:
 </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>
modding/constructionbasics.1594150749.txt.gz · Last modified: 2020/07/07 21:39 by yoshi