Convert existing cds using the new system

(cherry picked from commit 4770be5f1b)
This commit is contained in:
Gouvernathor 2024-03-28 22:28:53 +01:00 committed by LoafyLemon
parent 6408942054
commit c5c04ff79e

View File

@ -54,29 +54,31 @@ python early hide:
evaled = {n: eval(e) for n, e in self.items()}
renpy.dynamic(**evaled)
python early:
def parse_chibi(l):
@register_decorator
class chibi:
@staticmethod
def parse(l):
who = l.simple_expression()
action = l.simple_expression()
return (who, action)
def execute_chibi(p):
print(f"{p}")
who, action = p
def execute(self):
print(f"{self}")
who, action = self
func = eval(f"{who}_chibi.{action}")
# print(f"Execution: {who} {action}")
def lint_chibi(p):
who, action = p
def lint(self):
who, action = self
try:
chibi = eval(f"{who}_chibi")
except Exception:
renpy.error(f"Character chibi not defined: {who}")
def predict_chibi(p):
who, action = p
def predict(self):
who, action = self
chibi = eval(f"{who}_chibi")
doll = eval(f"{who}")
@ -89,15 +91,13 @@ python early:
return layers
renpy.register_statement(
name="chibi",
parse=parse_chibi,
execute=execute_chibi,
lint=lint_chibi,
predict=predict_chibi,
)
@register_decorator
class random:
block = True
predict_all = True
def parse_random(l):
@staticmethod
def parse(l):
l.require(":")
l.expect_eol()
@ -127,8 +127,8 @@ python early:
return {"blocks": blocks}
def next_random(p):
blocks = [(block, weight) for block, weight, condition in p["blocks"] if eval(condition)]
def next(self):
blocks = [(block, weight) for block, weight, condition in self["blocks"] if eval(condition)]
total_weight = sum(weight for _, weight in blocks)
n = renpy.random.random() * total_weight
@ -139,11 +139,3 @@ python early:
n -= weight
return block
renpy.register_statement(
name="random",
block=True,
predict_all=True,
parse=parse_random,
next=next_random,
)