Trouble using parameters

I’m having a bit of trouble with a subroutine. More specifically, about how to pass variables tthrough a parameter.

My code for the subroutine looks like this:

*label abilityDots
*params currentFull maxFull
*temp totalFull 0
*temp totalEmpty 0
*set showStat ""
*set totalFull  currentFull
*set totalEmpty (maxFull - totalFull)

*label buildFull
*if (totalFull = 0)
	*goto buildEmpty
	*set showStat "●"
	*set totalFull -1
	*goto buildFull

*label buildEmpty
*if (totalEmpty = 0)
	*set showStat "○"
	*set totalEmpty -1
	*goto buildEmpty

which is taken exactly (minus variable names) from this post.
I’m getting the non-existent variable error for both “maxFull” and “currentFull”, although I thought that using *params would create them (this is my first time trying to use subroutines and parameters in general and the information I’m finding online doesn’t help much). The code leading to the sub-routine is this:

*gosub_scene routines abilityDots strChips strength

The goal is to display the character’s remaining uses of skills related to a certain stat as chips, like in VTM Night Road, (as I’m adapting a simple pnp game), but in reverse, with using a skill removing available chips. Strength here would indicate the maximum number of these chips, while strChips would be the number of these chips the player has to use still.
I was under the impression that the value of strChips and strength would be passed to become currentFull and maxFull. What actually happens? Am I misunderstanding what parameters are? Any help would be appreciated. Thank you.

I managed to figure it out on my own. For anyone reading this with the same issue, I had to create the variables currentFull and maxFull before I could use them in the subroutine. EDIT: This did not actually fix the problem.

That doesn’t sound right to me. You shouldn’t need to create the variables mentioned in params separately: Params | ChoiceScript Wiki | Fandom

Are you actually calling your routine via gosub or gosub_scene? If you fall into it from other code or use goto or goto_scene, then you might encounter problems.


I just tested the code and it doesn’t actually work… Yes, I’m using *gosub_scene. But the subroutine is in the stats page, and I’m not sure if that’s causing the problem. I’m also trying to use the name of a variable after i specify where to go after using *gosub_scene, but it doesn’t carry over the value of the variable.

if the processes is done within a single text file, you can create them with *temp, but if you need them to be present on multiple text files, create them with *create on startup file, temp variables only visible on a specific file where they got created

yes the value are passed, but not to a new variable, the variables remain param_1 and param_2 under new aliases, currentFull and maxFull, its only used to make codes more readable

Sorry, but could you elaborate? I don’t understand what you mean by that.

*params is the command to receive parameters that comes along when calling a subroutine

the original names are always: param_1, param_2, param_3, and so on, depends on how many parameters are being passed

then, inside the subroutine, those names are changed to currentFull and maxFull, so there is no NEW variable called currentFull, only param_1 under the alias of currentFull, that only works inside that subroutine

Ohhh ok, that makes sense now! Thank you :slight_smile:

This time, I did actually get it to work :D! i had to change my variables from camelcase to using underscores and it fixed itself! That’s on me for not realizing I couldn’t do that lol.

1 Like

Ah! Thanks for sharing. Yeah, I’d advise against using camel case in ChoiceScript, the unofficial(?) convention is snake_case. So not overly surprised you saw some issues there.


This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.