aboutsummaryrefslogtreecommitdiff
path: root/gamemode/hud/draw_spell.lua
blob: c1879ef8faef05d9dfc1f54f82341fcf8210b007 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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)