Skip to content

Commit

Permalink
test: add hooks_basic
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWii committed Aug 2, 2022
1 parent 060c78c commit 5d6b7a5
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/hooks_basic/beet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: integrity-hooks-basic

data_pack:
load:
- data/test/functions: src

require:
- bolt
- integrity

pipeline:
- mecha

output: dist

meta:
generate_namespace: test
29 changes: 29 additions & 0 deletions examples/hooks_basic/src/main.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from integrity import Hook

function ./load:
say Loading...
Hook.create("load")
say Loaded.
Hook.create("loaded")

with Hook.at("load"):
as @a[tag=!loaded]:
say Loading player
Hook.create("player:load")
tag @s add loaded

with Hook.at("player:load"):
scoreboard players set @s example.score 123
align xyz positioned ~.5 ~.5 ~.5 expand:
Hook.create("player:load/centered")
tag @s remove abc

with Hook.at("player:load/centered"):
setblock ~ ~ ~ stone

with Hook.at("player:load/centered"):
particle flame ~ ~ ~ 0 0 0 0.1 1 force


with Hook.at("loaded"):
scoreboard players reset @a *
4 changes: 4 additions & 0 deletions examples/hooks_basic/src/other.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from integrity import Hook

with Hook.at("load"):
scoreboard players set @a other.test 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
say Loading...
execute as @a[tag=!loaded] run function test:main/nested_execute_0
scoreboard players set @a other.test 0
say Loaded.
scoreboard players reset @a *
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
say Loading player
scoreboard players set @s example.score 123
execute align xyz positioned ~0.5 ~0.5 ~0.5 run setblock ~ ~ ~ stone
execute align xyz positioned ~0.5 ~0.5 ~0.5 run particle flame ~ ~ ~ 0 0 0 0.1 1 force
tag @s remove abc
tag @s add loaded
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 10,
"description": ""
}
}

0 comments on commit 5d6b7a5

Please sign in to comment.