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
|
{
id: "match_lock_controller",
next_animation: "'normal'",
always_active: true,
hidden_in_game: true,
vars: {
lit: [],
#matches currently active
won: [],
},
on_create: "[
set(vars.locks, all_locks),
transform(range(size(all_locks)), [
set(all_locks[v].x, new_location[v][0]),
set(all_locks[v].y, new_location[v][1])
]) where new_location = shuffle(transform(all_locks, [v.x, v.y])),
] where all_locks =
filter(level.chars, 'char',
char.type in match_lock_types and char.vars.group = context.self.vars.group
) where match_lock_types = transform(range(17), 'match_lock_${v}')",
#types of matches won
on_match: "if(matched,
if(not not_all, [
transform(now_lit, fire_event(v, 'win')),
set(vars.won, vars.won + [arg.type]),
set(vars.lit, []),
if(size(filter(vars.locks, 'lock', not lock.type in context.vars.won + [context.arg.type])) = 0,
if(linked, fire_event(linked, 'button_pressed'),
debug('ERROR: No linked object for ${self.type} (group ${vars.group}).')
) where linked = get_object(level, vars.linked_object))
],
set(vars.lit, now_lit),
) where not_all = find(filter(self.vars.locks, 'lock', not lock in now_lit), 'lock', lock.type = context.arg.type),
[ set(vars.lit, []),
transform(now_lit, fire_event(v, 'fail')),
])
where now_lit = vars.lit + [arg],
where matched = (size(vars.lit) = size(filter(vars.lit, 'item', item.type = arg.type)))",
on_end_anim: "animation('normal')",
zorder: 100,
editor_info: {
category: "keys & triggers",
help: "One of these is required for every match_lock group.
Place a pair of match_locks, in the keys_&_triggers
folder, and when matched they will fire an event in the
object specified in this controller's linked_object.
Make sure the group variable matches! :)",
var: [
{
name: "group",
type: "int",
value: 1,
},
{
name: "linked_object",
type: "label",
},
],
},
animation: {
id: "normal",
image: "props/match-buttons.png",
x: 0,
y: 0,
w: 32,
h: 32,
collide: [0,0,32,32],
frames: 1,
duration: 1000000000,
},
}
|