temporary solution for 4dF

master
hunterdelyx1 2014-10-30 05:37:03 +03:00
parent dfbcacdd5f
commit ca6df6134d
1 changed files with 47 additions and 1 deletions

View File

@ -49,6 +49,9 @@ LEFT_INDENT = 0.01
TOP_INDENT = 0.92
FONT_WIDTH = 12
FONT_HEIGHT = 28
fudge_levels = {"-","terrible--","terrible-","terrible", "poor", "mediocre", "fair", "good", "great", "superb", "legendary", "legendary+", "legendary++","like Allah"}
-- config zone }}}
firsthud = nil
@ -132,12 +135,54 @@ minetest.register_on_chat_message(function(name, message)
end
-- dices
dice = string.match(message, "d(%d+)")
dice = string.match(message, "^d(%d+).*")
if dice=="4" or dice=="6" or dice=="8" or dice=="10" or dice=="12" or dice=="20" then
fmt = "*** %s rolls d"..dice.." and the result is %s ***"
color = DICE_COLOR
submes = math.random(dice)
end
--Temporary solution for 4dF
fudge_dice_tmp = string.match(message, "^4dF (.*)$")
if fudge_dice_tmp~=nil then
for key, val in pairs(fudge_levels) do
fudge_level = string.match(fudge_dice_tmp, "^("..val..".*)")
fudge_level_key = key
if fudge_level~=nil then
diff = 0
signs = ""
for i = 1, 4 do
rand = math.random(3)
if rand == 1 then
diff=diff+1
signs = signs.."+"
elseif rand == 2 then
diff=diff-1
signs = signs.."-"
else
signs = signs.."="
end
end
fmt = "*** %s rolls 4df ("..signs..") from "..fudge_level.." and the result is %s ***"
color = DICE_COLOR
fudge_level_key = fudge_level_key+diff
if fudge_level_key<1 then
fudge_level_key = 1
elseif fudge_level_key>#fudge_levels then
fudge_level_key = #fudge_levels
end
submes = fudge_levels[fudge_level_key]
break
end
end
end
if not submes then
submes = message
end
@ -155,6 +200,7 @@ minetest.register_on_chat_message(function(name, message)
elseif minetest.check_player_privs(pls[i]:get_player_name(), {gm=true}) then
sendMessage(pls[i], string.format(fmt, name, submes), GMSPY_COLOR)
end
print(string.format(fmt, name, submes))
end
return true