Ported greetings, rules and spree messages to TOML format

This commit is contained in:
Timo Smit 2017-03-15 13:43:16 +01:00
parent 90c5af82dc
commit 39caf003a7
11 changed files with 274 additions and 192 deletions

View File

@ -1,8 +0,0 @@
[level]
level = 0
greeting = Welcome ^7[N]^9!
[user]
guid = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
greeting = Welcome the console!

7
config/greetings.toml Normal file
View File

@ -0,0 +1,7 @@
[[level]]
level = 0
greeting = "Welcome ^7[N]^9!"
[[user]]
guid = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
greeting = "Welcome the console!"

View File

@ -1,40 +0,0 @@
[rule]
shortcut = sk
rule = ^1NO ^7spawnkilling^9!
[rule]
shortcut = tk
rule = ^1NO ^7teamkilling^9!
[rule]
shortcut = tb
rule = ^1NO ^7teambleeding^9!
[rule]
shortcut = xp
rule = ^1NO ^7XP whoring^9!
[rule]
shortcut = lan
rule = ^7English ^9in ^7main ^9and ^7team chat^9.
[rule]
shortcut = chat
rule = ^1NO ^7insulting ^9or ^7swearing^9!
[rule]
shortcut = advert
rule = ^7Do ^1NOT ^7advertise^9!
[rule]
shortcut = push
rule = ^7Do ^1NOT ^9push your ^7team mates^9!
[rule]
shortcut = level
rule = ^7Do ^1NOT ^9ask for ^7admin levels^9!
[rule]
shortcut = bug
rule = ^7Do ^1NOT ^9use ^7map bugs^9/^7exploits^9!

39
config/rules.toml Normal file
View File

@ -0,0 +1,39 @@
[[rule]]
shortcut = "sk"
rule = "^1NO ^7spawnkilling^9!"
[[rule]]
shortcut = "tk"
rule = "^1NO ^7teamkilling^9!"
[[rule]]
shortcut = "tb"
rule = "^1NO ^7teambleeding^9!"
[[rule]]
shortcut = "xp"
rule = "^1NO ^7XP whoring^9!"
[[rule]]
shortcut = "lan"
rule = "^7English ^9in ^7main ^9and ^7team chat^9."
[[rule]]
shortcut = "chat"
rule = "^1NO ^7insulting ^9or ^7swearing^9!"
[[rule]]
shortcut = "advert"
rule = "^7Do ^1NOT ^7advertise^9!"
[[rule]]
shortcut = "push"
rule = "^7Do ^1NOT ^9push your ^7team mates^9!"
[[rule]]
shortcut = "level"
rule = "^7Do ^1NOT ^9ask for ^7admin levels^9!"
[[rule]]
shortcut = "bug"
rule = "^7Do ^1NOT ^9use ^7map bugs^9/^7exploits^9!"

View File

@ -1,100 +0,0 @@
[kill]
amount = 5
msg = ^dis on a ^2killing spree^d!
sound = killingspree.wav
[kill]
amount = 10
msg = ^dis on a ^2rampage^d!
sound = rampage.wav
[kill]
amount = 15
msg = ^dis ^2dominating^d!
sound = dominating.wav
[kill]
amount = 20
msg = ^drevels in his ^2bloodbath^d!
sound = unstoppable.wav
[kill]
amount = 25
msg = ^dis a walking ^2slaughterhouse^d!
sound = godlike.wav
[kill]
amount = 30
msg = ^dwreaks ^2havoc ^dupon his foes^d!
sound = wickedsick.wav
[kill]
amount = 35
msg = ^dcuts through enemies like a ^2god ^2of ^2war^d!
sound = potter.wav
[kill]
amount = 40
msg = ^dis the ^2prophet of doom^d!
sound = holyshit.wav
[death]
amount = 10
msg = ^dmust be having a bad day!
sound = humiliation.wav
[death]
amount = 15
msg = ^dhis day just got worse!
sound = humiliation.wav
[death]
amount = 20
msg = ^dtries to kill with flowers!
sound = humiliation.wav
[death]
amount = 25
msg = ^dis getting his ass kicked!
sound = humiliation.wav
[death]
amount = 30
msg = ^dis a death magnet!
sound = humiliation.wav
[death]
amount = 40
msg = ^dneeds remedial combat training!
sound = humiliation.wav
[death]
amount = 50
msg = ^dstill can't kill shit!
sound = humiliation.wav
[revive]
amount = 3
msg = ^dis on a ^2revive spree^d!
sound =
[revive]
amount = 5
msg = ^dis a ^2health dealer^d!
sound =
[revive]
amount = 10
msg = ^dis a ^2perfect nurse^d!
sound =
[revive]
amount = 15
msg = ^dis a ^2syringe maniac^d!
sound =
[revive]
amount = 25
msg = ^dis the new ^2Dr. Frankenstein^d!
sound =

