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
d2373eb6
Commit
d2373eb6
authored
10 years ago
by
Jeija
Browse files
Options
Downloads
Patches
Plain Diff
Don't trigger an "off" event to itself when luacontroller turns a port off
I hope this doesn't break anyone's setup.
parent
2a51e40a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mesecons/internal.lua
+1
-1
1 addition, 1 deletion
mesecons/internal.lua
mesecons_luacontroller/init.lua
+32
-1
32 additions, 1 deletion
mesecons_luacontroller/init.lua
with
33 additions
and
2 deletions
mesecons/internal.lua
+
1
−
1
View file @
d2373eb6
...
...
@@ -598,7 +598,7 @@ function mesecon.is_powered(pos, rule)
local
nn
=
minetest
.
get_node
(
np
)
if
(
mesecon
.
is_conductor_on
(
nn
,
mesecon
.
invertRule
(
rname
))
or
mesecon
.
is_receptor_on
(
nn
.
name
))
then
sourcepos
.
insert
(
np
)
table.insert
(
sourcepos
,
np
)
end
end
end
...
...
This diff is collapsed.
Click to expand it.
mesecons_luacontroller/init.lua
+
32
−
1
View file @
d2373eb6
...
...
@@ -133,6 +133,23 @@ local function set_port_states(pos, ports)
local
new_name
=
generate_name
(
ports
)
if
name
~=
new_name
and
vports
then
-- Problem:
-- We need to place the new node first so that when turning
-- off some port, it won't stay on because the rules indicate
-- there is an onstate output port there.
-- When turning the output off then, it will however cause feedback
-- so that the luacontroller will receive an "off" event by turning
-- its output off.
-- Solution / Workaround:
-- Remember which output was turned off and ignore next "off" event.
local
meta
=
minetest
.
get_meta
(
pos
)
local
ign
=
minetest
.
deserialize
(
meta
:
get_string
(
"ignore_offevents"
))
or
{}
if
ports
.
a
and
not
vports
.
a
and
not
mesecon
.
is_powered
(
pos
,
rules
.
a
)
then
ign
.
A
=
true
end
if
ports
.
b
and
not
vports
.
b
and
not
mesecon
.
is_powered
(
pos
,
rules
.
b
)
then
ign
.
B
=
true
end
if
ports
.
c
and
not
vports
.
c
and
not
mesecon
.
is_powered
(
pos
,
rules
.
c
)
then
ign
.
C
=
true
end
if
ports
.
d
and
not
vports
.
d
and
not
mesecon
.
is_powered
(
pos
,
rules
.
d
)
then
ign
.
D
=
true
end
meta
:
set_string
(
"ignore_offevents"
,
minetest
.
serialize
(
ign
))
minetest
.
swap_node
(
pos
,
{
name
=
new_name
,
param2
=
node
.
param2
})
if
ports
.
a
~=
vports
.
a
then
set_port
(
pos
,
rules
.
a
,
ports
.
a
)
end
...
...
@@ -163,6 +180,19 @@ local function overheat(pos, meta)
end
end
------------------------
-- Ignored off events --
------------------------
local
function
ignore_event
(
event
,
meta
)
if
event
.
type
~=
"off"
then
return
false
end
local
ignore_offevents
=
minetest
.
deserialize
(
meta
:
get_string
(
"ignore_offevents"
))
or
{}
if
ignore_offevents
[
event
.
pin
.
name
]
then
ignore_offevents
[
event
.
pin
.
name
]
=
nil
meta
:
set_string
(
"ignore_offevents"
,
minetest
.
serialize
(
ignore_offevents
))
return
true
end
end
-------------------------
-- Parsing and running --
...
...
@@ -361,6 +391,7 @@ end
local
function
run
(
pos
,
event
)
local
meta
=
minetest
.
get_meta
(
pos
)
if
overheat
(
pos
)
then
return
end
if
ignore_event
(
event
,
meta
)
then
return
end
-- Load code & mem from meta
local
mem
=
load_memory
(
meta
)
...
...
@@ -499,7 +530,7 @@ for d = 0, 1 do
rules
=
input_rules
[
cid
],
action_change
=
function
(
pos
,
_
,
rule_name
,
new_state
)
update_real_port_states
(
pos
,
rule_name
,
new_state
)
run
(
pos
,
{
type
=
new_state
,
pin
=
rule_name
})
run
(
pos
,
{
type
=
new_state
,
pin
=
rule_name
})
end
,
},
receptor
=
{
...
...
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