-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
345 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require: | ||
- bolt | ||
data_pack: | ||
load: "src" | ||
pipeline: | ||
- mecha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from contextlib import contextmanager | ||
|
||
|
||
class LoopAgainAtRuntime: | ||
def __init__(self, name: str): | ||
self.name = name | ||
|
||
def __bool__(self): | ||
function self.name | ||
return False | ||
|
||
|
||
class Tmp: | ||
def __init__(self, name: str = None): | ||
if name is None: | ||
name = ctx.generate.format("tmp{incr}") | ||
self.name = name | ||
|
||
def __dup__(self): | ||
result = Tmp() | ||
result = self | ||
return result | ||
|
||
def __rebind__(self, rhs: object): | ||
if self is rhs: | ||
return self | ||
if isinstance(rhs, Tmp): | ||
scoreboard players operation self.name global = rhs.name global | ||
else: | ||
scoreboard players set self.name global int(rhs) | ||
return self | ||
|
||
@contextmanager | ||
def __branch__(self): | ||
unless score self.name global matches 0: | ||
yield True | ||
|
||
@contextmanager | ||
def __loop__(self): | ||
name = ctx.generate.format(~/ + "/loop{incr}") | ||
execute function name: | ||
yield LoopAgainAtRuntime(name) | ||
|
||
def __not__(self): | ||
result = Tmp() | ||
result = 1 | ||
unless score self.name global matches 0: | ||
result = 0 | ||
return result | ||
|
||
def __eq__(self, rhs: object): | ||
result = Tmp() | ||
result = 0 | ||
if isinstance(rhs, Tmp): | ||
if score self.name global = rhs.name global: | ||
result = 1 | ||
else: | ||
if score self.name global matches int(rhs): | ||
result = 1 | ||
return result | ||
|
||
def __iadd__(self, rhs: object): | ||
if isinstance(rhs, Tmp): | ||
scoreboard players operation self.name global += rhs.name global | ||
else: | ||
scoreboard players add self.name global int(rhs) | ||
return self | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
|
||
def display(value: object): | ||
if isinstance(value, Tmp): | ||
tellraw @a {"score": {"name": value.name, "objective": "global"}} | ||
else: | ||
tellraw @a {"text": f"{value}"} | ||
|
||
|
||
def f(i): | ||
while not i == 4: | ||
display(i) | ||
i += 1 | ||
|
||
a = 0 | ||
f(a) | ||
|
||
b = Tmp("b") | ||
b = 0 | ||
f(b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
append function_tag minecraft:load { | ||
"values": [__name__] | ||
} | ||
|
||
scoreboard objectives add global dummy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.