CASTING_SPELL = nil --AddLUACSFolder("spellminigames") --A table of spells to functions? Spells = {} --[[ ["fireball"] = { ["minigame"] = connectthedots, ["interupt"] = connectextradots, ["difficulty"] = 1 } }]]-- function loadgames() GAMEMODE.minigames = {} local Folder = GAMEMODE.Folder:gsub("gamemodes/","").."/gamemode/hud/" print("WS2A:Looking for minigames in:" .. Folder) local games = file.Find(Folder.."*","LUA") local game = {} print("WS2A:Loading " .. #(games) .. " minigames") for k,v in pairs(games) do print(k) print(v) --[[ if (v != "base.lua") then AddCSLuaFile(Folder.."/"..v) include(Folder.."/"..v) if((not game.Name) or (not game.minigame) or (not game.interupt)) then print("WS2A:Error loading " .. Folder .. "/" .. v .. "One or more of the are missing: Name, minigame, interupt") continue else print("WS2A:Loaded " .. Folder .. "/" .. v) end table.insert(GAMEMODE.Spells,{ Spell.Name }) NPC = table.Copy(BaseItem) end ]]-- end end hook.Add("Initialize","Loadspells",function() loadgames() end) concommand.Add("reloadgames",function(ply,cmd,args) loadgames() end) function StartMinigame(spell) print("starting " .. spell) if not spell then return end --If we're already casting, and are told to cast again do someting. if CASTING_SPELL != nil then CASTING_SPELL["interupt"]() return end if spells[spell] then CASTING_SPELL = spells[spell] spells[spell]["minigame"](spells[spell]["difficulty"]) else print("Could not find spell " .. spell) end end function DrawSpellOverlay() if(CASTING_SPELL) then CASTING_SPELL["minigame"]() end end concommand.Add("startminigame",function(ply,cmd,args) print("Starting " .. args[1]) StartMinigame(args[1]) end)