94
config/sprees.toml Normal file
View File

@ -0,0 +1,94 @@
[[kill]]
amount = 5
msg = "^dis on a ^2killing spree^d!"
sound = "killingspree.wav"
[[kill]]
amount = 10
msg = "^dis on a ^2rampage^d!"
sound = "rampage.wav"
[[kill]]
amount = 15
msg = "^dis ^2dominating^d!"
sound = "dominating.wav"
[[kill]]
amount = 20
msg = "^drevels in his ^2bloodbath^d!"
sound = "unstoppable.wav"
[[kill]]
amount = 25
msg = "^dis a walking ^2slaughterhouse^d!"
sound = "godlike.wav"
[[kill]]
amount = 30
msg = "^dwreaks ^2havoc ^dupon his foes^d!"
sound = "wickedsick.wav"
[[kill]]
amount = 35
msg = "^dcuts through enemies like a ^2god ^2of ^2war^d!"
sound = "potter.wav"
[[kill]]
amount = 40
msg = "^dis the ^2prophet of doom^d!"
sound = "holyshit.wav"
[[death]]
amount = 10
msg = "^dmust be having a bad day!"
sound = "humiliation.wav"
[[death]]
amount = 15
msg = "^dhis day just got worse!"
sound = "humiliation.wav"
[[death]]
amount = 20
msg = "^dtries to kill with flowers!"
sound = "humiliation.wav"
[[death]]
amount = 25
msg = "^dis getting his ass kicked!"
sound = "humiliation.wav"
[[death]]
amount = 30
msg = "^dis a death magnet!"
sound = "humiliation.wav"
[[death]]
amount = 40
msg = "^dneeds remedial combat training!"
sound = "humiliation.wav"
[[death]]
amount = 50
msg = "^dstill can't kill shit!"
sound = "humiliation.wav"
[[revive]]
amount = 3
msg = "^dis on a ^2revive spree^d!"
[[revive]]
amount = 5
msg = "^dis a ^2health dealer^d!"
[[revive]]
amount = 10
msg = "^dis a ^2perfect nurse^d!"
[[revive]]
amount = 15
msg = "^dis a ^2syringe maniac^d!"
[[revive]]
amount = 25
msg = "^dis the new ^2Dr. Frankenstein^d!"

View File

@ -48,10 +48,10 @@ welcome = "^dwolfadmin: ^9This server is running WolfAdmin, type ^7/wolfadmin ^9
area = 3
[rules]
file = "rules.cfg"
file = "rules.toml"
[greetings]
file = "greetings.cfg"
file = "greetings.toml"
area = 3
bots = 1
@ -59,6 +59,6 @@ bots = 1
bots = 1
[sprees]
file = "sprees.cfg"
file = "sprees.toml"
messages = 7
records = 1

View File

@ -19,6 +19,8 @@ local events = require (wolfa_getLuaPath()..".util.events")
local files = require (wolfa_getLuaPath()..".util.files")
local settings = require (wolfa_getLuaPath()..".util.settings")
local toml = require "toml"
local rules = {}
local data = {}
@ -38,17 +40,41 @@ function rules.load()
return 0
end
local amount, array = files.loadFromCFG(fileName, "[a-z]+")
if string.find(fileName, ".toml") == string.len(fileName) - 4 then
local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ)
local fileString = et.trap_FS_Read(fileDescriptor, fileLength)
if amount == 0 then return 0 end
et.trap_FS_FCloseFile(fileDescriptor)
for _, rule in ipairs(array["rule"]) do
if rule["shortcut"] and rule["rule"] then
data[rule["shortcut"]] = rule["rule"]
local fileTable = toml.parse(fileString)
local amount
for _, rule in ipairs(fileTable["rule"]) do
if rule["shortcut"] and rule["rule"] then
data[rule["shortcut"]] = rule["rule"]
end
end
return amount
else
-- compatibility for 1.1.* and lower
outputDebug("Using .cfg files is deprecated as of 1.2.0. Please consider updating to .toml files.", 3)
local amount, array = files.loadFromCFG(fileName, "[a-z]+")
if amount == 0 then return 0 end
for _, rule in ipairs(array["rule"]) do
if rule["shortcut"] and rule["rule"] then
data[rule["shortcut"]] = rule["rule"]
end
end
return amount
end
return amount
return 0
end
function rules.oninit(levelTime, randomSeed, restartMap)

View File

