Asking about Variable ?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
Rnot2000
Regular
Posts: 42
Joined: Thu Oct 31, 2019 8:40 am
Contact:

Asking about Variable ?

#1 Post by Rnot2000 »

default buy = 0
default applecream = 10

default item = "apple"
default item_status = "cream"

$ buy = [item ]+[item_status]

# become >>>
# buy = applecream
# buy = 10

i know this is not how it work....
but any idea how to code like this ?'

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Asking about Variable ?

#2 Post by _ticlock_ »

Rnot2000 wrote: Fri Jan 13, 2023 10:10 am $ buy = [item ]+[item_status]

# become >>>
# buy = applecream
# buy = 10

Code: Select all

$ buy = getattr(store, item + item_status)

JamesRosenthal
Newbie
Posts: 1
Joined: Wed Jan 18, 2023 9:04 am
Contact:

Re: Asking about Variable ?

#3 Post by JamesRosenthal »

Thanks for the code. I will keep it in my mind.

NathalieBelcher
Newbie
Posts: 4
Joined: Thu Jan 12, 2023 1:51 am
Contact:

Re: Asking about Variable ?

#4 Post by NathalieBelcher »

Thanks for helping me out as well.

Post Reply

Who is online

Users browsing this forum: Google [Bot]