2020-06-14 16:29:10 -07:00
local breath_value = { }
minetest.register_chatcommand ( ' spawn ' , {
description = ' Teleport to spawn ' ,
privs = { home = true } ,
func = function ( name )
local player = minetest.get_player_by_name ( name )
player : setpos ( { x = 1473 , y = 2486 , z = 2970 } )
end ,
} )
2020-06-14 17:07:58 -07:00
minetest.register_chatcommand ( ' interact ' , {
2020-06-14 16:29:10 -07:00
description = ' Gives player interact ' ,
2020-06-14 17:07:58 -07:00
params = ' keyword ' ,
2020-06-14 16:29:10 -07:00
privs = { home = true } ,
2020-06-14 17:07:58 -07:00
func = function ( name , params )
if params == ' yellowsnow ' then
local privs = minetest.get_player_privs ( name )
privs.interact = true
minetest.set_player_privs ( name , privs )
minetest.chat_send_player ( name , ' Enjoy your stay on the Epic server! ' )
else
minetest.chat_send_player ( name , ' Check your spelling and try again. ' )
end
2020-06-14 16:29:10 -07:00
end ,
} )
minetest.register_chatcommand ( ' rules ' , {
description = ' Shows player rules ' ,
func = function ( name )
minetest.show_formspec ( name , ' rules ' , spawn_rules_formspec )
end ,
} )
minetest.register_chatcommand ( ' news ' , {
description = ' Shows player news ' ,
func = function ( name )
minetest.show_formspec ( name , ' news ' , spawn_news_formspec )
end ,
} )
local function has_interact ( player )
local name = player : get_player_name ( )
return not minetest.check_player_privs ( name , { interact = true } )
end
minetest.register_on_joinplayer ( function ( player )
player : set_properties ( { hp_max = 50 } )
player : set_properties ( { breath_max = 40 } )
player : set_breath ( 40 )
if has_interact ( player ) then
local player_name = player : get_player_name ( )
minetest.chat_send_player ( player_name , ' Read the rules for information on how to get interact. Para español visite https://www.nathansalapat.com/server/epic-server_es ' )
minetest.show_formspec ( player_name , ' rules ' , spawn_rules_formspec )
else
local player_name = player : get_player_name ( )
local info_count = tonumber ( spawn.storage : get_string ( player_name .. ' _info_count ' ) ) or 5
if info_count < 10 then
local new_count = ( info_count + 1 )
spawn.storage : set_string ( player_name .. ' _info_count ' , new_count )
minetest.show_formspec ( player_name , ' _info_message ' , spawn_info_formspec )
end
end
end )
local function drown ( player , air )
local new_breath = ( air - 4 )
breath_value [ player ] = new_breath
player : set_breath ( new_breath )
end
minetest.register_playerevent ( function ( player , event )
local air = player : get_breath ( )
local old_air = breath_value [ player ] or 40
if event == " breath_changed " then
if old_air > air then --Drowning
drown ( player , air )
else --Filling lungs with air
breath_value [ player ] = air
end
end
end )