Values not showing up with ui.text
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.
Values not showing up with ui.text
I can't get values to show up inside ui.text, example:
$ ui.text("To get to the next screen, click %(playerscore)d")
It comes back displaying %(playerscore)d in the UI. With dialogue statements it shows the value fine... any help would be awesome, thanks!
$ ui.text("To get to the next screen, click %(playerscore)d")
It comes back displaying %(playerscore)d in the UI. With dialogue statements it shows the value fine... any help would be awesome, thanks!
Re: Values not showing up with ui.text
Try
Note: <%d> is used if the <playerscore>`s value is data (a number), and <%s> - if string (some text), even if string is "123".
... and if you need to show several variables it would be like
Code: Select all
$ ui.text ("To get to the next screen, click %d" %(playerscore) )
... and if you need to show several variables it would be like
Code: Select all
$ ui.text ("%d some text %d%s" %(data_var, another_data_var, string_var) ) # the order of variables is important
Last edited by Alex on Sat Feb 13, 2010 4:06 pm, edited 2 times in total.
Re: Values not showing up with ui.text
That's not working either, why did you move the value outside the text string?
the value I'm trying to display is a number and not a string
the value I'm trying to display is a number and not a string
Re: Values not showing up with ui.text
Could you show the part of your code...
Re: Values not showing up with ui.text
Playerscore doesn't display a numeric value, instead if displays exactly the way it's written in the string.
Also for some reason I can't figure out how to make my menu wait for an instruction, when the UI opens the script keeps running and displays "stupid UI!" i'd prefer for it to wait for a click before doing anything further
Code: Select all
init:
image bg slums = "bg_blur.jpg"
$ playerscore = 1
python:
def testoverlay():
ui.text("Test")
config.overlay_functions.append(testoverlay)
# The game starts here.
label start:
scene bg slums
Test UI
# Clicking on image map opens the UI below.
$ ui.imagemap("bg_slumtest.jpg", "bg_slumtest2.jpg", [
(100, 100, 300, 400, "choice1"),
])
$ result= ui.interact()
if result == "choice1":
$ ui.vbox(xpos=.3, ypos=1)
$ ui.imagebutton("btn_taxi_killer_no_text.png", "btn_taxi_killer_no_text_over.png", clicked=ui.jumps('startthird'))
$ ui.close()
$ ui.vbox(xpos=.2, ypos=.25)
$ ui.text("This is the score %(playerscore)d ")
$ ui.close()
"Stupid UI!"
- PyTom
- Ren'Py Creator
- Posts: 16096
- 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: Values not showing up with ui.text
Interpolation isn't automatic when in python code. You need to tell Ren'Py what you want to interpolate:bobbk wrote:Playerscore doesn't display a numeric value, instead if displays exactly the way it's written in the string.
Code: Select all
if result == "choice1":
$ ui.vbox(xpos=.3, ypos=1)
$ ui.imagebutton("btn_taxi_killer_no_text.png", "btn_taxi_killer_no_text_over.png", clicked=ui.jumps('startthird'))
$ ui.close()
$ ui.vbox(xpos=.2, ypos=.25)
$ ui.text("This is the score %d " % playerscore)
$ ui.close()
pause
"Stupid UI!"
You'll need to cause an interaction to occur. If you want clicking outside of the button to cause the game to advance, you can use pause as given above. Otherwise, you can call ui.interact.Also for some reason I can't figure out how to make my menu wait for an instruction, when the UI opens the script keeps running and displays "stupid UI!" i'd prefer for it to wait for a click before doing anything further
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
Re: Values not showing up with ui.text
Fixed! Alex gave the same advice but I think I had a typo.
Pause is a pretty simple solution to something I couldn't quite figure out =)
thanks Alex & Pytom!
Pause is a pretty simple solution to something I couldn't quite figure out =)
thanks Alex & Pytom!
Re: Values not showing up with ui.text
Oops, I was late...))
Who is online
Users browsing this forum: Google [Bot]