Page Menu
Home
1F616EMO Bugtracker
Search
Configure Global Search
Log In
Files
F156880
init.lua
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
init.lua
View Options
-- twi_mods/newcomer_tips/init.lua
-- Tips for newcomers
--[[
The MIT License (MIT)
Copyright © 2024 1F616EMO
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]
local
S
=
minetest
.
get_translator
(
"newcomer_tips"
)
local
C
=
minetest
.
colorize
local
time_joined
=
{}
local
msg
=
table.concat
({
S
(
"Welcome to 1F616EMO Survival Server!"
),
S
(
"Read the rules at @1, or TL;DR: respect others."
,
"https://wiki-twi.1f616emo.xyz/wiki/Project:Rules"
),
S
(
"You can ask for help in the chatroom. Type
\"
/report
\"
if you want to contact the moderation team."
),
S
(
"Have fun!"
),
},
"
\n
"
)
minetest
.
register_on_newplayer
(
function
(
player
)
local
meta
=
player
:
get_meta
()
meta
:
set_int
(
"newcomer_tips_send"
,
1
)
end
)
minetest
.
register_on_joinplayer
(
function
(
player
)
local
name
=
player
:
get_player_name
()
local
meta
=
player
:
get_meta
()
if
meta
:
get_int
(
"newcomer_tips_send"
)
==
1
then
time_joined
[
name
]
=
os.time
()
minetest
.
after
(
0.5
,
function
()
if
minetest
.
get_player_by_name
(
name
)
then
minetest
.
chat_send_all
(
C
(
"yellow"
,
S
(
"Welcome our new player, @1!"
,
name
)))
minetest
.
chat_send_player
(
name
,
msg
)
end
end
)
end
end
)
local
TIME_NEEDED
=
2
*
60
minetest
.
register_on_leaveplayer
(
function
(
player
)
local
name
=
player
:
get_player_name
()
if
time_joined
[
name
]
and
os.time
()
-
time_joined
[
name
]
>
TIME_NEEDED
then
local
meta
=
player
:
get_meta
()
meta
:
set_int
(
"newcomer_tips_send"
,
0
)
end
time_joined
[
name
]
=
nil
end
)
local
function
loop
()
local
now
=
os.time
()
for
name
,
time
in
pairs
(
time_joined
)
do
if
now
-
time
>
TIME_NEEDED
then
local
player
=
minetest
.
get_player_by_name
(
name
)
local
meta
=
player
:
get_meta
()
meta
:
set_int
(
"newcomer_tips_send"
,
0
)
time_joined
[
name
]
=
nil
end
end
minetest
.
after
(
30
,
loop
)
end
minetest
.
after
(
5
,
loop
)
twi_fx
.
register_on_chat_message
(
function
(
name
,
message
)
local
player
=
minetest
.
get_player_by_name
(
name
)
local
spawn_pos
=
minetest
.
setting_get_pos
(
"static_spawnpoint"
)
if
not
(
player
and
spawn_pos
)
then
return
end
local
meta
=
player
:
get_meta
()
if
meta
:
get_int
(
"newcomer_tips_send"
)
~=
1
then
return
end
message
=
string.lower
(
message
)
if
string.find
(
message
,
"spawn"
)
then
minetest
.
after
(
0
,
function
()
if
minetest
.
get_player_by_name
(
name
)
then
minetest
.
chat_send_player
(
name
,
minetest
.
colorize
(
"orange"
,
S
(
"Tip! Type
\"
/spawn
\"
(without the quotes but with the slash) to get back tp the spawnpoint."
)))
end
end
)
elseif
string.find
(
message
,
"escape"
)
or
string.find
(
message
,
"stuck"
)
then
minetest
.
after
(
0
,
function
()
if
minetest
.
get_player_by_name
(
name
)
then
minetest
.
chat_send_player
(
name
,
minetest
.
colorize
(
"orange"
,
S
(
"Tip! Type
\"
/spawn
\"
(without the quotes but with the slash) to escape."
)))
end
end
)
end
end
)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 3, 6:05 PM (22 h, 45 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
57/de/2ed7de13e01f4ff7df5620e4c303
Default Alt Text
init.lua (4 KB)
Attached To
Mode
rTWIMODS Survival Server Custom Modifications
Attached
Detach File
Event Timeline
Log In to Comment