-
-
Save DaZombieKiller/3e37dec3c1ea4cf033e1d7b5ad3056ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setmetatable(_G, | |
{ | |
__index = function(t, k) | |
-- return string for nonexistent values | |
-- saves needing to manually specify each value | |
return k | |
end, | |
}) | |
function addsoundentry(name, id, pri, pitch_lo, pitch_hi, voc_num, voc_dist, voc_flags) | |
return | |
{ | |
name = name, | |
id = id, | |
pri = pri, | |
pitch_lo = pitch_lo, | |
pitch_hi = pitch_hi, | |
voc_num = voc_num, | |
voc_dist = voc_dist, | |
voc_flags = voc_flags, | |
} | |
end | |
function addcommentsection(name) | |
return { comment = name } | |
end | |
local data = | |
{ | |
-- simple copy/paste then find+replace in selection "\n" -> ",\n" | |
addcommentsection "Sound entries", | |
addsoundentry("NULL.VOC", DIGI_NULL, 0, 0, 0, 0, DIST_NORMAL, VF_NORMAL), | |
addcommentsection "Sword", | |
addsoundentry("SWRDSTR1.VOC", DIGI_SWORDSWOOSH, PRI_HI_PLAYERWEAP, -200, 200, 0, DIST_NORMAL, VF_NORMAL), | |
addcommentsection "Shuriken", | |
addsoundentry("THROW.VOC", DIGI_STAR, PRI_HI_PLAYERWEAP, -100, 100, 0, DIST_NORMAL, VF_NORMAL), | |
addsoundentry("STRCLNK.VOC", DIGI_STARCLINK, PRI_PLAYERAMBIENT, 0, 0, 0, DIST_NORMAL, VF_NORMAL), | |
addsoundentry("NULL.VOC", DIGI_NULL_STARWIZ, PRI_LOW_PLAYERWEAP, 0, 0, 0, DIST_NORMAL, VF_LOOP), | |
addcommentsection "Uzi", | |
addsoundentry("UZIFIRE1.VOC", DIGI_UZIFIRE, PRI_HI_PLAYERWEAP, 0, 0, 0, DIST_NORMAL, VF_NORMAL), | |
} | |
local file = io.open("out.lua", "wb") | |
file:write "sounds =\n{\n" | |
for i, soundentry in ipairs(data) do | |
if soundentry.comment then | |
file:write(string.format(" -- %s\n", soundentry.comment)) | |
else | |
file:write " {\n" | |
for k, v in pairs(soundentry) do | |
if type(v) == "string" then | |
file:write(string.format(" %s = %q,\n", k, v)) | |
else | |
file:write(string.format(" %s = %s,\n", k, v)) | |
end | |
end | |
file:write " },\n" | |
if i ~= #data then file:write "\n" end | |
end | |
end | |
file:write "}" | |
file:close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment