-
Notifications
You must be signed in to change notification settings - Fork 0
/
zf_function_wrappers.py
executable file
·93 lines (72 loc) · 2.64 KB
/
zf_function_wrappers.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""
This file holds functions that reproduce the commands available in the editor (http://zetaflow.skylogic.ca/game/edit)
"""
# Note: argument 'parts' is EITHER a single part number (string or int) OR a list (array) of part numbers
def parts_to_string(parts):
if (isinstance(parts, list)):
return ','.join([str(x) for x in parts])
else:
return f'{parts}'
def randomRotate(speed):
return f'randomRotate, {speed:d}'
def makeInvincible(parts):
parts_str = parts_to_string(parts)
return f'makeInvincible, {parts_str}'
def makeVulnerable(parts):
parts_str = parts_to_string(parts)
return f'makeVulnerable, {parts_str}'
def makeTriggerRepeat(START_FRAME, REPEAT_AFTER_FRAMES, ANY_COMMAND):
return 'makeTrigger, timeRepeat, %d, %d, %s' % (START_FRAME, REPEAT_AFTER_FRAMES, ANY_COMMAND)
def makeTriggerDeath(part_num, any_command):
return f'makeTrigger, death, {part_num}, {any_command}'
def makeTriggerTime(START_FRAME, ANY_COMMAND):
return f'makeTrigger, time, {START_FRAME}, {ANY_COMMAND}'
def disableGun(parts):
parts_str = parts_to_string(parts)
return f'disableGun, {parts_str}'
def enableGun(parts):
parts_str = parts_to_string(parts)
return f'enableGun, {parts_str}'
def setDistance(parts, dist):
parts_str = parts_to_string(parts)
return f'setDistance, {dist}, {parts_str}'
def setGunTime(parts, time):
parts_str = parts_to_string(parts)
return f'setGunTime, {time:d}, {parts_str}'
def setWidth(parts, width_percent):
parts_str = parts_to_string(parts)
return f'setWidth, {width_percent:d}, {parts_str}'
def setHeight(parts, height_percent):
parts_str = parts_to_string(parts)
return f'setHeight, {height_percent:d}, {parts_str}'
def setHP(parts, hp):
parts_str = parts_to_string(parts)
return f'setHP, {hp}, {parts_str}'
def setColor(parts, hex_color):
"""
color_hex: e.g. FF0000 for red
"""
parts_str = parts_to_string(parts)
return f'col, {hex_color}, {parts_str}'
def destroy(parts):
parts_str = parts_to_string(parts)
return f'destroy, {parts_str}'
def setSize(parts, percentage):
strs = []
strs.append( setWidth(parts, percentage) )
strs.append( setHeight(parts, percentage) )
return strs
def rotatePartToShip(parts):
parts_str = parts_to_string(parts)
return f'rotatePartToShip, {parts_str}'
def rotate(part, speed, min_angle=None, max_angle=None, start_angle=None):
assert isinstance(part, int)
if (min_angle is None and max_angle is None and start_angle is None):
return f'rotatePart, {part}, {speed}'
else:
assert min_angle is not None
assert max_angle is not None
assert start_angle is not None
return f'rotatePart, {part}, {speed}, {min_angle}, {max_angle}, {start_angle}'
def stop(cmd):
return 'stop, %s' % cmd