Lemma Soft Forums

Supporting creators of visual novels and story-based games since 2003.


Visit our new games list, blog aggregator, IRC, and wiki.
Activation problem? Email [email protected]
It is currently Thu May 23, 2013 9:22 am

All times are UTC - 5 hours [ DST ]


Forum rules


Ask questions about one topic per thread, and use a descriptive subject. "NotImplemented error in script.rpy" is a good subject, "Tom's problems" is not. Remember to include all of traceback.txt or error.txt when reporting a problem, as well as the relevant lines of script. Use the [code] tag to format scripts.



Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
PostPosted: Wed Jan 14, 2009 7:36 pm 
Eileen-Class Veteran
User avatar

Joined: Fri Aug 31, 2007 7:02 am
Posts: 1265
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Well I know of a roundabout way but as usual it's inefficient so use it at your own discretion. Here an example of the code:
Code:
label first_value:
    $ value1=renpy.random.choice([1, 2, 3])
label second_value:
    $ value2=renpy.random.choice([1, 2, 3])
    if value1==value2:
        jump second_value
label third_value:
    $ value3=renpy.random.choice([1, 2, 3])
    if value1==value3 or value2==value3:
        jump third_value

This code will ensure all the values you get are different but it's a big mess if you intend to use 1000s of choices.

_________________
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.


Top
 Profile Send private message  
 
PostPosted: Wed Jan 14, 2009 7:52 pm 
Miko-Class Veteran
User avatar

Joined: Tue Jul 24, 2007 12:58 pm
Posts: 526
BCS wrote:
I wonder if there is any way to prevent a random container from selecting the same thing twice ... ?


Try using remove.

Code:
    $ squiggle = [1, 2, 3, 4, 5]
    label abc:
        pass
   
   
    $ mychoice = renpy.random.choice(squiggle)
   
    "You chose %(mychoice)s."
    $ squiggle.remove(mychoice)
    jump abc


It gives an error once you've run out of choices, though.

Similarly, append adds things to lists.


Top
 Profile Send private message  
 
PostPosted: Wed Jan 14, 2009 8:08 pm 
Eileen-Class Veteran
User avatar

Joined: Fri Aug 31, 2007 7:02 am
Posts: 1265
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Showni way is better if you don't plan to have choices that have been chosen be chosen again. Showsni method is less messy and more efficient than mine.

_________________
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.


Top
 Profile Send private message  
 
PostPosted: Wed Jan 14, 2009 10:13 pm 
Eileen-Class Veteran
User avatar

Joined: Mon Sep 19, 2005 2:15 am
Posts: 1281
Location: Florida
Hmm, well, I'll definitely try it out in the future! :P I'll probably test it on Serkai's Zelda dungeon-style puzzles he's helping me with. A bit of randomness in descriptions for something like mirrors and walls and floors and rooms (atmosphere, anyway?) would alleviate some of the monotony too.

_________________
Obviously, this post has way too much text.

Love is my weapon and trust is my armor!


Top
 Profile Send private message  
 
PostPosted: Thu Jan 15, 2009 12:19 am 
Regular
User avatar

Joined: Fri Jul 25, 2008 11:51 pm
Posts: 126
BCS wrote:
Jake wrote:
BCS wrote:
Got it. Thanks. Delete it, roll again, right?


You don't even need to delete it, really - just assign a new value over the top and it'll replace what was already there. The distinction is just that the variable will always contain whatever value it was last given, and can't go off and find a new random number on its own - you have to explicitly generate and assign a new random number each time you want it to change.


I think I "got" it by the time I reached the end of my script, instead of copying and pasting gobs of text over. You can use a "call" function to accomplish this repeatedly, right?


Whoops. Yeah, when I was talking about "del" that wasn't the thing I was trying to get across. :D

Sorry for confusing you.


Top
 Profile Send private message  
 
PostPosted: Fri Apr 06, 2012 1:30 pm 
Veteran
User avatar

Joined: Fri Aug 17, 2007 9:59 am
Posts: 204
Location: Always somewhere behind you...
Completed: Tour de Pharmacy (Proofreader)
Projects: Raven Hollow (Core Coder, Proofreader), The Universal Hope (Core Coder, Proofreader), The Abandoned Land (Proofreader)
Organization: FlareBlue Entertainment
Okay, I've been all over this thread and it seems like the place to post this.
I've got a question about the random integer generator, but I need it to be reusable, and creating new generators doesn't seem to be too efficient in this regard. Basically it's going to be used for meeting random people while out exploring.
I have this set up in my script file:
Code:
label start:
   (flags and stuff)
   $ go_diceroll = renpy.random.randint(1, 8)


I've set up the first call like so in a seperate script:
Code:
label explore:
   if go_diceroll = (value):
      show (person)
   elif (blah blah blah)

And it basically stacks like that.
As you can imagine setting up another generator for every single one of these will not only be cumbersome, but very time consuming and horribly inefficient. Is there any way to cause my dice to "forget" its original result and roll another one once I need it to?
I did read Showsni's choice system, but doesn't seem to be the way I want to take this.

One last thing.
Depending on how the player interacts with certain NPCs I'd like the dice weighted in favour of that NPC, or less likely to meet as the case may be. This makes it sound like a Dating Sim, but it's not.

Any help is greatly appreciated.

EDIT: I've looked again and it seems kind of handy. But I'd still like an easy to use weighting system.

_________________
Peace and Love,
Squark

Current Projects:
Universal Hope
Raven Hollow (on hold for now)


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Protected by Anti-Spam ACP
Powered by phpBB® Forum Software © phpBB Group