Ultimate Noob Coding


#141

About to start back into coding. An idea how does the die roller work? I know I had read somewhere before that there was one, and I have some plans for it.


#142

Umm… you mean something like this?

*temp dieroll 0

*rand dieroll 1 100

*if dieroll < 20
   blahablah
*if dieroll > 80
   hablahah
*else
   etc. Blah blah

#143

That should do for a start. Danke!


#144

Bitte :wave:t4:
Mandatory 20chars


#145

I found a great gender coding tutorial from Fairy Godfeather from back in the day to start me on inserting these things into the code for NPT. But how do I set a NPC to automatically have the opposite of what the MC does? If the player is Fiorella, they are automatically female, which means Alexi must automatically be male.


#146

Set the npc’s gender/pronouns as you would the mc’s. You could put it in the original choice when the player picks their own gender, or code it later with an *if command. I’m labeling my own flippable npc’s pronouns the same as the mc’s with an extra letter in front, something like this (first variable is the mc’s gender):

*if male_female = "female"
	*set aname "Isa"
	*set amale_female "female"
	*set ahe_she "she"
	*set ahis_hers "hers"
	*set ahis_her "her"
	*set ahim_her "her"
	*set aman_woman "woman"
	*set amr_miss "Miss"

#147

Characters are finally meeting, and that means it’s time for relationship stats! Unless it ends up overly complicated, my notion is to eschew numerical values (or at least, visible ones) and have each relationship described in a short statement. For example: at meeting Alexi, you will start out at 10, but what the player will see is just Alexi: Largely indifferent to your existence. That one will fit a certain range, perhaps 9-11, and then if it goes to 12 it would be Alexi: Finds your company tolerable. Drop to 6-8 and you get Alexi: Wishes you would think more and talk a whole lot less. You get the idea.

However, if possible I would like these to not be visible until the character is introduced. Especially since some characters are unique to certain story paths, so no one will see them all in one go-round. Any thoughts? Also, from an opinion standpoint, since I already have eight stats on the stat page, would it be better to include relationship stuff in a separate page on the stats area (and if so, how?) or continue to leave it with the others?

Thanks in advance; I couldn’t have gotten this far without the forum’s support.

Also, I feel I must ask: is it really that bad to copy and paste text from a Google Drive doc into Choicescript? I know the tutorials talked about all the errors it could cause, but I must admit that while I am a fast typer, I am not exactly enjoying retyping tends of thousands of words when there is a way to do it instantaneously. How bad would it be to employ the good ol’ Ctrl+V to paste them in instead?


#148

For relationships
This would only show if the relationship of more than 5

rel_alexi is the relationship stat for Alexi

*if ((rel_alexi > 8) and (rel_alexi < 12 ))
    Alexi : indifferent to your existence
*if (rel_alexi > 11)
    Alexi : finds your company tolerable
*if ((rel_alexi > 5) and (rel_alexi < 9))
    Alexi : she thinks you would talk less and think more

For making them appear in a different location

*label mainstats

(Stats)

*choice
    # Relationships
        *goto relationships
    # other stat
        *goto misc

*label relationship

(Relationship stats)

*choice 
    # main stats
        *goto mainstats
    # other stats 
        *goto misc

*label misc

(Other stats )

*choice
    # main stats
        *goto mainstats
    # relationships
        *goto relationships
       

Sorry if this contained any indentation error. I am on phone.


#149

Well, as long as the .txt files is saved with UTF-8 encoding and it identifies the indentation, I think it should works just fine.


#150

For making relationships only show up if you’ve met the character, you can use a simple conditional, unique to the character (*if met_alexi) or based on a variable already used for something related (*if chapter > 2; *if completed_training)

So, something like:

	*if (met_brother)
		Your brother is more responsible than you'd guess from that shabby hat. You get along 
		*if (rel_brother < 35)
			poorly.
		*if ((rel_brother => 35) or (rel_brother =< 65)
			well.
		*if (rel_brother > 65)
			very well.
Some other ideas, and multireplace

You can get more complicated than a boolean for character status, to account for more than whether or not you’ve met them. I’ve got a couple characters that might be dead, trying to kill you, or revealed to be something different than originally thought. You could do this with a text variable (*if character_status = “dead”), or, if you want to get fancier, use a number (Write down what the different values mean!), and take advantage of multireplace. Then, you can write sentences like:

Alexi @{alexi_status |is|is|was} your traveling companion. 

alexi_status 1 means you haven’t met yet, so there’s no word there. Statuses 2 and 3 both have Alexi alive, but with some variation that’s not being used here (maybe you’re in a romantic relationship, or he’s missing). Status 4 means Alexi’s dead, so the verb changes to past tense.

WARNING: don’t try to convert a 1-100 relationship value straight to multireplace (i.e. @{(rel_alexi/3) enemy|acquaintance|friend}). The math is way more complicated than it looks to make them even. Just make another variable:

*if (rel_brother < 33)
	*set nrel_brother 1
*if (rel_brother > 66)
	*set nrel_brother 3
*if ((rel_brother => 33) or (rel_brother =<66)
	*set nrel_brother 2

My stat screen looks something like this:

	*if (brother_status > 1)
		Your brother is @{brother_type busy with something in the middle of the night|kind of a jerk|more responsible than you'd guess from that shabby hat|a little goofy, but a good friend}. You get along @{nrel_brother poorly|pretty well|very well}.

#151

If you have more than 1 stats to set then this could come in handy.

This example only consists of 2 relationship seats but could be done with more.

*temp rel_text ""
*temp rel 0
*temp alexi_text ""
*temp NPC_text ""

In the end of document ( preferably where the player doesn’t reach )


*label reltextsetter

*if ((rel > 8) and (rel  < 12 ))
    *set rel_text " is indifferent to your existence"
*if (rel > 11)
    *set rel_text "finds your company tolerable"
*if ((rel > 5) and (rel < 9))
    *set rel_text "thinks you would talk less and think more"
*return

Now when we need them

(Relationships)

*if (met_alexi)
    *set rel rel_alexi
    *gosub reltextsetter
    *set alexi_text rel_text
    Alexi : she ${alexi_text}

*if (met_AnotherNPC)
    *set rel rel_NPC
    *gosub reltextsetter
    *set NPC_text rel_text
    NPC : He ${NPC_text}

Variables needed in startup : rel_alexi, rel_NPC


#152

Having an issue where no choice option shows up here except the very first, wait him out. I assume it is because of indent issues, and I may have coded the *if thing wrong. But I am not sure of what way would be right, specifically.

*choice
    #Wait him out
        You decide to sit tight, hoping that your antagonist will make some sort of mistake that will allow you to either fight back or flee. The cold starts to set in as the time passes,.
        *if (jacket = 1) 
            Fortunately the thermal strips in your jacket continue to pump out heat, keeping you relatively comfortable despite the frigid weather.  
            *goto frozensleep
        *else
            The cold and inertia leaves you feeling dangerously weakened, but after a brief struggle you manage to stay awake.  
            *goto frozensleep
*label frozensleep
            After several minutes you risk a glance over the top of the largest boulder, and find that you do have a rather golden opportunity.  Whether due to injury, fatigue or just boredom, the lanky figure appears to have fallen into a fitful sleep right on the frozen ground.  A handheld communicator lies near one hand, flashing and chiming wildly.
            *if (jacket = 0)
                *set Endurance -2
                *goto beatalexi
            *else
                *goto beatalexi
    *if (quackers = 1)
        *disable_reuse #Deploy Mr. Quackers!
            You draw forth your trusty rubber duck, kiss him once for luck (and a second time just because you feel like it) and then hurl him toward a patch of scraggly undergrowth.  The loud squeak he emits on impact immediately draws your foe's attention, and you hear several shots fired.  Horrified and filled with regret at exposing your dearest friend to such dangers, you burst out from cover and dash toward your antagonist, tackling the figure and pummeling him senseless before he can even turn to react.
            *set Insanity +3
            *goto beatalexi
    *if (palmcomm = 1)
        *disable_reuse #Create a distraction
            You set your Palmcomm's theft alarm to go off in thirty seconds, then toss it in a low arc over to some scraggly underbrush. The device lands unseen, then when the time elapses it goes completely haywire. Lights flash, sirens wail and it vibrates loudly against the ice. Panicked, you hear seven loud reports as the lanky figure fires away at the source of the commotion. Then you hear the unmistakable dry [i]click[/i] of a firearm that has run out of ammo. Seizing the opportunity, you charge forward and launch a flying tackle at your foe, sending you both sprawling onto the tundra. You quickly get back to your feet. He does not. You see his chest rising and falling, but otherwise he seems to be unresponsive.
            *set Ingenuity +4
            *goto beatalexi
    *else
        *disable_reuse #Try to distract it!
            You fumble around at your feet for the largest loose rock available, and hurl it in a low arc over to some scraggly underbrush. At the same moment you launch yourself forward to try and close the ground between you. 
            *if (Ingenuity > 18)
                Through the blur of motion you see the figure fire into the bushes several times, then notice you coming forward and try to swerve the weapon in your direction. Your opponent is too slow, however, and you launch a flying tackle at your foe that sends you both sprawling onto the tundra. You quickly get back to your feet. The shooter does not.  You do see the figure's chest rising and falling, but otherwise there is no sign of activity.
                *set Ingenuity +1
                *goto beatalexi
            *else
                Through the blur of motion you see the figure fire into the bush once, but he clues in to the deception and turns to drawn down you while you are still too far away.  Your mind has just enough time to formulate a vile curse word, but not enough to utter it, before something slams into the side of your head and the world goes white once again.
                *set Ingenuity -2
                *goto alexibeathead
    *if (holdout = 1)
        *disable_reuse #Shoot it!
            You draw your holdout blaster and emerge a little from your cover, drawing a bead on the figure. At this range, effectiveness may be limited, but you go ahead and take the shot anyhow.
            *if (Marksman > 17)
                The azure beam crackles toward the figure almost faster than the naked eye can track, burning a groove in the arm holding the weapon. Your target emits a shriek of surprise and pain, and they release their grip on the slugthrower. You dash forward, closing the meters between you and your mysterious assailant before they recover, and scoop up the weapon. (Marksmanship +5)
                *set Marksmanship +4
                *goto beatalexi
            *else
                The impact from the crash must have thrown your aim off, as you miss by a country mile. Before you can retreat behind your stony shelter, you feel something slam into the side of your head and the world goes white once again.
                *set Marksmanship -2
                *goto alexibeathead
    *else
        *disable_reuse #Throw a rock at it!
            You grab a good-sized rock and emerge a little from your cover, drawing a bead on the figure. At this range, effectiveness may be limited, but you go ahead and take the shot anyhow.
            *if (Marksmanship > 18)
                The rock arcs unerringly into the muttering thing's shoulder.  Your target emits a shriek of surprise and pain, and they release their grip on the slugthrower. You dash forward, closing the meters between you and your mysterious assailant before they recover, and scoop up the weapon.
                *set Marksmanship +3
                *goto beatalexi
            *else 
                 The impact from the crash must have thrown your aim off, as you miss by a country mile. Before you can retreat behind your stony shelter, you feel something slam into the side of your head and the world goes white once again.
                 *set Marksmanship -2
                 *goto alexibeathead
    *disable_reuse #Try to communicate with it
        *if (Influence > 14)
            You call out from behind the rocky outcropping. "Hello? I don't mean you any harm. Do you speak English?" There's a pause, and you almost hear a tinny faraway voice akin to the one from your navicomp. Then more of the muttering, and a croaking shout. "Time will tell whether or not you mean any ice cream. Why don't you sautee your way out of there with your hams raised and we can hashbrown this out like normal folk?"
            *set Influence +1
            *choice
                #Do as I'm told.
                    You don't like putting yourself at the whim of what sounds like a fairly disturbed person, but you're even less fond of staying crouched behind these rocks forever, feeling your muscles ache and the north wind slowly dig its frozen claws deeper into your flesh. You put your hands up slowly and rise. "All right, I'm coming out. Don't do anything rash."
                    *goto alexicapture
                #Propose a compromise.
                    Ignoring the odd tics in the stranger's speech, you continue to plead your case. "We can be reasonable. I'll come out with my hands raised so you can see I'm unarmed, then you holster that cannon so we can have a proper discourse." There's a momentary pause, presumably as the thin figure ponders your request. "Eh, why the fudge not?" You emerge tentatively from your cover, wincing against a half-expected shot. It does not come. Instead you see the large sidearm dropped back into the low-slung holster, then the odd-speaking individual holds a hand to the side of its head in obvious pain.  The figure motions for you to follow it and calls out. "Neb says the heat is still working…although with that hole that some bushwhacking muffin blew in its poor rear end, it'll get chilly in there quite soon." You follow along, curious as to what will come next.
                    *set Influence +2
                    *goto capturealexi
                #Poop to that, he can throw [u]his[/u] weapon down!
                    You shout back defiantly. "I have the high ground, and if we wait here much longer you'll have to deal with my backup when they come to see why I am missing." You have no idea if this is true, but he doesn't have to know that. "So how about you toss your weapon on the ground, and then we 'hashbrown' this out?"
                    *if (Influence > 19)
                        There's a momentary pause, presumably as your antagonist ponders your request. Over the howl of the wind you clearly hear an exaggerated, dramatic sigh.  "Whatever.  I'm needing a nap anyway, so if you shoot me I guess I'll still get some rest one way or the apple." You hear the soft crunch of something falling on packed snow, then peek out and see the slugthrower laying on the ground in front of the figure. You stride forward with a confidence that almost feels genuine and pick up the discarded weapon.  The crimson-barreled slugthrower is surprisingly light, and the feel of it in your hand seems right.  The thin man smiles and shrugs, wincing at the movement. "I always had a feeling that Miss Jolie there would be the death of me one day.  Which makes me wonder why I kept the accursed cookie around." He yawns loudly, then sits cross-legged on the snowy ground. His eyes almost instantly widen. "Wow, that is cold. I immediately regret this decision. Mind if we go back to my bagel instead?"  The addled newcomer must recognize the look of confusion on your face, so he gestures to the damaged hulk behind him. Eager to escape the cold, you let him lead you into the ship, though you make sure to keep the newly acquired slugthrower trained on him at all times.
                        *set Influence +4
                        *goto capturealexi
                    *else
                        There's a momentary pause, presumably as your foe ponders your request. Then you hear a dry, raspy chuckle. "Nice try, you little beef Wellington. Hurry up and put your head out from that pile of pickles so I can finish you off and get back to fixing my friend here." This comment is punctuated by another shot from the weapon, which hits the rock you are crouched behind with a loud [i]Spannng![/i] It would appear that the initial round of negotiations has gone poorly.
                        *set Influence -2
                        *goto alexiredo

#153

This should have the same indent as the lines before and after it. (There may be other problems, but that’s the one I noticed.)


#154

I think there are; I am trying to make it so certain options only show up if an item or other circumstance is met (and I also have disable reuse on there for the branch which makes you do it over again), so I nested them inside an *if command, but that seems to lead the game into thinking that they are not part of the main choice. So they all should have been choices along with Wait Him Out, but Wait Him Out remains the only visible choice even after I changed the indent on that frozensleep label.


#155

What’s the difference between the Marksman stat and the Marksmanship stat?

Also, to be clear, if an #option is indented under an *if statement, it will only be visible if the player’s character meets the condition set by the *if statement. It will be completely removed if the character doesn’t meet the condition. So if the player is approaching the choice and their character doesn’t meet any of the requirements, they won’t see any of the options. At all. Are you sure your character has the stats required to use these other options while you’re testing?

If you want the #options to be present but greyed-out and unusable, you’ll want *selectable_if instead of *if.

Also, there’s a moment where the narration says (Marksmanship +5) but the code reads *set Marksmanship +4 .

I copy-pasted this sample code into a test file, made minimal changes, and got it working. Specifically, I corrected the indentation on that one *label, replaced the narration with short *comments to make it easier to examine, and gave my variables starting values large enough to pass the *if statements. In my test, the options are working correctly.

Here's my test code:
*title Code Test 4
*author @Minnow
*scene_list
    startup
*create jacket 1
*create quackers 1
*create palmcomm 1
*create holdout 1
*create Ingenuity 30
*create Marksman 30
*create Marksmanship 30
*create Influence 30
*create Endurance 30
*create Insanity 30
text
*choice
    #Wait him out
        *comment Narrative removed for simplicity.
        *if (jacket = 1) 
            *comment Narrative removed for simplicity. 
            *goto frozensleep
        *else
            *comment Narrative removed for simplicity. 
            *goto frozensleep
            *label frozensleep
            *comment Narrative removed for simplicity.
            *if (jacket = 0)
                *set Endurance -2
                *goto beatalexi
            *else
                *goto beatalexi
    *if (quackers = 1)
        *disable_reuse #Deploy Mr. Quackers!
            *comment Narrative removed for simplicity.
            *set Insanity +3
            *goto beatalexi
    *if (palmcomm = 1)
        *disable_reuse #Create a distraction
            *comment Narrative removed for simplicity.
            *set Ingenuity +4
            *goto beatalexi
    *else
        *disable_reuse #Try to distract it!
            *comment Narrative removed for simplicity.
            *if (Ingenuity > 18)
                *comment Narrative removed for simplicity.
                *set Ingenuity +1
                *goto beatalexi
            *else
                *comment Narrative removed for simplicity.
                *set Ingenuity -2
                *goto alexibeathead
    *if (holdout = 1)
        *disable_reuse #Shoot it!
            *comment Narrative removed for simplicity.
            *if (Marksman > 17)
                *comment Narrative removed for simplicity.
                *set Marksmanship +4
                *goto beatalexi
            *else
                *comment Narrative removed for simplicity.
                *set Marksmanship -2
                *goto alexibeathead
    *else
        *disable_reuse #Throw a rock at it!
            *comment Narrative removed for simplicity.
            *if (Marksmanship > 18)
                *comment Narrative removed for simplicity.
                *set Marksmanship +3
                *goto beatalexi
            *else 
                 *comment Narrative removed for simplicity.
                 *set Marksmanship -2
                 *goto alexibeathead
    *disable_reuse #Try to communicate with it
        *if (Influence > 14)
            *comment Narrative removed for simplicity.
            *set Influence +1
            *choice
                #Do as I'm told.
                    *comment Narrative removed for simplicity.
                    *goto alexicapture
                #Propose a compromise.
                    *comment Narrative removed for simplicity.
                    *set Influence +2
                    *goto capturealexi
                #Poop to that, he can throw [u]his[/u] weapon down!
                    *comment Narrative removed for simplicity.
                    *if (Influence > 19)
                        *comment Narrative removed for simplicity.
                        *set Influence +4
                        *goto capturealexi
                    *else
                        *comment Narrative removed for simplicity.
                        *set Influence -2
                        *goto alexiredo
*label beatalexi
*label alexibeathead
*label alexiredo
*label alexicapture
*label capturealexi

*ending
And here's what that looks like running in ChoiceScript:

Finally, there seems to be a problem with what appear to be a set of underline commands failing to actually underline anything. I'm not sure ChoiceScript supports underlining. Try italics instead?


#156

I did not know it didn’t support underlining; normally I just do italics. Guess I will this time too.

I guess I just didn’t understand why the *else ones were not showing up. If you do not have the Palmcomm, you are supposed to get an alternate choice to distract it using a rock. But maybe that is too complicated.

And the difference between Marksman and Marksmanship is nothing more than me being lazy about remembering to type the whole thing.


#157

I’ve found it’s actually easier to avoid *else commands most of the time. Just use an *if with the opposite requirements. *if (palmcomm), *if (not palmcomm). Otherwise it will try to relate it to the rest of the *if commands on the list.


#158

Hmm.

I replaced *create palmcomm 1 with *create palmcomm 0 to test the *else instead of the *if, then ran it again.

It appeared to correctly replace the "Create a distraction" option (successfully passing the *if ) with the "Try to distract it!" option (failing the *if and falling into the *else .)

I think at this point the standard suggestion becomes “Make sure everything is saved correctly, then clear your browser cache and try again,” right?

I believe the false/negative version has to be one of: *if (not(palmcomm)) note the double parenthesis or *if (palmcomm = false) or *if (palmcomm != true) when used in a choice.


#159

Yeah, that was a typo. I’ve been using *if not (palmcomm) in my own work, and that’s been fine.


#160

Just tried to introduce the *selectable_if instead of just *if, and it threw up an error stating it could not parse the line after. What might that be?

Oh, and the other options are showing now; I moved the Wait it out one to the bottom and that seemed to help.