SOLVED: Renpy random integer and unbound random choices
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
-
- Eileen-Class Veteran
- Posts: 1314
- Joined: Mon Sep 19, 2005 2:15 am
- Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
- Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
- Organization: Watercolorheart Studios
- IRC Nick: BCS
- Tumblr: adminwatercolor
- Deviantart: itsmywatercolorheart
- Github: Watercolordevdev
- Skype: heartnotes
- Soundcloud: Watercollider
- itch: watercolorheart
- Location: Florida
- Contact:
Re: Renpy random integer and unbound random choices
I have a feeling Ren'Py or python may be too limited for what I'm trying to do ... it simply seems to be impossible to call anything outside of the choice container from within the choices. Bad, bad, bad.
I'm not even the same person anymore
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Renpy random integer and unbound random choices
You didn't assign a value to randomstopgapBCS wrote:I'm getting this description, but no official traceback error. But the text says:
"randomstopgap unbound"
[/edit]
Face, meet palm.
" %(randomstopgap )s "
$ random appearance = renpy.random.choice(['cute', 'slender', 'fit', 'pretty', 'buxom'
I don't understand what you are trying to acheive. On another note if you want a sentence to go to a new line without erasing the previous line you can use \n like so:BCS wrote:I'm trying to figure out if the {nw} tag would work ... basically, what I need is something like {p} or {w} but actually erases the first line and displays the next one ...
I also can't call another %(randompronoun1)s from within the first %(randomstopgap)s ... this is going to be a BIG problem. D:
I tried '\"Person\" \"Hey!\"' but it didn't seem to like that ... it just displays "Person" "Hey!" and that isn't correct. "Person" should be in the name field. :/
Code: Select all
"BCS:\n I going to pull my hair out."
"BCS:
I'm going to pull my hair out"
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.
-
- Eileen-Class Veteran
- Posts: 1314
- Joined: Mon Sep 19, 2005 2:15 am
- Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
- Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
- Organization: Watercolorheart Studios
- IRC Nick: BCS
- Tumblr: adminwatercolor
- Deviantart: itsmywatercolorheart
- Github: Watercolordevdev
- Skype: heartnotes
- Soundcloud: Watercollider
- itch: watercolorheart
- Location: Florida
- Contact:
Re: Renpy random integer and unbound random choices
I would need to acheive:
"BCS says ... "
"ARGH, I'm going to pull my hair out!"
"BCS says ... {x} ARGH, I'm going to pull all my hair out!"
"BCS says ... "
"ARGH, I'm going to pull my hair out!"
"BCS says ... {x} ARGH, I'm going to pull all my hair out!"
I'm not even the same person anymore
-
- Eileen-Class Veteran
- Posts: 1314
- Joined: Mon Sep 19, 2005 2:15 am
- Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
- Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
- Organization: Watercolorheart Studios
- IRC Nick: BCS
- Tumblr: adminwatercolor
- Deviantart: itsmywatercolorheart
- Github: Watercolordevdev
- Skype: heartnotes
- Soundcloud: Watercollider
- itch: watercolorheart
- Location: Florida
- Contact:
Re: Renpy random integer and unbound random choices
I think I answered the wrong question. I'm using dialogue like this in Ren'Py (this is the code):JQuartz wrote:BCS wrote:I don't understand what you are trying to acheive.BCS wrote:I'm trying to figure out if the {nw} tag would work ... basically, what I need is something like {p} or {w} but actually erases the first line and displays the next one ...
I also can't call another %(randompronoun1)s from within the first %(randomstopgap)s ... this is going to be a BIG problem. D:
I tried '\"Person\" \"Hey!\"' but it didn't seem to like that ... it just displays "Person" "Hey!" and that isn't correct. "Person" should be in the name field. :/
Code: Select all
"Person" "Hey! You!"
In other words, I'm trying to set up dialogue within the original renpy.random.choices, but not a new one ..."Person" "Hey! You!"
renpy.random.choices = [('\"Person\" \"This.\"', '\"Person\" \"That.\"', 'You stop, bored.', 'You think to yourself, Hmm!'])
I'm not even the same person anymore
Re: Renpy random integer and unbound random choices
I see what you want. I'm not quite sure how to achive it, though. In the meantime, here's a hideous workaround:
But that's clearly horrible.
Code: Select all
$ randomtest = renpy.random.choice([1, 2])
if randomtest == 1:
"Person" "This"
if randomtest == 2:
"You think to yourself, hmmm."
-
- Eileen-Class Veteran
- Posts: 1314
- Joined: Mon Sep 19, 2005 2:15 am
- Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
- Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
- Organization: Watercolorheart Studios
- IRC Nick: BCS
- Tumblr: adminwatercolor
- Deviantart: itsmywatercolorheart
- Github: Watercolordevdev
- Skype: heartnotes
- Soundcloud: Watercollider
- itch: watercolorheart
- Location: Florida
- Contact:
Re: Renpy random integer and unbound random choices
Well, if that's how I have to do it ... I'll do it.
I'm not even the same person anymore
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Renpy random integer and unbound random choices
Man, I still can't see what he wants. I wonder if I can absorb some of your ability...Showsni wrote:I see what you want.
I still don't understand what you want but here a wild guess.BCS wrote:In other words, I'm trying to set up dialogue within the original renpy.random.choices, but not a new one ...
renpy.random.choices = [('\"Person\" \"This.\"', '\"Person\" \"That.\"', 'You stop, bored.', 'You think to yourself, Hmm!'])
Code: Select all
$ randomappearance = renpy.random.choice(['BCS says "I am cute and slender"', 'BCS says "I am going to pull all my hair out"', 'BCS says "I am having some programming trouble"'])
" %(randomappearance)s"
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.
-
- Eileen-Class Veteran
- Posts: 1314
- Joined: Mon Sep 19, 2005 2:15 am
- Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
- Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
- Organization: Watercolorheart Studios
- IRC Nick: BCS
- Tumblr: adminwatercolor
- Deviantart: itsmywatercolorheart
- Github: Watercolordevdev
- Skype: heartnotes
- Soundcloud: Watercollider
- itch: watercolorheart
- Location: Florida
- Contact:
Re: Renpy random integer and unbound random choices
Try again ...JQuartz wrote:he
It can't have 'says' or " " inside the description. That's not how the dialogue in Always Darkest Before Dawn works ...I still don't understand what you want but here a wild guess.Code: Select all
$ randomappearance = renpy.random.choice(['BCS says "I am cute and slender"', 'BCS says "I am going to pull all my hair out"', 'BCS says "I am having some programming trouble"']) " %(randomappearance)s"
It works like this:
I'm not even the same person anymore
Re: Renpy random integer and unbound random choices
If you type "Person" "Hello!" you'll get "Hello!" as said by the "Person" (with the Person appearing in a text box, like a normal character.)
renpy.random.choice returns an element from the list given; but can we make that include text and the person saying it? Say, you wanted to get a random one of
"I think long and hard."
"Person" "Hi!"
eileen "Hello."
show giraffe
out of a random choice; is that possible?
renpy.random.choice returns an element from the list given; but can we make that include text and the person saying it? Say, you wanted to get a random one of
"I think long and hard."
"Person" "Hi!"
eileen "Hello."
show giraffe
out of a random choice; is that possible?
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Renpy random integer and unbound random choices
I don't think it possible but you can fake it by using \n like so:Showsni wrote:If you type "Person" "Hello!" you'll get "Hello!" as said by the "Person" (with the Person appearing in a text box, like a normal character.)
renpy.random.choice returns an element from the list given; but can we make that include text and the person saying it? Say, you wanted to get a random one of
"I think long and hard."
"Person" "Hi!"
eileen "Hello."
show giraffe
out of a random choice; is that possible?
Code: Select all
$ randomappearance = renpy.random.choice(['BCS\nI am cute and slender', 'BCS\nI am going to pull all my hair out', 'BCS\nI am having some programming trouble'])
"%(randomappearance)s"
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.
Re: Renpy random integer and unbound random choices
Most things you'd want to do with this should be possible with eval(), which will execute a function even if it's in quotation marks.
I don't think eval() works with renpy.show() [?] because trying that gave me a traceback; however, just text should be fine with this...
Code: Select all
init:
$ eileen = Character("Eileen")
$ narrator = Character(" ")
$ person = Character("Person")
label start:
$ choices = ["narrator('I think long and hard')", "person('Hi!')", "eileen('Hello.')"]
$ eval(renpy.random.choice(choices))
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Renpy random integer and unbound random choices
Thanks Dusty, I stand corrected.JQuartz wrote:I don't think it possible but you can fake it by using \n like so:
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.
-
- Eileen-Class Veteran
- Posts: 1314
- Joined: Mon Sep 19, 2005 2:15 am
- Completed: Controlled Chaos / Sum of the Parts / "that" Midna game with ZONEsama
- Projects: Sparse Series/Oddments Shop original cartoon in Pevrea; Cybernetic Duels (fighting game); Good Vibin'
- Organization: Watercolorheart Studios
- IRC Nick: BCS
- Tumblr: adminwatercolor
- Deviantart: itsmywatercolorheart
- Github: Watercolordevdev
- Skype: heartnotes
- Soundcloud: Watercollider
- itch: watercolorheart
- Location: Florida
- Contact:
Re: Renpy random integer and unbound random choices
Thanks for the discussion, everyone. I hope this benefits someone. Instead of only using some of the fixes, I'm going to try all of them to see how they work.
$ choices = ["narrator('I think long and hard')", "person('Hi!')", "eileen('Hello.')"] It will go into an infinite loop, repeating the random choice and then the line of code after it.
There's another error not related to the above, but I have NO idea what is causing it ... I get a traceback error when I quit saying there is no yes-no prompt from common.
More specifically:
This one is strange. This one definitely works, but then it prints this line of code to the player.Dusty wrote:Most things you'd want to do with this should be possible with eval(), which will execute a function even if it's in quotation marks.
I don't think eval() works with renpy.show() [?] because trying that gave me a traceback; however, just text should be fine with this...Code: Select all
init: $ eileen = Character("Eileen") $ narrator = Character(" ") $ person = Character("Person") label start: $ choices = ["narrator('I think long and hard')", "person('Hi!')", "eileen('Hello.')"] $ eval(renpy.random.choice(choices))
$ choices = ["narrator('I think long and hard')", "person('Hi!')", "eileen('Hello.')"] It will go into an infinite loop, repeating the random choice and then the line of code after it.
There's another error not related to the above, but I have NO idea what is causing it ... I get a traceback error when I quit saying there is no yes-no prompt from common.
More specifically:
Code: Select all
I'm sorry, but an exception occurred while executing your Ren'Py
script.
AttributeError: Layout instance has no attribute 'yesno_prompt'
While running game code:
- script at line 9 of F:\Ren'Py\Always Darkest Before Dawn\renpy-6.8.1\Erotest/game/script.rpy
- script at line 32 of renpy-6.8.1/common/00menus.rpy
- python at line 32 of renpy-6.8.1/common/00menus.rpy.
I'm not even the same person anymore
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Renpy random integer and unbound random choices
Strange, I used the code you gave and it worked without a problem. Maybe the problem was after the set of codes. What is after this?
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.
- PyTom
- Ren'Py Creator
- Posts: 16088
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Renpy random integer and unbound random choices
That error is due to not calling theme.roundrect() or one of the other theme functions in init code.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Who is online
Users browsing this forum: Google [Bot], Kocker