/
developers.html
executable file
·167 lines (151 loc) · 7.93 KB
/
developers.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html>
<head>
<title>Mesecons - Developers</title>
<link rel="icon" type="image/ico" href="/img/favicon.ico">
<meta name="viewport" content="width=width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=Titillium+Web' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Cantarell' rel='stylesheet' type='text/css'>
<script src="common.js"></script>
<script src="items.js"></script>
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet" href="developers.css" />
</head>
<body>
<div id="header">
<a href="index.html"><img id="header_logo" src="img/logo.png"></a>
<a href="index.html"><div id="header_logotext">Mesecons</div></a>
<div id="header_menu">
<a class="header_menuitem" href="items.html">Items</a>
<a class="header_menuitem" href="digilines.html">Digilines</a>
<a class="header_menuitem" href="developers.html">Developers</a>
</div>
</div>
<div class="banner banner-developers"></div>
<div id="developers">
<div class = "article-heading">Development Resources</div>
<b>For the following commands you need to add "mesecons" to the dependencies of your mod.</b><br/><br/>
<div class = "paragraph-heading">General information</div>
There are 3 basic node types that you need to know about for Mesecon development.<br/>
You usually define two different nodes for each receptor / conductor / effector:
<ul>
<li>An active one, that emits / conducts / receives energy, its state is mesecon.state.on</li>
<li>An inactive one, that doesn't emit / conduct / receive energy, its state is mesecon.state.off</li>
</ul>
<br/>
Every definiton of a mesecon items also contains "rules". Rules define what positions the node connects to. For instance, normal mesecons connect to all nodes around them at the same height, above or below. Vertical mesecons only connect to those nodes that are above or below.<br/>
There are some preset rules:
<ul>
<li>mesecon.rules.default The standard rules, used if no rules are specified.</li>
<li>mesecon.rules.buttonlike The rules that buttons and wall levers use.</li>
<li>mesecon.rules.flat Node only connects to others at the same height (e.g. Microcontroller)</li><br/>
</ul>
You can also make rules yourself, it is even possible to make rules dependent on the orientation of the node: See the "Rules" section below.
The definition of a node includes a mesecons = {...} field that contains all the code for the mesecons integration.
<br/><br/>
<div class = "paragraph-heading">Conductors</div>
<img src="img/mesecon.png" class="dev-hover-item">
<div class = "code"><pre>
minetest.register_node("any:name", {
...
mesecons = {conductor = {
state = mesecon.state.on/off,
onstate = "any:name_on",
offstate = "any:name_off",
rules = mesecon.rules
}}
})</pre></div>
<b>state</b> = a mesecon.state | Defines if the conductor is active or inactive<br/>
<b>onstate</b> = a nodename | Required if state == mesecon.state.off | Defines the other nodename of the conductor definition, the active one.<br/>
<b>offstate</b> = a nodename | Required if state == mesecon.state.on | Defines the other nodename of the conductor definition, the inactive one.<br/>
<b>rules</b> = a mesecon.rules | If not specified, is mesecon.rules.default | Defines the connection rules of the conductor | Can be a function or a rules table
<br/><br/>
<div class = "paragraph-heading">Receptors</div>
Receptors are nodes that <i>send out</i> mesecon energy.
<img src="img/switch.png" class="dev-hover-item">
<div class = "code"><pre>
minetest.register_node("any:name", {
...
mesecons = {receptor = {
state = mesecon.state.on/off,
rules = mesecon.rules
}}
})</pre></div>
<b>state</b> = a mesecon.state | Defines if the receptor is active or inactive<br/>
<b>rules</b> = a mesecon.rules | If not specified, is mesecon.rules.default | Defines the connection rules of the receptor | Can be a function or a rules table
<br/>
<br/>
If a receptor recognized something and you want it to turn on, you have to call
<div class = "code"><pre>
minetest.set_node(pos, {name="myreceptor:receptor_on"})
mesecon.receptor_on(pos, rules)</pre></div>
...to turn it off again:
<div class = "code"><pre>
minetest.set_node(pos, {name="myreceptor:receptor_off"})
mesecon.receptor_off(pos, rules)</pre></div>
<br/><br/>
<div class = "paragraph-heading">Effectors</div>
Effectors do something when they receive power.
<img src="img/lightstone.png" class="dev-hover-item">
<div class = "code"><pre>
minetest.register_node("any:name", {
...
mesecons = {effector = {
rules = mesecon.rules
action_on = function (pos, node)
-- do something to turn the effector on
end,
action_off = function (pos, node)
-- do something to turn the effector off
end,
action_change = function (pos, node)
-- do something whenever any input to the effector changes
end
}}
})</pre></div>
All action functions are optional, but obviously there should be at least one to have your effector do anything at all.<br/>
<b>rules</b> = a mesecon.rules | If not specified, is mesecon.rules.default | Defines the connection rules of the effector | Can be a function or a rules table<br/>
<b>action_on</b> a function (pos, node) | It is called when the effector receives power and is not powered by anything else<br/>
<b>action_off</b> a function (pos, node) | It is called when the effector doesn't receive power anymore and is not powered by anything else<br/>
<b>action_change</b> a function (pos, node) | Called if action_on or action_off are called, but also if the receptor is already being powered and a change occurs somewhere (e.g. used by microcontroller)<br/>
<br/>
<div class = "paragraph-heading">Rules</div>
Rules are a table of relative positions that describe what nodes around an effector/receptor/conductor it links to, e.g. where a receptor turns on conductors.<br/><br/>
<div class = "code"><pre>
myrules =
{{x=-1, y=0, z=0},
{x=1, y=0, z=0}}</pre></div>
These rules link to the nodes at the x+ side and x- side of the effector/receptor/conductor.
<br/><br/>
There are some cases in which the rules depend on the rotation of a node, e.g. for the delayer.
In this case you just use a function instead of a table:
<br/><br/>
<div class = "code"><pre>
rules = function(node)
if node.param2 == 1 then
return {{x=1, y=0, z=0}}
elseif node.param2 == 2 then
...
end
end</pre></div>
<div class = "paragraph-heading">Complex items</div>
Complex items like the microcontroller, gates, the dealyer or the torch are both effectors and receptors. Explaining them would be too much for a dev reference - check out their code!
<br/><br/>
<div class = "paragraph-heading">Design</div>
VanessaE is the design leader of mesecons. Ask her for detailed information about mesecon design.<br/>
This shows the colors and the proportions of a mesecon wire:
<img src = "img/meseconsdesign.png"><br/>
The default texture size is 16x16. In special cases you may use 32x32 (e.g. Microcontroller), but only make the important parts of the texture in that resolution (for the Microcontroller it is only the letters at the input ports) and keep the rest in 16px which means 2x2 pixels.<br/>
<br/><br/>
<div class = "paragraph-heading">Contribute</div>
You contribute by forking the repository on GitHub and sending a pull request. You may also contribute to the digilines mod (which is an extension that provides a digital bus system) or to this website.<br/>
<a href="https://github.com/minetest-mods/mesecons">Mesecons mod repository (Lua)</a><br/>
<a href="https://github.com/Jeija/mesecons.net">Mesecons.net repository (HTML, CSS, JavaScript)</a><br/>
<a href="https://github.com/minetest-mods/digilines">Digilines mod (extension, Lua)</a><br/>
<br/>
<div class = "paragraph-heading">Guidelines</div>
Make sure you follow the <a href="devguidelines.html">Development Guidelines</a> before sending a pull request.
</div>
</body>
</html>