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.
-
Nero
- Veteran
- Posts: 242
- Joined: Tue Aug 09, 2016 2:59 pm
-
Contact:
#1
Post
by Nero » Sat Mar 28, 2020 3:08 pm
I have a text that says something like "Skill deals 5 damage." so the next thing I want it to show is IF damage goes up then show "Skill deals {color=ff0000}5{/color} damage"
Basically say same thing just change the color of number in sentence does anyone have idea how to make that work in my example here? Seems so trivial but for some reason I have problems making that work without making my code inefficient.
Code: Select all
screen test:
for s in skill_list:
text "%s" % s.description
init python:
class Skill():
name = "Skill"
damage_base = 10
damage = damage_base
description = "[s.name] deals [s.damage] damage."
def skill_damage_up():
for s in skill_list:
s.damage += 1
skill_list = [Skill()]
label start:
show screen test
label loop:
"..."
$ skill_damage_up()
jump start
Last edited by
Nero on Sat Mar 28, 2020 4:42 pm, edited 1 time in total.
-
gas
- Miko-Class Veteran
- Posts: 838
- Joined: Mon Jan 26, 2009 7:21 pm
-
Contact:
#2
Post
by gas » Sat Mar 28, 2020 4:11 pm
mmm... this?
Code: Select all
screen test:
for s in skill_list:
text "[s.name] deals {color=ff0000}[s.damage]{/color} damage"
not using a description parameter.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
-
Nero
- Veteran
- Posts: 242
- Joined: Tue Aug 09, 2016 2:59 pm
-
Contact:
#3
Post
by Nero » Sat Mar 28, 2020 4:42 pm
Okay I figured it out. No this is what I meant:
Code: Select all
text "%s" % (s.description if s.damage == s.damage_base else s.description.replace("[s.damage]","{color=#ff0000}[s.damage]{/color}"))
Users browsing this forum: Bing [Bot], _ticlock_