Couldn't extract another token error, and also code help/questions

Hiya! So I’m having a bit of trouble with a new project of mine. I want constantly updating variables “highskill” and “lowskill,” that check to see if they’re the lowest skill every time a stat change is made. I know that this’ll be a little tricky, as it’s a string that updates based on a number comparison.

I have strings assigned to the variables “highskill” and “lowskill,” and numbers assigned to the words in those strings.

My plan is this: if the current lowskill’s number is higher than a stat being updated, then that stat will become the new lowskill.

It would be awesome and amazing if I could call them in a comparison command like the one below, but anything that makes this work will suffice. I will say, I would prefer it to be a pretty short chunk of code as I literally will be pasting this in every single stat update. I theoretically could just make a huuuuuge if statement, but I would preeeefffeeeeerrrrrr not to.

        *if (lowskill="nothing")
            *set lowskill conscientiousness
        *elseif conscientiousness < ${lowskill}
            *set lowskill conscientiousness

Obviously, this code sets off the “couldn’t extract another token” error, but it’s the closest I am to somewhat conveying my idea.

You need $ only when you’re printing the variable in text, try without it?

1 Like

Let me see if I understand this fully.

You have created a series of variables for your skills. Each of these skills has a numerical value.

And you have also created variables for high skill and low skill which are strings. And you want to be able to update these often.

I think this might work. At least it produced the effect I think you want when I tested it.

So, each time you want to test a skill, you just use this subroutine with the skill you want to test in " " after the label.

This is assuming the string for lowskill contains some skill already. And I only did lowskill below but it’d be easy to add for highskill as well.

*gosub testing "honor"

*label testing
*params test_skill
*if {lowskill} > {test_skill}
    *set lowskill test_skill
    *return
*else
    *return
1 Like

Looks like it might work, but I get the error “Cannot read properly ‘length’ of undefined” when I put in the code and run it.

Alright nevermind, I moved it so that the gosub was before the subroutine, but now it’s giving the error “no parameter passed for test_skill”

Probably because you’re “falling into” the sub routine from elsewhere in your code. You can put sub routines in a completely separate scene file and use *gosub_scene to access them. Prevents any flow issues like this.

2 Likes

ok, that works!! Thank you all :3

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