-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuiltin_level_4.lua
70 lines (61 loc) · 1.26 KB
/
builtin_level_4.lua
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
function __reset_button_states()
__button_states = {}
for i = 1,6 do
__button_states[i] = __new_unknown_boolean()
end
end
function btn(i)
-- TODO What happens if this is called during _draw? Are the values guaranteed
-- to be consistent with _update?
__assert(i >= 0)
__assert(i <= 5)
i = i + 1
-- This weird if statement concretizes the button
-- state the first time it is read.
if __button_states[i] then
__button_states[i] = true
return true
else
__button_states[i] = false
return false
end
end
function count(v)
-- TODO crash when a second argument is called
return #v
end
function del(list, target)
if #list == 0 then
return nil
end
local found = false
local found_value = nil
for i=1,32767 do
if i > #list then
break
end
if not found then
local v = list[i]
if v == target then
found = true
found_value = v
end
end
if found and (i + 1) <= #list then
list[i] = list[i + 1]
end
end
if found then
__array_table_drop_last(list)
end
return found_value
end
-- Noop functions
function print() end
function music() end
function sfx() end
function pal() end
function rectfill() end
function map() end
function spr() end
function circfill() end