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
|
# Level controllers are generic objects designed to be used as triggers for scripts.
# Various usages include modifying:
# - on_create to trigger something on the start of a level.
# - on_triggered to trigger something when the player reaches a certain spot
{
id: "heightmap_platform_controller",
next_animation: "'normal'",
always_active: true,
hidden_in_game: true,
platform_area: [0,0,10],
vars: {
last_triggered: -400,
heightmap: [],
},
on_create: "if(size(vars.heightmap) >= 2,
[set(platform_area, [(vars.heightmap[0][0] - x)/2, 0, (vars.heightmap[size(vars.heightmap)-1][0] - x)/2]),
set(platform_offsets, map(vars.heightmap, value[1] - y))
],
set(platform_area, null),
)",
on_editor_changed_variable: "if(size(vars.heightmap) >= 2,
if(head(vars.heightmap)[0] > back(vars.heightmap)[0]-10,
#don't let the left side cross over the right#
[set(vars.heightmap,
[[back(vars.heightmap)[0]-10, vars.heightmap[0][1]]] +
vars.heightmap[1:]),
fire_event('editor_changed_variable')],
#adjust the vertexes so they are evenly spaced on the x axis#
[set(vars.heightmap, map(vars.heightmap, [
(vars.heightmap[0][0]*r + vars.heightmap[size(vars.heightmap)-1][0]*(1000-r))/1000, value[1]]
where r = (1000*((size(vars.heightmap)-1) - index))/
(size(vars.heightmap)-1))),
fire_event('create')
])
)",
on_end_anim: "animation('normal')",
zorder: 50,
editor_info: {
category: "controllers",
var: [
{
name: "heightmap",
type: "points",
value: "[]",
}
],
},
animation: {
id: "normal",
image: "effects/particles.png",
x: 86,
y: 73,
w: 28,
h: 28,
collide: [0,0,28,28],
frames: 1,
duration: 1000,
},
}
|