-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoal.gplfeimc
More file actions
64 lines (57 loc) · 2.93 KB
/
goal.gplfeimc
File metadata and controls
64 lines (57 loc) · 2.93 KB
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
declare Main f:main # declare entrypoint (declare can also be used to export variables and functions)
require lib:Math # import, returns null if it fails
require lib:Random # import, returns null if it fails
demand interface:FileAccess as fa # import, throws an error if it fails
@main(args) do # function declaration
print(args["1"])
print(args._.1)
$r = fa.open("user://test.txt","w") > The user:// directory uses a unique directory for every app
r = $r # Makes $r a global variable instead of local--- They could've just directly wrote to r, but maybe they have a reason.
if r.status == 0 then
print("test")? # prints debug info
fa.write(r.stream,input())
end
match r.status for
item 0 then print("File Opened Correctly!") end
item Err.DiskFull then
print("Your disk is full!")! # ! means breakpoint. This just logs the current state of the program and waits until [ENTER]/[RETURN] is pressed.
end
end
end
declare GameTick f:gt # can be called from external program via language's embedding API
require foreign interface:GameWorld as gw # `foreign` specifies that it is defined in the host program, if it's being embedded.
require foreign datatype:GameEntity # Since there's no `as`, just as earlier, we default to the name of the entry, GameEntity
time: float = 0.0 # Type declaration optional, you can always just do: time = 0.0
spawned_this_cycle = false # boolean
@gt(delta) do
print(delta)
time += delta
$temp = time # copy time to $temp, a local variable.
$temp !ex{Math.floor(x*2) % 5 == 0 and !spawned_this_cycle} # !ex specifies to apply an expression, where the variable is represented as x. In it, we: Multiply $temp by 2, floor it, checks if it's divisible by five via modulo/remainder and that spawned_this_cycle is false, and then sets $temp to the result.
if $temp then
spawned_this_cycle = true
$zombie = GameEntity.new()
$zombie.model = "./models/zombie.obj"
$zombie.speed = 16
$zombie.speed_unit = $zombie.speed_units.meters_per_second # might be a bit fast
$zombie.damage = gw.get_average_player_health()/5.0 # that's kinda strong
$zombie.health = 1.0
gw.add($zombie,gw.get_spawn_zone(hostile),1)
for item in gw.get_item_spawns() do
gw.item_spawn(item).with(gw.get_loottable("HIGH").get_amount(5)).apply()
end
else
spawned_this_cycle = false
for item in range(5) do
if Random.range(0,500) == 2 then
$zombie = GameEntity.new()
$zombie.model = "./models/zombie_spooky.obj"
$zombie.speed = 10
$zombie.speed_unit = $zombie.speed_units.meters_per_second
$zombie.damage = gw.get_average_player_health()/500.0
$zombie.health = 0.01
gw.add($zombie,gw.get_spawn_zone(hostile),5000) # 5000 zombies
end
end
end
end