Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
illuna
Commits
05e23068
Commit
05e23068
authored
8 years ago
by
Milan
Browse files
Options
Downloads
Patches
Plain Diff
add notice command
parent
a1140159
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
commands.lua
+49
-0
49 additions, 0 deletions
commands.lua
with
49 additions
and
0 deletions
commands.lua
+
49
−
0
View file @
05e23068
...
...
@@ -65,3 +65,52 @@ minetest.register_on_respawnplayer(function(player, pos)
player
:
setpos
(
spawn
)
return
true
end
)
-- Commands, originally by Grailtest @0-afflatus
command
=
{}
function
command
.
send_notice
(
target
,
text
)
local
player
=
minetest
.
get_player_by_name
(
target
)
if
not
player
then
return
false
,
(
"There's no player named '%s'."
):
format
(
target
)
end
local
fs
=
{
}
local
lines
=
{
}
for
i
,
line
in
ipairs
(
text
:
split
(
"|"
))
do
local
lt
=
{
}
for
j
=
1
,
#
line
,
40
do
table.insert
(
lt
,
line
:
sub
(
j
,
j
+
39
))
end
lines
[
i
]
=
table.concat
(
lt
,
"
\n
"
)
end
text
=
table.concat
(
lines
,
"
\n
"
)
text
=
minetest
.
formspec_escape
(
text
)
table.insert
(
fs
,
"size[8,4]"
)
--table.insert(fs, "background[0,0;8,4;ui_form_bg.png]")
table.insert
(
fs
,
"label[1,.2;"
..
text
..
"]"
)
table.insert
(
fs
,
"button_exit[3,3.2;2,0.5;ok;OK]"
)
fs
=
table.concat
(
fs
)
minetest
.
after
(
0
.
5
,
function
()
minetest
.
show_formspec
(
target
,
"notice:notice"
,
fs
)
end
)
return
true
end
minetest
.
register_privilege
(
"notice"
,
"Send notices to players."
)
minetest
.
register_chatcommand
(
"notice"
,
{
params
=
"<player> <text>"
,
privs
=
{
notice
=
true
,
},
description
=
"Show a notice to a player."
,
func
=
function
(
name
,
params
)
local
target
,
text
=
params
:
match
(
"(%S+)%s+(.+)"
)
if
not
(
target
and
text
)
then
return
false
,
"Usage: /notice <player> <text>"
end
local
ok
,
err
=
command
.
send_notice
(
target
,
text
)
if
not
ok
then
return
false
,
err
end
return
true
,
"Notice sent!"
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