by Remix ;P
Delete plz
doubled topic
Hello
Here i have a code for random events made for me by Remix
Just sharing
Code: Select all
label choice_jump(*choice_targets):
# *choice_targets can be lists/tuples or just string:
# each argument is a label name with optional weight
# [ 'labelname' (string), 2 (integer weight) ] >> 'labelname', 'labelname'
# Without weight (or if passed as just a string, it defaults to weight 1)
# build a list of weighted choices
$ choice_jumps = [g for h in [
[k[0]]*k[1] for k in [
[j,1] if isinstance(j, basestring)
else j if len(j)>1
else [j[0],1] for j in choice_targets]
]
for g in h]
# choose one from the list
$ choice_target = renpy.random.choice( choice_jumps )
## comment out this to avoid the debug dialogue
"Randomly chose '[choice_target]' after expanding the options to [choice_jumps]"
#
# uncomment this and maybe remove the 'return' once done testing
# jump expression choice_target
return
default luck = 5
label start:
"Start"
call choice_jump( ['label_a',3], ['label_b', 2], ['label_c', 1] )
"Middle"
call choice_jump( ['label_a',luck], ['label_b',2], ['label_c', 1] )
"End"
$ luck = 3
call choice_jump( ['label_a'], ['label_b',luck], ['label_c'] )
return