Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomised jump-and-return #573

Closed
DinosaurHorseSword opened this issue May 22, 2024 · 1 comment · Fixed by #617
Closed

Randomised jump-and-return #573

DinosaurHorseSword opened this issue May 22, 2024 · 1 comment · Fixed by #617
Assignees
Labels
bug Something isn't working

Comments

@DinosaurHorseSword
Copy link

Is your feature request related to a problem? Please describe.
When writing dialogue, I only use jump-and-return statements and sometimes have random snippets.
Currently, the parser return from the snippet it took and then evaluates again the siblings until all blocks have been reached.
The current solutions either break the chain of jump-and-return or are tedious to write and difficult to read.

~ dialogue
before
% =>< snippet_0
% =>< snippet_1
% =>< snippet_2
after
=> END!
# outputs before, snippet_0/1/2 and each  following sibling, after

Describe the solution you'd like
Parity with randomized jump, the jump-and-return solution should output the same as the jump.

~ dialogue
before
% => snippet_0
% => snippet_1
% => snippet_2
after
=> END!
# outputs "before, snippet_0/1/2, after"

Describe alternatives you've considered
Two work-arounds, one that breaks the chain of jump-and-return:

~ dialogue
before
% => snippet_0
% => snippet_1
% => snippet_2

~ dialogue_next
after
=> END!

~ snippet_0
0
=> dialogue_next

~ snippet_1
1
=> dialogue_next

~ snippet_2
2
=> dialogue_next

And the other, that is less readable and requires to have an autoload:

# autoload.gd
var rdm: int
var rng: RandomNumberGenerator = RandomNumberGenerator.new()

# dialogue resource
~ dialogue
before

set rdm = rng.randi_range(0, 2)
if rdm == 0:
    =>< snippet_0
elif rdm == 1:
    =>< snippet_1
elif rdm == 2:
    =>< snippet_2

after
=> END!
@DinosaurHorseSword DinosaurHorseSword added the enhancement New feature or request label May 22, 2024
@nathanhoad nathanhoad added bug Something isn't working and removed enhancement New feature or request labels May 23, 2024
@nathanhoad
Copy link
Owner

Yeah randomised jump-and-returns should behave the same as jumps so that's currently a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants