In other languages I've seen, you can have a function return some kind of data. I think of labels in RenPy as functions, since they seem to work like they do. What I mean is, well I'll show you an example. The following is a label I wrote that converts a numerical value to a string (if there's a way of doing this natively, please let me know, but it's not really the point of this question). So the way I have it working now is as follows:
Code: Select all
label numWord(number=0):
$ returnData = ""
$ ifPlural = "s"
$ returnData = "DUNNO"
if number == 0:
$ returnData = "no"
if number == 1:
$ returnData = "one"
$ ifPlural = ""
if number == 2:
$ returnData = "two"
if number == 3:
$ returnData = "three"
if number == 4:
$ returnData = "four"
if number == 5:
$ returnData = "five"
if number == 6:
$ returnData = "six"
return
call numWord(3)
$ whatToSay = "I ate "+returnData+" cakes"+ifPlural+"."
# "I ate three cakes."
Code: Select all
label numWord(number=0):
$ returnData = ""
$ ifPlural = "s"
$ returnData = "DUNNO"
if number == 0:
$ returnData = "no"
if number == 1:
$ returnData = "one"
$ ifPlural = ""
if number == 2:
$ returnData = "two"
if number == 3:
$ returnData = "three"
if number == 4:
$ returnData = "four"
if number == 5:
$ returnData = "five"
if number == 6:
$ returnData = "six"
return returnData
$ whatToSay = "I ate "+numWord(3)+" cakes"+ifPlural+"."
# "I ate three cakes."