diff options
author | cheapie <no-email-for-you@example.com> | 2016-05-31 19:21:12 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2016-05-31 19:21:12 -0500 |
commit | b18c42625ff02568e8a20fe4c764e96aed39ccfe (patch) | |
tree | c0b5e4531257e6602db855dadac05307f413a972 | |
parent | d7d91e21d1c16a384ef17e80bdd523aa85f6db2a (diff) | |
download | newplayer-b18c42625ff02568e8a20fe4c764e96aed39ccfe.tar newplayer-b18c42625ff02568e8a20fe4c764e96aed39ccfe.tar.gz newplayer-b18c42625ff02568e8a20fe4c764e96aed39ccfe.tar.bz2 newplayer-b18c42625ff02568e8a20fe4c764e96aed39ccfe.tar.xz newplayer-b18c42625ff02568e8a20fe4c764e96aed39ccfe.zip |
Fall back to non-colored text if an old server version is in use
-rw-r--r-- | init.lua | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -1,5 +1,13 @@ newplayer = {} +if type(minetest.colorize) == "function" then + newplayer.colorize = minetest.colorize +else + newplayer.colorize = function(color,text) + return text + end +end + local f = io.open(minetest.get_worldpath()..DIR_DELIM.."newplayer-keywords.txt","r") if f then local d = f:read("*all") @@ -105,7 +113,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) minetest.chat_send_player(name,"Teleporting to spawn...") player:setpos(spawn) else - minetest.chat_send_player(name,minetest.colorize("#FF0000","ERROR: ").."The spawn point is not set!") + minetest.chat_send_player(name,newplayer.colorize("#FF0000","ERROR: ").."The spawn point is not set!") end local form = "size[5,3]".. "label[1,0;Thank you for agreeing]".. @@ -139,7 +147,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) f:write(fields.rules) f:close() newplayer.rules = fields.rules - minetest.chat_send_player(name,minetest.colorize("#55FF55","Success: ").."Rules/keyword updated.") + minetest.chat_send_player(name,newplayer.colorize("#55FF55","Success: ").."Rules/keyword updated.") end else minetest.chat_send_player(name,"You hacker you... nice try!") @@ -190,7 +198,7 @@ minetest.register_chatcommand("set_no_interact_spawn",{ local pos = minetest.get_player_by_name(name):getpos() minetest.setting_set("spawnpoint_no_interact",string.format("%s,%s,%s",pos.x,pos.y,pos.z)) minetest.setting_save() - return true, minetest.colorize("#55FF55","Success: ").."Spawn point for players without interact set to: "..minetest.colorize("#00FFFF",minetest.pos_to_string(pos)) + return true, newplayer.colorize("#55FF55","Success: ").."Spawn point for players without interact set to: "..newplayer.colorize("#00FFFF",minetest.pos_to_string(pos)) end} ) @@ -202,7 +210,7 @@ minetest.register_chatcommand("set_interact_spawn",{ local pos = minetest.get_player_by_name(name):getpos() minetest.setting_set("spawnpoint_interact",string.format("%s,%s,%s",pos.x,pos.y,pos.z)) minetest.setting_save() - return true, minetest.colorize("#55FF55","Success: ").."Spawn point for players with interact set to: "..minetest.colorize("#00FFFF",minetest.pos_to_string(pos)) + return true, newplayer.colorize("#55FF55","Success: ").."Spawn point for players with interact set to: "..newplayer.colorize("#00FFFF",minetest.pos_to_string(pos)) end} ) @@ -215,7 +223,7 @@ minetest.register_chatcommand("getkeywords",{ if #newplayer.keywords > 0 then out = "Currently configured keywords:" for _,kw in pairs(newplayer.keywords) do - out = out.."\n"..minetest.colorize("#00FFFF",kw) + out = out.."\n"..newplayer.colorize("#00FFFF",kw) end else out = "No keywords are currently set." @@ -230,7 +238,7 @@ minetest.register_chatcommand("addkeyword",{ privs = {server=true}, func = function(name,param) if (not param) or param == "" then - return true, minetest.colorize("#FF0000","ERROR: ").."No keyword supplied" + return true, newplayer.colorize("#FF0000","ERROR: ").."No keyword supplied" end table.insert(newplayer.keywords,param) newplayer.savekeywords() @@ -244,16 +252,16 @@ minetest.register_chatcommand("delkeyword",{ privs = {server=true}, func = function(name,param) if (not param) or param == "" then - return true, minetest.colorize("#FF0000","ERROR: ").."No keyword supplied" + return true, newplayer.colorize("#FF0000","ERROR: ").."No keyword supplied" end for k,v in pairs(newplayer.keywords) do if v == param then newplayer.keywords[k] = nil newplayer.savekeywords() - return true, "Keyword "..minetest.colorize("#00FFFF",param).." removed" + return true, "Keyword "..newplayer.colorize("#00FFFF",param).." removed" end end - return true, minetest.colorize("#FF0000","ERROR: ").."Keyword "..minetest.colorize("#00FFFF",param).." not found" + return true, newplayer.colorize("#FF0000","ERROR: ").."Keyword "..newplayer.colorize("#00FFFF",param).." not found" end} ) @@ -269,7 +277,7 @@ minetest.register_chatcommand("spawn",{ player:setpos(pos) return true, "Teleporting to spawn..." else - return true, minetest.colorize("#FF0000","ERROR: ").."The spawn point is not set!" + return true, newplayer.colorize("#FF0000","ERROR: ").."The spawn point is not set!" end else local pos = minetest.setting_get_pos("spawnpoint_no_interact") @@ -277,7 +285,7 @@ minetest.register_chatcommand("spawn",{ player:setpos(pos) return true, "Teleporting to spawn..." else - return true, minetest.colorize("#FF0000","ERROR: ").."The spawn point is not set!" + return true, newplayer.colorize("#FF0000","ERROR: ").."The spawn point is not set!" end end end} |