Some problems with variables

Hey folks, I’ve come here with a few questions in mind about variables, and just coding, to a certain degree.

So say I had six variables to work with: strength, agility, astuteness, stealth, intimidation, and persuasion, and I wanted the player to be able to choose which one is the highest out of the group, and after they choose their highest stat, they can go on to choose the stats that go after.

Ex;

What are you the best at?
*choice

#Intelligence
*set intelligence 20
#Strength
*set strength 20
#Stealth
*set stealth 20

And so on(for some reason, it won’t let me indent here, so…)

Here is what I used for this same purpose, feel free to re-purpose it. To be fair it was @Maxmansung who coded this bit for me:

*temp round 1

*label ask
*if round = 1 
	"What would you say you're best at?"
	*gosub questions
*if round = 2
	"Good at anything else?"
	*gosub questions
*if round = 3
	"Anything you've dabbled in?"
	*gosub questions
*if round = 4
	"And what are you bad at?"
	*gosub questions
*return	

	
*label questions
*hide_reuse
*fake_choice
	#Hand-to-hand combat, swords and the like
		*if round = 1
			*set hand %+30
		*if round = 2
			*set hand %+20
		*if round = 3
			*set hand %+10
		*if round = 4
			*set hand %-10
	#Marksmanship
		*if round = 1
			*set marksmanship %+30
		*if round = 2
			*set marksmanship %+20
		*if round = 3
			*set marksmanship %+10
		*if round = 4
			*set marksmanship %-10
	#Riding
		*if round = 1
			*set riding %+30
		*if round = 2
			*set riding %+20
		*if round = 3
			*set riding %+10
		*if round = 4
			*set riding %-10
	#Brawling
		*if round = 1
			*set brawl %+30
		*if round = 2
			*set brawl %+20
		*if round = 3
			*set brawl %+10
		*if round = 4
			*set brawl %-10
	#charisma
		*if round = 1
			*set charisma %+30
		*if round = 2
			*set charisma %+20
		*if round = 3
			*set charisma %+10
		*if round = 4
			*set charisma %-10
	#Intimidation
		*if round = 1
			*set intimidation %+30
		*if round = 2
			*set intimidation %+20
		*if round = 3
			*set intimidation %+10
		*if round = 4
			*set intimidation %-10
	#Endurance
		*if round = 1
			*set endurance %+30
		*if round = 2
			*set endurance %+20
		*if round = 3
			*set endurance %+10
		*if round = 4
			*set endurance %-10
	#Leadership
		*if round = 1
			*set leadership %+30
		*if round = 2
			*set leadership %+20
		*if round = 3
			*set leadership %+10
		*if round = 4
			*set leadership %-10
	#Military Acumen
		*if round = 1
			*set acumen %+30
		*if round = 2
			*set acumen %+20
		*if round = 3
			*set acumen %+10
		*if round = 4
			*set acumen %-10

*set round +1			
*return

Thank you for your help! When it comes to *gosubs, I’m completely lost. ^.^;

Hey there, I’m back, and with more problems(unfortunately).

I modeled my coding based on what you had, but when it got down to the bottom, I get an error saying: Invalid return, we’ve already returned from the last gosub.

The invalid return is the first one in the coding, under the *gosub questions

*temp round 1
*label ask
*if round = 1
	"What would you say that the ${boygirl} has the most potential for?"
	*gosub questions
*if round = 2
	"Is ${heshe} proficient at anything else?"
	*gosub questions
*if round = 3 
	"By any chance, are there any underlying skills that ${heshe} might develop?"
	*gosub questions
*if round = 4
	"What do you think that ${heshe} might have the most trouble with?"
	*gosub questions
*return

*label questions
*hide_reuse
*fake_choice
	#"Fighting."
		*if round = 1
			*set strength %+30
		*if round = 2
				*set strength %+20
		*if round = 3
			*set strength %+10
		*if round = 4
			*set strength %+0
	#"I'd say intelligence."
		*if round = 1
			*set astuteness  %+30
		*if round = 2
				*set astuteness %+20
		*if round = 3
			*set astuteness %+10
		*if round = 4
			*set astuteness %+0
	#"Agility."
		*if round = 1
			*set agility %+30
		*if round = 2
			*set agility %+20
		*if round = 3
			*set agility %+10
		*if round = 4
			*set agility %+0
	#"Resilience."
		*if round = 1
			*set resilience %+30
		*if round = 2
			*set resilience %+20
		*if round = 3
			*set resilience %+10
		*if round = 4
			*set resilience %+0
	#"Leadership."
		*if round = 1
			*set leadership %+30
		*if round = 2
			*set leadership %+20
		*if round = 3
			*set leadership %+10
		*if round = 4
			*set leadership %+0
	#"Stealth."
		*if round = 1
			*set stealth %+30
		*if round = 2
			*set stealth %+20
		*if round = 3
			*set stealth %+10
		*if round = 4 
			*set stealth %+0
	#"Persuasion."
		*if round = 1
			*set persuasion %+30
		*if round = 2
			*set persuasion %+20
		*if round = 3
			*set persuasion %+10
		*if round = 4
			*set persuasion %+0

*set round +1
*return

I don’t think this would solve your problem but…

some of your ‘answers’ in *label questions have extra indents.

Edit: Okay, I just noticed something.

After Round = 4 , you still do a round+1, which would make Round = 5. However, there is no Round = 5.

You would probably want to add a

*if round = 5
*goto [label name here]

with proper indents, of course
probably the simplest solution for now. not a choicescript expert hehe.
btw how do you do that code thing in forums?

Replace the first return with *goto [label of wherever the story continues]. That’s not a subroutine (which needs to end in *return), that’s your main story.

Everything between *label questions and the bottom *return is your subroutine. The only way people should read that is if they get there via a *gosub. You could stick all your subroutines at the very bottom of your scene txt file, underneath the final *finish, just to keep them out of the way. Or you can keep them in the middle of your story and write around them, using a label to jump from your stat-setting question to the next bit of the story.

And incidentally, you don’t need the “if round = 4, set it %+0” lines – as you’ll of course be aware, adding zero literally does nothing.

Edit:

Ah, yes, that’s right – you’d actually want to replace the first *return with

*if round=5
  *goto next_bit_of_story
*goto ask

That way, you’ll go back to “ask” for rounds 1-4, and then continue the story after round 5.

That completely solved my problem. Thanks for the help, guys. ^.^

@UmbraLama, I just copied and pasted my code into the preformatted text button thing.
It looks like this : </>

Ah, and there’s another problem that I’ve run across. I want certain attributes(more specifically, the ones that weren’t picked) to be raised be a certain percentage(let’s say 5).

*if count = 5
    *if (strength = 0)
        *set strength %+5
    *if (astuteness = 0)
        *set astuteness %+5
    *if (agility = 0)
        *set agility %+5
    *if (resilience = 0)
        *set resilience %+5
    *if (leadership = 0)
        *set leadership %+5
    *if (stealth = 0)
        *set leadership %+5
    *if (persuasion = 0)
        *set persuasion %+5

Yet whenever I do it, the stats show no changes at all. I’ve tried tweaking the code here and there, but it hasn’t helped.

Doesn’t exactly solve your problem but if you don’t want any stats to remain at 0 then why not do “If strength = 0 set strength 5” instead of adding 5. I am not sure but it could possibly be an error with fairmath, maybe it can’t handle zeroes?

Think I’ve seen this before.

%+5 may be too small for fairmath to handle. Either that, or start with all stats at 1.

And thanks, now I know how to do it hehe

Fairmath can’t handle zeroes – it runs 01-99. The best way to use fairmath is for opposed stats, where 50 is (in effect) zero. For non-opposed stats that increase from 0, I’d suggest using normal math (ie take out the % before your +/-).

1 Like

Right, increasing 0% by a percent of itself is always going to be 0.
I just read fairmath goes between 1-99 and doesn’t work with other numbers in ways you’d expect.