#----------------------------------------------------------------------- # METADATA UTILITY script, get exbit, sl, bit, begin variable(meta, n) meta := first child(sl) n := get slice extra(meta, extra 0) if(n,and,2^bit) then(exit returning(true)) exit returning(false) end script, set exbit, sl, bit, value=1, begin variable(meta, n) meta := first child(sl) n := get slice extra(meta, extra 0) if(value) then(n := n, or, 2^bit) else(n := n, and, (-1, xor, 2^bit)) set slice extra(meta, extra 0, n) end script, init metadata, sl, begin variable(meta) meta := create container(0, 0) set slice visible(meta, false) set parent(meta, sl) # Values set direction(sl, 1) set update callback(sl, none) set touch callback(sl, none) set force x(sl, 0) set force y(sl, 0) set anim collection(sl, 0) set anim group(sl, -1) set anim frame(sl, -1) set anim frame state(sl, 0) set antifriction(sl, 0) set walk max(sl, 0) set attacking(sl, 0) # Bits set remove me(sl, false) set standing on obstructable(sl, false) set touching floor(sl, false) set touching ceiling(sl, false) set crouching(sl, false) set can crouch(sl, false) set immobile(sl, false) set transition anim needed(sl, false) end #----------------------------------------------------------------------- # METADATA # extra 0 = flipped # extra 1 = force y # extra 2 = force x # first child # extra 0 = bitsets # extra 1 = walk max # extra 2 = anim collection # x = anim group # y = anim frame # width = touch callback # height = antifriction ticks # pad top = update callback # pad right = anim frame state # pad bottom = attacking script, get direction, sl, begin exit returning(get slice extra(sl, extra 0)) end script, set direction, sl, v, begin set slice extra(sl, extra 0, v) end script, run update callback, sl, begin variable(cb) cb := get top padding(first child(sl)) if(cb) then(run script by id(cb, sl)) end script, set update callback, sl, v, begin set top padding(first child(sl), v) end script, run touch callback, sl, begin variable(cb) cb := slice width(first child(sl)) if(cb) then(run script by id(cb, sl)) end script, set touch callback, sl, value, begin set slice width(first child(sl), value) end script, push force y, sl, change, begin set force y(sl, get force y(sl) + change) end script, set force y, sl, value, begin variable(tv) tv := terminal velocity value := bounds(value, tv*-1, tv) set slice extra(sl, extra 1, value) end script, get force y, sl, begin exit returning(get slice extra(sl, extra 1)) end script, push force x, sl, change, begin set force x(sl, get force x(sl) + change) end script, set force x, sl, value, begin variable(tv) tv := terminal velocity value := bounds(value, tv*-1, tv) set slice extra(sl, extra 2, value) end script, get force x, sl, begin exit returning(get slice extra(sl, extra 2)) end script, get antifriction, sl, begin exit returning(slice height(first child(sl))) end script, set antifriction, sl, value, begin set slice height(first child(sl), value) end script, get walk max, sl, begin exit returning(get slice extra(first child(sl), extra 1)) end script, set walk max, sl, value, begin set slice extra(first child(sl), extra 1, value) end script, get anim collection, sl, begin exit returning(get slice extra(first child(sl), extra 2)) end script, set anim collection, sl, value, begin set slice extra(first child(sl), extra 2, value) end script, get anim group, sl, begin exit returning(slice x(first child(sl))) end script, set anim group, sl, value, begin set slice x(first child(sl), value) end script, get anim frame, sl, begin exit returning(slice y(first child(sl))) end script, set anim frame, sl, value, begin set slice y(first child(sl), value) end script, get anim frame state, sl, begin exit returning(get right padding(first child(sl))) end script, set anim frame state, sl, value, begin set right padding(first child(sl), value) end script, get attacking, sl, begin exit returning(get bottom padding(first child(sl))) end script, set attacking, sl, value, begin set bottom padding(first child(sl), value) end #BITS script, get remove me, sl ( exit returning(get exbit(sl, 1)) ) script, set remove me, sl, value ( set exbit(sl, 1, value) ) script, get standing on obstructable, sl ( exit returning(get exbit(sl, 2)) ) script, set standing on obstructable, sl, v ( set exbit(sl, 2, v) ) script, get touching floor, sl ( exit returning(get exbit(sl, 3)) ) script, set touching floor, sl, v ( set exbit(sl, 3, v) ) script, get touching ceiling, sl ( exit returning(get exbit(sl, 4)) ) script, set touching ceiling, sl, v ( set exbit(sl, 4, v) ) script, get crouching, sl ( exit returning(get exbit(sl, 5)) ) script, set crouching, sl, v, begin variable(old) old := get exbit(sl, 5) if(v && old <> v) then( # start crouching set transition anim needed(sl, true) ) set exbit(sl, 5, v) end script, get can crouch, sl ( exit returning(get exbit(sl, 6)) ) script, set can crouch, sl, v ( set exbit(sl, 6, v) ) script, get immobile, sl ( exit returning(get exbit(sl, 7)) ) script, set immobile, sl, v ( set exbit(sl, 7, v) ) script, get transition anim needed, sl ( exit returning(get exbit(sl, 8)) ) script, set transition anim needed, sl, v ( set exbit(sl, 8, v) )