Skip to content

Commit

Permalink
Ported greetings, rules and spree messages to TOML format
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo Smit committed Mar 15, 2017
1 parent 90c5af8 commit 39caf00
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 190 deletions.
8 changes: 0 additions & 8 deletions config/greetings.cfg

This file was deleted.

7 changes: 7 additions & 0 deletions config/greetings.toml
@@ -0,0 +1,7 @@
[[level]]
level = 0
greeting = "Welcome ^7[N]^9!"

[[user]]
guid = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
greeting = "Welcome the console!"
40 changes: 0 additions & 40 deletions config/rules.cfg

This file was deleted.

39 changes: 39 additions & 0 deletions config/rules.toml
@@ -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!"
100 changes: 0 additions & 100 deletions config/sprees.cfg

This file was deleted.

94 changes: 94 additions & 0 deletions config/sprees.toml
@@ -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!"
6 changes: 3 additions & 3 deletions config/wolfadmin.toml
Expand Up @@ -48,17 +48,17 @@ 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

[records]
bots = 1

[sprees]
file = "sprees.cfg"
file = "sprees.toml"
messages = 7
records = 1
38 changes: 32 additions & 6 deletions luamods/wolfadmin/admin/rules.lua
Expand Up @@ -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 = {}
Expand All @@ -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)

et.trap_FS_FCloseFile(fileDescriptor)

local fileTable = toml.parse(fileString)

if amount == 0 then return 0 end
local amount

for _, rule in ipairs(array["rule"]) do
if rule["shortcut"] and rule["rule"] then
data[rule["shortcut"]] = rule["rule"]
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)
Expand Down

0 comments on commit 39caf00

Please sign in to comment.