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
1a9704f1
Commit
1a9704f1
authored
5 years ago
by
coil
Committed by
Vitaliy
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add digiline commands for operating node detector (#472)
parent
8baa789e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mesecons_detector/doc/nodedetector/description.html
+6
-3
6 additions, 3 deletions
mesecons_detector/doc/nodedetector/description.html
mesecons_detector/init.lua
+34
-13
34 additions, 13 deletions
mesecons_detector/init.lua
with
40 additions
and
16 deletions
mesecons_detector/doc/nodedetector/description.html
+
6
−
3
View file @
1a9704f1
The node detector is a receptor. It changes its state when either any node
or a specific node is detected. Right-click it to set a nodename to scan for.
It can also receive digiline signals. You can either send "GET" and it will
respond with the detected nodename or you can send any other string and it will
set this string as the node to scan for.
It can also receive digiline signals. For example, you can send
<code>
{distance=4, scanname="default:dirt"}
</code>
to set distance to 4 and scan for dirt. You can omit either parameter.
There is also a command parameter:
<code>
{command="get"}
</code>
will respond
with the detected nodename and
<code>
{command="scan"}
</code>
will respond with
a boolean using the distance and nodename of the detector.
Nodenames must include the mod they reside in, so for instance default:dirt, not just dirt.
The distance parameter specifies how many blocks are between the node detector and the node to detect.
Automatic scanning with Mesecons output only works when the detector is in an active block, but Digilines queries always work.
This diff is collapsed.
Click to expand it.
mesecons_detector/init.lua
+
34
−
13
View file @
1a9704f1
...
...
@@ -189,28 +189,49 @@ local function node_detector_scan(pos)
(
frontname
~=
"air"
and
frontname
~=
"ignore"
and
scanname
==
""
)
end
local
function
node_detector_send_node_name
(
pos
,
node
,
channel
,
meta
)
local
distance
=
meta
:
get_int
(
"distance"
)
local
distance_max
=
mesecon
.
setting
(
"node_detector_distance_max"
,
10
)
if
distance
<
0
then
distance
=
0
end
if
distance
>
distance_max
then
distance
=
distance_max
end
local
nodename
=
minetest
.
get_node
(
vector
.
subtract
(
pos
,
vector
.
multiply
(
minetest
.
facedir_to_dir
(
node
.
param2
),
distance
+
1
))
).
name
digiline
:
receptor_send
(
pos
,
digiline
.
rules
.
default
,
channel
,
nodename
)
end
-- set player name when receiving a digiline signal on a specific channel
local
node_detector_digiline
=
{
effector
=
{
action
=
function
(
pos
,
node
,
channel
,
msg
)
local
meta
=
minetest
.
get_meta
(
pos
)
local
distance
=
meta
:
get_int
(
"distance"
)
local
distance_max
=
mesecon
.
setting
(
"node_detector_distance_max"
,
10
)
if
distance
<
0
then
distance
=
0
end
if
distance
>
distance_max
then
distance
=
distance_max
end
if
channel
~=
meta
:
get_string
(
"digiline_channel"
)
then
return
end
if
msg
==
GET_COMMAND
then
local
nodename
=
minetest
.
get_node
(
vector
.
subtract
(
pos
,
vector
.
multiply
(
minetest
.
facedir_to_dir
(
node
.
param2
),
distance
+
1
))
).
name
digiline
:
receptor_send
(
pos
,
digiline
.
rules
.
default
,
channel
,
nodename
)
if
type
(
msg
)
==
"table"
then
if
msg
.
distance
or
msg
.
scanname
then
if
msg
.
distance
then
meta
:
set_string
(
"distance"
,
msg
.
distance
)
end
if
msg
.
scanname
then
meta
:
set_string
(
"scanname"
,
msg
.
scanname
)
end
node_detector_make_formspec
(
pos
)
end
if
msg
.
command
==
"get"
then
node_detector_send_node_name
(
pos
,
node
,
channel
,
meta
)
elseif
msg
.
command
==
"scan"
then
local
result
=
node_detector_scan
(
pos
)
digiline
:
receptor_send
(
pos
,
digiline
.
rules
.
default
,
channel
,
result
)
end
else
meta
:
set_string
(
"scanname"
,
msg
)
node_detector_make_formspec
(
pos
)
if
msg
==
GET_COMMAND
then
node_detector_send_node_name
(
pos
,
node
,
channel
,
meta
)
else
meta
:
set_string
(
"scanname"
,
msg
)
node_detector_make_formspec
(
pos
)
end
end
end
,
},
...
...
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