aboutsummaryrefslogtreecommitdiff
path: root/gamemode/hud/draw_spell.lua
diff options
context:
space:
mode:
authorAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-01-30 22:04:03 -0500
committerAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-01-30 22:04:03 -0500
commit41342f0b0fd915ddeebe9ba783faab9446037c2e (patch)
treecfadfb5b43f668e14be2fbe73c64234673f6f1df /gamemode/hud/draw_spell.lua
parent739c79882fb0c21bd353a7dec896421bda435a87 (diff)
downloadwintersurvival2-41342f0b0fd915ddeebe9ba783faab9446037c2e.tar.gz
wintersurvival2-41342f0b0fd915ddeebe9ba783faab9446037c2e.tar.bz2
wintersurvival2-41342f0b0fd915ddeebe9ba783faab9446037c2e.zip
More work on the connect the dots minigame
Diffstat (limited to 'gamemode/hud/draw_spell.lua')
-rw-r--r--gamemode/hud/draw_spell.lua76
1 files changed, 57 insertions, 19 deletions
diff --git a/gamemode/hud/draw_spell.lua b/gamemode/hud/draw_spell.lua
index 96440e4..b68e988 100644
--- a/gamemode/hud/draw_spell.lua
+++ b/gamemode/hud/draw_spell.lua
@@ -19,6 +19,7 @@ Games = {}
function loadgames()
includedfiles = {}
+ Games = {}
print("Looking for what minigames we need...")
for k,v in pairs(Spells) do
local filename = v["file"]
@@ -34,36 +35,73 @@ function loadgames()
Game = {}
include(Folder .. "/" .. k)
Games[k] = Game
+ print("Loaded game:")
+ PrintTable(Game,1)
end
print("Resolveing minigame names")
+ print("All games:")
+ PrintTable(Games,1)
+ print("All spells:")
+ PrintTable(Spells)
+ local needefunctions = {"minigame","draw","interupt"}
for k,v in pairs(Spells) do
+ local spell = v
+ print("Resolveing spell:")
+ PrintTable(Spells)
+ local gametab = Games[v["file"]]
+ if not gametab then
+ print("Coudln't find " .. v["file"] .. " in games")
+ end
+ for i,j in pairs(gametab) do
+ local issimple = false
+ for l,m in pairs(spell) do
+ print("Checking if ",m,"is",i)
+ if(m == i) then
+ print("Overloading " .. m)
+ spell[l] = j
+ issimple = true
+ break
+ end
+ end
+ if not issimple then
+ spell[i] = j
+ end
+ end
+ --[[
local mgname = v["minigame"]
local mginame = v["interupt"]
local mgdname = v["draw"]
for i,j in pairs(Games) do
if i == v["file"] then
- print("Resolved " .. k)
- local castfunc = j[mgname]
- local drawfunc = j[mgdname]
- local interuptfunc = j[mginame]
- if(castfunc) then
- v["minigame"] = castfunc
- else
- print("Spell " .. k .. " does not have a cast func! This may be an error!")
- end
- if(drawfunc) then
- v["draw"] = drawfunc
- else
- print("Spell " .. k .. " does not have a draw func! This may be an error!")
- end
- if(interuptfunc) then
- v["interupt"] = interuptfunc
- else
- print("Spell " .. k .. " does not have an interupt func! This may be an error!")
+ for l,m in pairs(j) do
+ Spells[k][l] = m
+ print("Resolved " .. k)
+ local castfunc = j[mgname]
+ local drawfunc = j[mgdname]
+ local interuptfunc = j[mginame]
+ if(castfunc) then
+ Spells[k]["minigame"] = castfunc
+ else
+ print("Spell " .. k .. " does not have a cast func! This may be an error!")
+ end
+ if(drawfunc) then
+ Spells[k]["draw"] = drawfunc
+ else
+ print("Spell " .. k .. " does not have a draw func! This may be an error!")
+ end
+ if(interuptfunc) then
+ Spells[k]["interupt"] = interuptfunc
+ else
+ print("Spell " .. k .. " does not have an interupt func! This may be an error!")
+ end
end
end
+ Spells[k] = j
end
+ ]]--
end
+ print("After resolveing:")
+ PrintTable(Spells)
end
hook.Add("Initialize","Loadspells",function()
@@ -85,7 +123,7 @@ function StartMinigame(spell)
if Spells[spell] then
CASTING_SPELL = Spells[spell]
- Spells[spell]["minigame"](CASTING_SPELL, Spells[spell]["difficulty"])
+ CASTING_SPELL["minigame"](CASTING_SPELL, CASTING_SPELL["difficulty"])
else
print("Could not find spell " .. spell)
end