Displaying a Variable calling from Alternating Variables.

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
Chendzeea
Newbie
Posts: 10
Joined: Fri May 18, 2018 8:05 pm
Contact:

Displaying a Variable calling from Alternating Variables.

#1 Post by Chendzeea »

I need to Display the [Survival Points aka SP] of an Active Character since they can be selected at will. Example "[POV] has [SP] Remaining."

$ VICKY_POV = True
$ LEX_POV = False
$ Vicky_SP = 1
$ Lex_SP = 0

if VICKY_POV == True:
$ POV = "Vicky"
elif LEX_POV == False:
$ POV = "Lex"
else:
pass
################################### The Problem is Below ##############################

This doesn't work obviously, but it illustrates how I was trying to get to work.
if VICKY_POV == True:
SP = $ Vicky_SP
elif LEX_POV == True:
SP = $ Lex_SP
else:
pass

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Displaying a Variable calling from Alternating Variables.

#2 Post by hell_oh_world »

Using labels you can do it like this...

Code: Select all

default pov = "Vicky"
default vicky_sp = 0
default lex_sp = 1

label display(pov, sp):
   "[pov] has [sp] Remaining."
   return

label start:
  python:
    if pov == "Vicky": sp = vicky_sp
    elif pov == "Lex": sp = lex_sp
    
  call display(pov, sp)

Chendzeea
Newbie
Posts: 10
Joined: Fri May 18, 2018 8:05 pm
Contact:

Re: Displaying a Variable calling from Alternating Variables.

#3 Post by Chendzeea »

Yeah I've been going over tutorials. I was going about this wildly wrong. Sorry to bother everyone. It's just difficult sorting through all the sea of awkward tutorial and out of date information. Thank you.

Post Reply

Who is online

Users browsing this forum: No registered users