aboutsummaryrefslogtreecommitdiffstats
path: root/Scripts/ui.lua
blob: f6c65f226875c64632c562e1b93a31199b09a36d (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
ui = {
    dialog = {
        buf = {},
        idx = 0,
        rdx = 0,

        queue = function(self, text)
            self.idx = self.idx + 1
            self.buf[self.idx] = text

            if self.idx == 1 then
                game.dialog(30, 50, 400, 100)
                game.puts("dialog", 36, 52, text)
            end
        end,

        update = function(self, mx, my)
            if self.idx > 0 then
                if mx > 30 and mx < 430 and my > 50 and my < 150 then
                    self.rdx = self.rdx + 1
                    if self.rdx == self.idx then
                        self.idx = 0
                        self.rdx = 0
                        game.dialogClear()
                    else
                        game.puts("dialog", 36, 52, self.buf[self.rdx + 1])
                    end
                end
            end
        end
    }
}