Hey I’m having trouble with using return for a gosub function in the stats area. Whenever I put a return at the bottom of my function, it gives me the same error saying I don’t have a parameter for “trait_value” when I’m pretty sure its right there at the top of everything. If I remove the return, I can only call the gosub once and no other text will show after that which isn’t what I want.
The error I’m getting is: “choicescript_stats line 82: No parameter passed for trait_value”
If you use Preformatted text it becomes easier to read the code. It preserves the white spaces. It’s one of the options when you click the gear icon on the menu bar when composing a post.
Regarding your error, if I had to guess it’s because you have to “hide” the subroutine. ChoiceScript will read your code top to bottom. Right now, after charisma, it runs through the show_trait_bar subroutine code block again. My suggestion is to move it to the end of the file and put a *finish before it.
I once got a similar problem with a similar subroutine although my code was trying to emulate the “Chice of Robots” style stats and was simpler.
In my case I forget to declare the param with a proper value!=0.
I mean, the parameter was a blank “” whithout numeral value and the code was supposed to “count” said blank value.
Other cause of this problem may be an issue seems with how you are calling the show_trait_bar function in the choicescript_stats file.
The error message indicates that no parameter was passed for trait_val
Hmm… lets make some tests.
Try this:
Instead of:
BRAWN:
*gosub show_trait_bar traits_1
CHARISMA:
*gosub show_trait_bar traits_2
Try explicitly passing the variable:
*comment if trairs_1 or trait_2 ISNUMBER
BRAWN:
*gosub show_trait_bar (traits_1)
CHARISMA:
*gosub show_trait_bar (traits_2)
Also, I did notice you are using implicit control flow. Do trait_1 or trait_2 are global variables or are they temporary variables declared in another routine?
But now, I’m trying to check for a personality type and a trait to set the max star count to 7, but for soem reason the if statement I wrote doesn’t do anything. Any thoughts?
Assuming the indentations are as written, your if statement seems to be empty, that would be why it’s not doing anything. It’d need to be:
*if count < stars
*set filled & "★"
(...)
However, I’d recommend using multireplace to fill stars like that instead of trying to emulate a repetition loop on ChoiceScript. In that case, you wouldn’t call a subroutine to fill stars and would instead use plain text.
I have 5 Personality “Types” that I’m trying to give each a respective max set of traits, (e.g. let’s say “type 1” can only have a max amount of 6 stars in trait1, while “type 2” can have a max amount of 7 in trait1)
This only really works once, before it just copies the latest max star value for the 5 other 5 traits. I’m guessing this is because it only resets “max_stars” once, but I have no clue what the alternative would be. (I’m super new to choicescript sorry lol)
Let’s say you’re running the code checking for traits_2.
In the first run, traits_1 has a value of 30 and traits_2 has a value of 45. In this case, the code would run, correctly detect trait_value = 45, and set max_stars to 9.
However, if traits_1 has a value of 30 and traits_2 also has a value of 30, the code finds that trait_value = 30 = traits_1 and sets the max_stars to 6.
It’ll run into this problem everytime two traits have the same value.
Under the assumption that you don’t want to use multireplace, your best bet would be to set a second control param.