Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mesecons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
mesecons
Commits
70e9db28
Commit
70e9db28
authored
12 years ago
by
Vanessa Ezekowitz
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:Jeija/minetest-mod-mesecons
parents
c04870ef
3928d54d
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
mesecons/init.lua
+15
-13
15 additions, 13 deletions
mesecons/init.lua
mesecons/internal.lua
+4
-16
4 additions, 16 deletions
mesecons/internal.lua
mesecons/legacy.lua
+13
-0
13 additions, 0 deletions
mesecons/legacy.lua
mesecons_switch/init.lua
+1
-2
1 addition, 2 deletions
mesecons_switch/init.lua
with
33 additions
and
31 deletions
mesecons/init.lua
+
15
−
13
View file @
70e9db28
...
...
@@ -20,7 +20,6 @@ mesecon.actions_on={} -- Saves registered function callbacks for mesecon on
mesecon
.
actions_off
=
{}
-- Saves registered function callbacks for mesecon off
mesecon
.
actions_change
=
{}
-- Saves registered function callbacks for mesecon change
mesecon
.
receptors
=
{}
mesecon
.
receptors_off
=
{}
mesecon
.
effectors
=
{}
mesecon
.
rules
=
{}
mesecon
.
conductors
=
{}
...
...
@@ -33,25 +32,26 @@ dofile(minetest.get_modpath("mesecons").."/internal.lua");
-- API API API API API API API API API API API API API API API API API API
function
mesecon
:
add_receptor_node
(
name
,
rules
,
get_rules
)
--rules table is optional; if rules depend on param2 pass (nodename, nil, function get_rules)
if
get_rules
==
nil
and
rules
==
nil
then
rules
=
mesecon
:
get_rules
(
"default"
)
end
table.insert
(
mesecon
.
receptors
,
{
name
=
name
,
rules
=
rules
,
get_rules
=
get_rules
})
end
function
mesecon
:
add_receptor_node_off
(
name
,
rules
,
get_rules
)
if
get_rules
==
nil
and
rules
==
nil
then
rules
=
mesecon
:
get_rules
(
"default"
)
function
mesecon
:
register_receptor
(
onstate
,
offstate
,
rules
,
get_rules
)
if
get_rules
==
nil
and
rules
==
nil
then
rules
=
mesecon
:
get_rules
(
"default"
)
end
table.insert
(
mesecon
.
receptors_off
,
{
name
=
name
,
rules
=
rules
,
get_rules
=
get_rules
})
table.insert
(
mesecon
.
receptors
,
{
onstate
=
onstate
,
offstate
=
offstate
,
rules
=
rules
,
get_rules
=
get_rules
})
end
function
mesecon
:
register_effector
(
onstate
,
offstate
,
input_rules
,
get_input_rules
)
if
get_input_rules
==
nil
and
input_rules
==
nil
then
rules
=
mesecon
:
get_rules
(
"default"
)
end
table.insert
(
mesecon
.
effectors
,
{
onstate
=
onstate
,
offstate
=
offstate
,
input_rules
=
input_rules
,
get_input_rules
=
get_input_rules
})
table.insert
(
mesecon
.
effectors
,
{
onstate
=
onstate
,
offstate
=
offstate
,
input_rules
=
input_rules
,
get_input_rules
=
get_input_rules
})
end
function
mesecon
:
receptor_on
(
pos
,
rules
)
...
...
@@ -130,3 +130,5 @@ dofile(minetest.get_modpath("mesecons").."/wires.lua");
--Services like turnoff receptor on dignode and so on
dofile
(
minetest
.
get_modpath
(
"mesecons"
)
..
"/services.lua"
);
--Deprecated stuff
dofile
(
minetest
.
get_modpath
(
"mesecons"
)
..
"/legacy.lua"
);
This diff is collapsed.
Click to expand it.
mesecons/internal.lua
+
4
−
16
View file @
70e9db28
...
...
@@ -4,7 +4,7 @@
function
mesecon
:
is_receptor_node
(
nodename
)
local
i
=
1
for
i
,
receptor
in
ipairs
(
mesecon
.
receptors
)
do
if
receptor
.
nam
e
==
nodename
then
if
receptor
.
onstat
e
==
nodename
then
return
true
end
i
=
i
+
1
...
...
@@ -14,8 +14,8 @@ end
function
mesecon
:
is_receptor_node_off
(
nodename
,
pos
,
ownpos
)
local
i
=
1
for
i
,
receptor
in
ipairs
(
mesecon
.
receptors
_off
)
do
if
receptor
.
nam
e
==
nodename
then
for
i
,
receptor
in
ipairs
(
mesecon
.
receptors
)
do
if
receptor
.
offstat
e
==
nodename
then
return
true
end
i
=
i
+
1
...
...
@@ -25,7 +25,7 @@ end
function
mesecon
:
receptor_get_rules
(
node
)
for
i
,
receptor
in
ipairs
(
mesecon
.
receptors
)
do
if
receptor
.
nam
e
==
node
.
name
then
if
receptor
.
onstate
==
node
.
name
or
receptor
.
offstat
e
==
node
.
name
then
if
receptor
.
get_rules
~=
nil
then
return
receptor
.
get_rules
(
node
.
param2
)
elseif
mesecon
.
receptors
[
i
].
rules
~=
nil
then
...
...
@@ -35,18 +35,6 @@ function mesecon:receptor_get_rules(node)
end
end
end
for
i
,
receptor
in
ipairs
(
mesecon
.
receptors_off
)
do
if
receptor
.
name
==
node
.
name
then
if
receptor
.
get_rules
~=
nil
then
return
receptor
.
get_rules
(
node
.
param2
)
elseif
mesecon
.
receptors_off
[
i
].
rules
~=
nil
then
return
receptor
.
rules
else
return
mesecon
:
get_rules
(
"default"
)
end
end
end
return
nil
end
...
...
This diff is collapsed.
Click to expand it.
mesecons/legacy.lua
0 → 100644
+
13
−
0
View file @
70e9db28
function
mesecon
:
add_receptor_node
(
name
,
rules
,
get_rules
)
if
get_rules
==
nil
and
rules
==
nil
then
rules
=
mesecon
:
get_rules
(
"default"
)
end
table.insert
(
mesecon
.
receptors
,
{
onstate
=
name
,
rules
=
rules
,
get_rules
=
get_rules
})
end
function
mesecon
:
add_receptor_node_off
(
name
,
rules
,
get_rules
)
if
get_rules
==
nil
and
rules
==
nil
then
rules
=
mesecon
:
get_rules
(
"default"
)
end
table.insert
(
mesecon
.
receptors
,
{
offstate
=
name
,
rules
=
rules
,
get_rules
=
get_rules
})
end
This diff is collapsed.
Click to expand it.
mesecons_switch/init.lua
+
1
−
2
View file @
70e9db28
...
...
@@ -15,8 +15,7 @@ minetest.register_node("mesecons_switch:mesecon_switch_on", {
description
=
"Switch"
,
})
mesecon
:
add_receptor_node
(
"mesecons_switch:mesecon_switch_on"
)
mesecon
:
add_receptor_node_off
(
"mesecons_switch:mesecon_switch_off"
)
mesecon
:
register_receptor
(
"mesecons_switch:mesecon_switch_on"
,
"mesecons_switch:mesecon_switch_off"
)
minetest
.
register_on_punchnode
(
function
(
pos
,
node
,
puncher
)
if
node
.
name
==
"mesecons_switch:mesecon_switch_on"
then
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment