SetScreenVariable(still having trouble)
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.
SetScreenVariable(still having trouble)
I've been trying to figure this out by myself for a couple of days now but im stumped and cant think of how to do this right. im gonna try to explain what I'm trying to achieve...I'm still new to this so idk if what I'm talking about will make any sense.
im trying to create some kind of party select screen. you use the arrows to look through available characters. the limit of characters you can have in your party is 3. when you see a character you want to select you click on the character's portrait and they are removed from the list of available characters and into your current party (the empty boxes on the side). and if you change your mind you click the portrait of the character you want to change and they move back to the list of available characters.That's all.
im having trouble thinking of the right code to do this. i was thinking of making a list with imagebuttons for the clickable character portraits (i dont know how to make that work) and using SetScreenVariable on the arrow buttons or something and adding some code to it so different character images from the list show up when you click the arrows? but i really dont know. i looked at some codes and saw them use that code for somethings similar to what i want to do.
or would a different code be more easier to use?
if anyone has any idea how to do something like this let me know. i would really like to solve this problem. sorry if this is confusing im bad at explaining things.
im trying to create some kind of party select screen. you use the arrows to look through available characters. the limit of characters you can have in your party is 3. when you see a character you want to select you click on the character's portrait and they are removed from the list of available characters and into your current party (the empty boxes on the side). and if you change your mind you click the portrait of the character you want to change and they move back to the list of available characters.That's all.
im having trouble thinking of the right code to do this. i was thinking of making a list with imagebuttons for the clickable character portraits (i dont know how to make that work) and using SetScreenVariable on the arrow buttons or something and adding some code to it so different character images from the list show up when you click the arrows? but i really dont know. i looked at some codes and saw them use that code for somethings similar to what i want to do.
or would a different code be more easier to use?
if anyone has any idea how to do something like this let me know. i would really like to solve this problem. sorry if this is confusing im bad at explaining things.
Last edited by bebeesun on Sat Feb 06, 2016 12:25 am, edited 1 time in total.
- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: SetScreenVariable
Okay what you could do is kind of borrow code from this idea:
http://lemmasoft.renai.us/forums/viewto ... =8&t=14559
Obviously not all of it but for example, maybe set up the code to something to the extent of the arrow buttons set a variable to show the characters, just like the dress up game. how it does the whole:
showing_character += 1
then make it so it only cycles through the max number of available characters there should be. and assign that same number (if you click the arrow 5 times then the file number should have the number 5 in it as well)
I think I'm explaining this in a really confusing way, sorry. You could either have a live composite or you could just have an image that shows depending on the variable that is shown.
As for the characters being taken out of the available characters, maybe you need to use a list for that (a python list) and then take them out of the list if selected and then shown on the screen.
It's honestly probably going to be more complicated than this, especially if there are going to be three slots and any character could go into any slot in any order. Might take some digging and research. Hopefully someone answers with an exact or close-to-exact formula for this but I bet some of this with some tweaking could work through code similar to the dress up screen code.
http://lemmasoft.renai.us/forums/viewto ... =8&t=14559
Obviously not all of it but for example, maybe set up the code to something to the extent of the arrow buttons set a variable to show the characters, just like the dress up game. how it does the whole:
showing_character += 1
then make it so it only cycles through the max number of available characters there should be. and assign that same number (if you click the arrow 5 times then the file number should have the number 5 in it as well)
I think I'm explaining this in a really confusing way, sorry. You could either have a live composite or you could just have an image that shows depending on the variable that is shown.
As for the characters being taken out of the available characters, maybe you need to use a list for that (a python list) and then take them out of the list if selected and then shown on the screen.
It's honestly probably going to be more complicated than this, especially if there are going to be three slots and any character could go into any slot in any order. Might take some digging and research. Hopefully someone answers with an exact or close-to-exact formula for this but I bet some of this with some tweaking could work through code similar to the dress up screen code.
Re: SetScreenVariable
You can go figure out fancy stuff like adding images and what not to your own liking, but here's a basic framework. It's fundamentally similar to leon's dress-up code, but simpler.
Code: Select all
screen choose_party(char_list):
default char = 0
default party = []
hbox:
textbutton "<" action If(char == 0, SetScreenVariable("char", len(char_list) -1),SetScreenVariable("char", char -1))
textbutton char_list[char] action If(len(party) < 3, AddToSet(party, char_list[char]))
textbutton ">" action If(char == len(char_list) - 1, SetScreenVariable("char", 0),SetScreenVariable("char", char + 1))
null width 30
for c in party:
textbutton c action RemoveFromSet(party, c)
label start:
$ char_list = ["A", "B", "C", "D", "E"]
show screen choose_party(char_list)
"Add/remove from party as you wish."
Re: SetScreenVariable
omg that actaully worked! thank you! and its an easy code to read too! i really appreciate it! now i just need to get images to show with this code hopefully someone else can help me on this! if anyone has any ideas let me know
Re: SetScreenVariable(still having trouble)
im sorry im still having trouble figuring out how to add imagebuttons to the code ive looked at a bunch of other codes and messed with it but nothing is working. can anyone help?
- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: SetScreenVariable(still having trouble)
In place of where the textbuttons are on philats example? If that's what you mean... replace textbutton with imagebutton.
(remember to indent this right--can't tab indent on the forum when typing this lol)
or are you asking something else?
If you took the first textbutton and made it an imagebutton, it'd be something like:
But I'm assuming you mean the character images. Which should still be as simple
(remember to indent this right--can't tab indent on the forum when typing this lol)
Code: Select all
imagebutton:
idle "my_imagebutton.png"
hover "my_imagebutton_hover.png"
action #blahblah~~you get the idea
If you took the first textbutton and made it an imagebutton, it'd be something like:
Code: Select all
imagebutton:
idle "pic1.png"
hover "pic1_hover.png"
action If(char == 0, SetScreenVariable("char", len(char_list) -1),SetScreenVariable("char", char -1))
Re: SetScreenVariable(still having trouble)
i used the first code you gave me and it does show an image there but how do i make it so that everyone in the list:
has their own image? and when you click it the image moves to the side and takes it out of the available party.
when i click the image the textbuttons still come up.im having trouble figuring that part out
Code: Select all
$ char_list = ["A", "B", "C", "D", "E"]
when i click the image the textbuttons still come up.im having trouble figuring that part out
- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: SetScreenVariable(still having trouble)
Hmm I wouldn't know the 'exact' order and syntax for this without thinking it through and testing it out myself (and not at 1 AM xD)
Re: SetScreenVariable(still having trouble)
ok! let me know if u come up with something!
Re: SetScreenVariable(still having trouble)
You want to have classes holding character information. Here's a simple example of a character class holding names and ages. http://lemmasoft.renai.us/forums/viewto ... 87#p398481
This is leon's inventory screen, which shows you how to make imagebuttons with classes -- the Item() class has an image attribute which is referenced in showing the items on screen.
This is leon's inventory screen, which shows you how to make imagebuttons with classes -- the Item() class has an image attribute which is referenced in showing the items on screen.
Re: SetScreenVariable(still having trouble)
yes im very close to solving this problem! i actually had leon's inventory bookmarked but i hadnt looked at the code yet. its very easy to read.i understand classes a bit more now. i tested it out and got an imagebutton to show up but then i restarted the game over and it gave me an error. so i tried something random like this its a mess...im probably doing it all wrong....
Code: Select all
init python:
class Player():
def __init__(self, name, image=""):
self.name = name
self.image = image
screen choose_party(char_list):
tag menu
default char = 0
default party = []
$ pic = name.image
hbox:
textbutton "<" action If(char == 0, SetScreenVariable("char", len(char_list) -1),SetScreenVariable("char", char -1))
imagebutton idle pic xpos 10 ypos 150 focus_mask None action If(len(party) < 3, AddToSet(party, char_list[char]))
textbutton ">" action If(char == len(char_list) - 1, SetScreenVariable("char", 0),SetScreenVariable("char", char + 1))
null width 30
for c in party:
textbutton c action RemoveFromSet(party, c)
label start:
$ char_list = [A, B, C, D, E]
$ A = Player("Rose", "portrait1.png")
show screen choose_party(char_list)
- konett
- Regular
- Posts: 150
- Joined: Fri Apr 26, 2013 4:00 pm
- Projects: White Lie, Witching Tower, Tropichu!
- Tumblr: cosmickonett
- Deviantart: konett
- itch: konett
- Location: The Netherlands
- Contact:
Re: SetScreenVariable(still having trouble)
To get to change $ pic = name.image to $ pic = char_list[char].image. You needed to define your variable before adding them to the list, too. I changed some things around to also get images for the items in the list to show an image as well. I used 170x475 images to test it with and it work.
Code: Select all
init python:
class Player():
def __init__(self, name, pic=""):
self.name = name
self.pic = pic
screen choose_party(char_list):
tag menu
default char = 0
default party = []
$ pic = char_list[char].pic
hbox:
textbutton "<" action If(char == 0, SetScreenVariable("char", len(char_list) -1),SetScreenVariable("char", char -1))
imagebutton idle pic action If(len(party) < 3, AddToSet(party, char_list[char]))
textbutton ">" action If(char == len(char_list) - 1, SetScreenVariable("char", 0),SetScreenVariable("char", char + 1))
null width 30
for c in party:
imagebutton idle c.pic action RemoveFromSet(party, c)
label start:
$ A = Player("Rose", "portrait1.png")
$ B = Player("Dave", "portrait2.png")
$ C = Player("John", "portrait3.png")
$ D = Player("Ben", "portrait4.png")
$ E = Player("Kate", "portrait5.png")
$ char_list = [A, B, C, D, E]
call screen choose_party(char_list)
Re: SetScreenVariable(still having trouble)
yes!! that worked! thank you so much for your help! i can finally move on to something else thank you!
Who is online
Users browsing this forum: No registered users