@ -27,6 +27,8 @@ local events = require (wolfa_getLuaPath()..".util.events")
local files = require (wolfa_getLuaPath()..".util.files")
local settings = require (wolfa_getLuaPath()..".util.settings")
local toml = require "toml"
local sprees = {}
sprees.RECORD_KILL = 0
@ -101,35 +103,63 @@ function sprees.load()
end
end
local fileName = settings.get("g_fileSprees")
for i = 0, sprees.RECORD_NUM - 1 do
spreeMessages[i] = {}
spreeMessagesByType[i] = {}
end
local fileName = settings.get("g_fileSprees")
if fileName == "" then
return 0
end
local amount, array = files.loadFromCFG(fileName, "[a-z]+")
if string.find(fileName, ".toml") == string.len(fileName) - 4 then
local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ)
local fileString = et.trap_FS_Read(fileDescriptor, fileLength)
for name, block in pairs(array) do
for _, spree in ipairs(block) do
if spree["msg"] then
for k, v in pairs(spree) do
if k == "amount" then
spree[k] = tonumber(v)
end
et.trap_FS_FCloseFile(fileDescriptor)
local fileTable = toml.parse(fileString)
local amount
for name, block in pairs(fileTable) do
for _, spree in ipairs(block) do
if spree["msg"] then
table.insert(spreeMessagesByType[sprees.getRecordTypeByName(name)], spree)
spreeMessages[sprees.getRecordTypeByName(name)][spree["amount"]] = spree
end
table.insert(spreeMessagesByType[sprees.getRecordTypeByName(name)], spree)
spreeMessages[sprees.getRecordTypeByName(name)][spree["amount"]] = spree
end
end
return amount
else
-- compatibility for 1.1.* and lower
outputDebug("Using .cfg files is deprecated as of 1.2.0. Please consider updating to .toml files.", 3)
local amount, array = files.loadFromCFG(fileName, "[a-z]+")
for name, block in pairs(array) do
for _, spree in ipairs(block) do
if spree["msg"] then
for k, v in pairs(spree) do
if k == "amount" then
spree[k] = tonumber(v)
end
end
table.insert(spreeMessagesByType[sprees.getRecordTypeByName(name)], spree)
spreeMessages[sprees.getRecordTypeByName(name)][spree["amount"]] = spree
end
end
end
return amount
end
return amount
return 0
end
function sprees.save()

View File

@ -25,6 +25,8 @@ local events = require (wolfa_getLuaPath()..".util.events")
local settings = require (wolfa_getLuaPath()..".util.settings")
local files = require (wolfa_getLuaPath()..".util.files")
local toml = require "toml"
local greetings = {}
local userGreetings = {}
@ -86,29 +88,61 @@ function greetings.load()
return 0
end
local amount, array = files.loadFromCFG(fileName, "[a-z]+")
if string.find(fileName, ".toml") == string.len(fileName) - 4 then
local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ)
local fileString = et.trap_FS_Read(fileDescriptor, fileLength)
if amount == 0 then return 0 end
et.trap_FS_FCloseFile(fileDescriptor)
for _, greeting in ipairs(array["level"]) do
if greeting["text"] then
levelGreetings[tonumber(greeting["level"])] = {
["text"] = greeting["greeting"],
["sound"] = greeting["sound"],
}
local fileTable = toml.parse(fileString)
for _, greeting in ipairs(fileTable["level"]) do
if greeting["greeting"] then
levelGreetings[greeting["level"]] = {
["text"] = greeting["greeting"],
["sound"] = greeting["sound"]
}
end
end
for _, greeting in ipairs(fileTable["user"]) do
if greeting["greeting"] then
userGreetings[greeting["guid"]] = {
["text"] = greeting["greeting"],
["sound"] = greeting["sound"]
}
end
end
return #fileTable["level"] + #fileTable["user"]
else
-- compatibility for 1.1.* and lower
outputDebug("Using .cfg files is deprecated as of 1.2.0. Please consider updating to .toml files.", 3)
local amount, array = files.loadFromCFG(fileName, "[a-z]+")
for _, greeting in ipairs(array["level"]) do
if greeting["text"] then
levelGreetings[tonumber(greeting["level"])] = {
["text"] = greeting["greeting"],
["sound"] = greeting["sound"]
}
end
end
for _, greeting in ipairs(array["user"]) do
if greeting["text"] then
userGreetings[greeting["guid"]] = {
["text"] = greeting["greeting"],
["sound"] = greeting["sound"]
}
end
end
return amount
end
for _, greeting in ipairs(array["user"]) do
if greeting["text"] then
userGreetings[greeting["guid"]] = {
["text"] = greeting["greeting"],
["sound"] = greeting["sound"],
}
end
end
return amount
return 0
end
function greetings.oninit(levelTime, randomSeed, restartMap)

View File

@ -23,9 +23,9 @@ local settings = {}
local data = {
["g_logChat"] = "chat.log",
["g_logAdmin"] = "admin.log",
["g_fileGreetings"] = "greetings.cfg",
["g_fileRules"] = "rules.cfg",
["g_fileSprees"] = "sprees.cfg",
["g_fileGreetings"] = "greetings.toml",
["g_fileRules"] = "rules.toml",
["g_fileSprees"] = "sprees.toml",
["g_playerHistory"] = 1,
["g_spreeMessages"] = 7,
["g_spreeRecords"] = 1,