Delete me plz\ doubled topic

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
Loopaz
Newbie
Posts: 13
Joined: Thu Apr 12, 2018 4:03 am
Completed: ..asking still the same questions!
Projects: Your choice VN
Location: Poland
Contact:

Delete me plz\ doubled topic

#1 Post by Loopaz »

Unfortunately the code was posded before
by Remix ;P

Delete plz
doubled topic

Hello
Here i have a code for random events made for me by Remix :)

Just sharing :D

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
"I know that I know nothing" :shock:
"Who ask not stray" :roll:
Bad english talker :|
I don't expect miracle. I expect profesionals :3
or do something right or do not do it at all

Post Reply

Who is online

Users browsing this forum: No registered users