Added colored nametags
This commit is contained in:
31
init.lua
31
init.lua
@@ -1,23 +1,10 @@
|
||||
bounty = {}
|
||||
bounty.file = core.get_worldpath() .. '/bounty.txt'
|
||||
bounty.data = {}
|
||||
--bounty.prizes = false --determines if prizes or amount per points game-mechanic is used
|
||||
if false then
|
||||
bounty.prizes = 'default:steel_ingot'
|
||||
bounty.points_per_prize = 100 --per 100 points you get a default:steel_ingot
|
||||
else
|
||||
bounty.prizes = {
|
||||
[20] = 'default:wood 50', -- for bounties that are higher then 100 iron ingots are given
|
||||
[50] = 'default:cobble 50', -- for bounties that are higher then 150 gold ingots are given
|
||||
[70] = 'default:stone 40', -- for bounties that are higher then 150 gold ingots are given
|
||||
[100] = 'default:steel_ingot 2', -- for bounties that are higher then 150 gold ingots are given
|
||||
[200] = 'default:steel_ingot 5' -- etc...
|
||||
}
|
||||
end
|
||||
|
||||
bounty.penalize = function(player_name) --set the penalty
|
||||
--example of a penalty (revoke all privs ecept interact)
|
||||
core.set_player_privs(player_name, { shout = true })
|
||||
--core.set_player_privs(player_name, { shout = true })
|
||||
bounty.unregister(player_name)
|
||||
--end of example
|
||||
end
|
||||
@@ -46,6 +33,20 @@ bounty.save = function()
|
||||
end
|
||||
end
|
||||
|
||||
bounty.set_nametag_color = function(player_name)
|
||||
local player = minetest.get_player_by_name(player_name)
|
||||
local props = player:get_properties()
|
||||
if bounty.data[player_name] > 100 then
|
||||
player:set_properties({ nametag_color = "#ff0000" })
|
||||
elseif bounty.data[player_name] > 50 then
|
||||
player:set_properties({ nametag_color = "#ffa500" })
|
||||
elseif bounty.data[player_name] > 0 then
|
||||
player:set_properties({ nametag_color = "#ffff00" })
|
||||
else
|
||||
player:set_properties({ nametag_color = "#00ff00" })
|
||||
end
|
||||
end
|
||||
|
||||
bounty.increase = function(player_name, amount)
|
||||
if bounty.data[player_name] then
|
||||
bounty.data[player_name] = bounty.data[player_name] + amount
|
||||
@@ -54,6 +55,7 @@ bounty.increase = function(player_name, amount)
|
||||
end
|
||||
bounty.save()
|
||||
bounty.notify(player_name, amount)
|
||||
bounty.set_nametag_color(player_name)
|
||||
end
|
||||
|
||||
bounty.decrease = function(player_name, amount)
|
||||
@@ -65,6 +67,7 @@ bounty.decrease = function(player_name, amount)
|
||||
end
|
||||
bounty.notify(player_name, -amount)
|
||||
bounty.save()
|
||||
bounty.set_nametag_color(player_name)
|
||||
end
|
||||
|
||||
bounty.register = function(player_name, amount)
|
||||
|
||||
Reference in New Issue
Block a user