Ultimate Noob Coding


#181

Only if you also use *else or *elseif. If you’re using *if by itself, you don’t need *goto commands.

*if evil_count > 0
    "Well, let's see.
    *if evil_deed_1
        You punched this guy.
    *if evil_deed_2
        You stole that spaceship.
    *if evil_deed_3
        You set fire to the orphanage!
    What is wrong with you?!"

I believe you simply open the quicktest.html and/or randomtest.html files with your web browser while your game is saved in default location. I don’t have much experience with either, but I just tested my own CS installation and that’s how it seemed to work.


#182

*if statements, without an *else or *elseif, do not need a *goto.

You look at the man
*if met_john = true
  you know as John
and say hello.

For opening *randomtest and *quicktest, Iuse Firefox. (I installed Firefox purely for Choicescript testing as it seems to be the best browser).
Right click and open with…


#183

Great! That should mean I can just do a long line of *if statements, it’ll display as many as are relevant to their playthrough, then insert a *goto at the end to move on to the next part. Thought it would be harder than that, honestly.

Thanks @andymwhy and @Minnow for the help with that and the tests. Haven’t ran them yet, but intend to after I finish troubleshooting the update I put out there the other day. On that note, I have successfully busted every bug reported on said update on my own, but this one is giving me a rash.

"Wait, her?  Her who?"  128 looks pale.  “Solus.”  You prompt him to give more information, but he refuses even under pain of torture.  Whoever this Solus is, she’s intimidating. (+2 Intelligence)
*set Intelligence +2

What else will you ask your captive?
*temp timer 0
*label repeatinterrogate
*choice
    *selectable_if (alexi = 1) #Let Alexi ask a question.
        *set timer +1
        Alexi looks over the large blaster rifle he purloined from the fallen female.  “Where’s your armory?  This is in pretty good condition, and I want to see how many more we might be able to acquire.”  You cock your head inquisitively, and he starts to get evasive.  “I mean, you know, to liberate them from the wrong hands.”  You feel a bit suspicious about that answer, given that he almost immediately switches his communicator over to the calculator program and starts punching in numbers and licking his lips based on what 128 tells him.
        *set arlship +1
        *if (timer = 1)
            *goto repeatinterrogate
        *else
            *goto deadsquawk 
    *selectable_if (alexi = 2) #Let Fiorella ask a question
        *set timer +1
        Fiorella looks at the top of the mountain.  “How many of you are there?”  The beaten guard shrugs.  “They wouldn’t divulge that information to the likes of me.  TURDs are expendable.  They just point to a square of dirt and say “Stand there”, so you do.  But this facility probably has dozens.  I mean, just look at my number.”  He lifts some of the hair back from his head, and you see a faint blue tattoo that proclaims him to be 128.  “They don’t skip around, this means there’s over a hundred who tested higher than me, and who knows how many that were lower?  And that’s just the TURDs.  Of course, there are other locations, but not many.  Not yet.  That’s what they’re building towards.”  You press him further on this point, but he seems to have little concrete information about the plans.  Just that ‘they’ will soon go on the offensive.
        *set frlship +1
        *if (timer = 1)
            *goto repeatinterrogate
        *else
            *goto deadsquawk
    *if (alexi = 1) #"How many soldiers does this Solus have under her control?"
        *set timer +1
        You gaze at the top of the mountain.  “How many of you are there?  What sort of resistance can we expect?”  The beaten guard shrugs.  “They wouldn’t divulge that information to the likes of me.  TURDs are expendable.  They just point to a square of dirt and say “Stand there”, so you do.  But this facility probably has dozens.  I mean, just look at my number.”  He lifts some of the hair back from his head, and you see a faint blue tattoo that proclaims him to be 128.  “They don’t skip around, this means there’s over a hundred who tested higher than me, and who knows how many that were lower?  And that’s just the TURDs.  Of course, there are other locations, but not many.  Not yet.  That’s what they’re building towards.”  You press him further on this point, but he seems to have little concrete information about the plans.  Just that ‘they’ will soon go on the offensive.
        *set Intelligence +2
        *if (timer = 1)
            *goto repeatinterrogate
        *else
            *goto deadsquawk
    *if (alexi = 2) #Use my Smuggler-Sense to ferret out anything of value!
        *set timer +1
        You examine the large blaster rifle that you purloined from the fallen female.  “Where’s your armory?  This is in pretty good condition, and I want to see how many more we might be able to acquire.”  Fiorella cocks her head at you, cluing you in that it might be wise not to be so open in your greed.  “I mean, you know, to liberate them from the wrong hands.”  Of course, you likely have done little to allay your new companion's suspicions, given that you almost immediately switch your communicator over to the calculator program and start punching in numbers based on what 128 tells you.  Could be even bigger than the payday you got after a long weekend scavving through the ruins of Portland.  Fingers crossed! (Dumb Luck +2)
        *set shared_stat +2
        *if (timer = 1)
            *goto repeatinterrogate
        *else
            *goto deadsquawk
    #Let Dolly ask a question.
        *set timer +1
        You motion the hoverloader over and direct it to ask a question of the captive.  It hovers uncomfortably close to him, a light blinks on its control console, and it almost whispers [i]“Stra-doink?”[/i]  The injured guard looks at you with fear and confusion, then back at the freight carrier.  “Um…yes?”  Dolly floats away almost immediately, apparently satisfied with the answer. (Insanity +1)
        *set Insanity +1
        *if (timer = 1)
            *goto repeatinterrogate
        *else
            *goto deadsquawk
    #“What do you know about the missiles that shot down our ships?”
        Despite his battered state, the guard smirks.  “That you weren’t the first, for one thing.  Project Pinprick, they call it.  They got ahold of some old-style remote missiles, wait until people enter the communications dead zone near the mountain, and blow them out of the sky.  Not everyone who flies over, of course.  Just one out of every twenty, or fifty, or one hundred.  Gradually weaken both military and civilian airpower, and also give them a steady flow of subjects for..whatever it is they play with up there.  Believe it or not, they’ve been doing it for months.  Post-Salian communications and mapping tech is a joke, and both GloPAc and civvies seem uninterested in spending days or weeks poking around mountains and forests on foot to look for someone missing when they can’t even pin down where it happened.  They always do a flyby a few days later, but by then the scav crews have done their job, making the area all squeaky clean.  And when the search parties don’t see any wreckage, they move on.”
        *set timer +1
        *choice
            *selectable_if (pathhack = 1) #“My flight path…
                "…it was locked in by the navicomp.  They must have suspected this was happening.  They set me up!”  Your outburst is greeted with a whoop of pained laughter from the guard.  “Haw haw!  Who’s the TURD now, eh?” (Intelligence +5)
                *set Intelligence +5
                *if (timer = 1)
                    *goto repeatinterrogate
                *else
                    *goto deadsquawk
            #”But where are the missiles located?”
                 The beaten guard shrugs.  ”Anywhere and everywhere.”  You flick his injury and hear him grunt with pain despite the narcotics in his system, but he does not relent.  “No, seriously.  It’s a mobile launch platform, drives around on little rubber wheels like something you’d see in a museum.  Helps keep anyone from zeroing in on where the attacks originate.” (Intelligence +2)
                 *set Intelligence +2
                 *if (timer = 1)
                     *goto repeatinterrogate
                 *else
                     *goto deadsquawk
             #"Do these missiles have a weakness?"
                 You list off the various ways you tried to thwart the projectile, to no avail.  Your captive's response is a knowing nod.  "Basically that's why they use these antiques.  Nowadays it's all emission-seekers, or smart bombs doing stuff on their own.  All you have to do is blank their little computer brain and you're gold.  What you need for these remote jobs is to be faster.  Or a better pilot than the guy they have behind the stick."  You're a little offended by that, but it is good advice nonetheless. (Ingenuity +3)
                 *set Ingenuity +3
                 *if (timer = 1)
                     *goto repeatinterrogate
                 *else
                     *goto deadsquawk
*label deadsquawk

I included all of it, but somewhere in the *choice that branches off from the question about the missiles is what is kicking up an alert that says “expected choice body” I don’t see anywhere that I missed an indent or forgot a *goto or anything.


#184

Now i don’t know if that might be it but the last # (before Do these) is further in than the other. That indention causing it by chance?


#185

There’s probably an indentation error somewhere along that choice body. Try to check if everything is indented on its respective level.

Fyi, your error is strikingly similar with this one.


#186

I think I found it: The first two #options for that *choice are indented by 12 spaces. The third #option is indented by 13. What happens when you remove that one extra space from the last #option?


#187

I took it back a space, we’ll see if that works. I love CSIDE and its auto-indents, but the fact that it seems not to be able to do it right when if/else statements are involved in a nested choice has caused some headaches.


#188

Spacing is always the first thing I check on any error … just is a habit I’ve gotten into.


#189

Question: I have pondered having a -1 to all stats be the penalty for losing all your Endurance (life), at which point it would then reset to 10 or so. How would this be doable? Or is it doable at all?


#190

That sounds like it shouldn’t be too difficult. I’d set up a subroutine to check endurance whenever you decrease it and alter stats if it’s below one.

So your subroutine, would look something like this. (I’d put in a separate scene file since you’ll be using it through out the game – mine is just called ‘subs’)

*label check_life
*if (endurance < 1)
    *if (stat_1 > 0)
        *set stat_1 - 1
    *if (stat_2 > 0)
        *set stat_2 - 1
    *if (stat_3 > 0)
        *set stat_3 - 1
    *set endurance 10
    You have died! Your health has been restored, but all other stats have received a - 1 penalty.
*return

Then, in each place where it’s possible to ‘die,’ you’d reference the subroutine, something like this:

#A foolhardy decision
    *set endurance - 1
    *gosub_scene subs check_life
    Blah, blah story continues

The subroutine above will only make changes if endurance is below 1, and will only decrease stats greater than 0, so you don’t end up with negative stats. It also will display a message for the player indicating what’s happened. If you want to have a unique message for different deaths, you could have a subroutine that only ‘resets’ the player, and only run it if endurance gets too low, something like:

#Another poor choice
    *set endurance - 1
    *if (endurance < 1)
        You're too weak to make the climb. You fall and hit your head! You wake up feeling disoriented. Is there something you've forgotten?
        *gosub_scene subs revive
        *page_break
    The story continues as if nothing happened...

If you wanted to have an achievement for dying or dying a certain number of times, you could put that in the subroutine, too!


#191

I still need to figure out this *gosub you’ve mentioned, but that will likely have to wait for another day.

A more pressing issue: how do I set the results of a random dice roll not to repeat? I am using the roller to give players random encounters as they return to the start of the chapter, but I’m looking for each individual encounter to only come up a max of one time.


#192

Since you’re using numbers to represent random events, maybe you want to make an extra check for every event you have.

Like

*if event_a = false
   *set event_a true
   *goto okay
*else
   *goto rollagain

#193

More like

*label choose
*random dice 0 6
*if dice = 0
    *if (dice_0)
        *goto choose
    *else 
        *set dice_0 true 
        *goto event_dice_0

In this when the dice rolls it will run a check of what number it is

when it confirms it is zero then it will run a check is it the second time it has come up

If it is the second time then it will goto to the dice rolling again and process starts again.

If it is first time then it will set the variable that decides is it used true and goto to the event


Or you can do this

*label choose
*random dice 0 6
*label dice_0_check
*if dice = 0
    *if (dice_0)
        *goto dice_1_check
    *else 
        *set dice_0 true 
        *goto event_dice_0
*label dice_1_check
*if dice = 1
    *if (dice_1)
        *goto dice_2_check
    *else 
        *set dice_1 true 
        *goto event_dice_1

Here when check for 0 fails it checks for 1 and when it fails it checks for 2 and if you think that it might not be random then I would like to tell that it is random because the starting point is decided randomly.


#194

Achievements! What are they and how do they work? I assume they will just involve more variables to keep track of counts for things, but how do I get them to display, and what allows them to track over multiple playthroughs?


#195

Hey, so just to make sure I understand, if I do the gosub_scene for ‘death’, I would put it in a separate scene file, but after the stat adjustments and whatever flavor text I included, it would then take them back to wherever they were in the story automatically in the previous scene?


#196

It’s pretty simple really; in the startup file, you have a list of achievements, like so:

*achievement ach001 visible 10 Achievement 1 Name
    Text for when unachieved.
    Text for when achieved.
*achievement ach002 hidden 20 Achievement 2 Name
    hidden
    Text for when achieved.

(The second is a secret achievement, which isn’t visible until it’s achieved.)

Then, when you want to award the achievement, use the following code:
*achieve ach001

(Note that the CS-code names ach001 and ach002 are just for demonstration; you could use any name as long as it’s a single word. The displayed names “Achievement 1 Name” etc. can also be anything you want, and can be multiple words.)

The program itself should track them over multiple playthroughs (I understand it’s not perfect, though), so you don’t need to worry about that yourself.

Does that help?

EDIT: The numbers (10 and 20) are the “point score” of the achievement, but I have no idea if this is actually used for anything. :confused:


#197

Okay, so each one breaks down like this: the *achievement code tag, its operating name (kinda like with scenes, where they have a single word name in the scene list), whether it is visible or invisible, and I assume the 10 and 20 are point values, then the achievement name people will actually see. Then indent underneath to get to the text that shows before they get it, and then the text that shows after. But there’s nothing code-wise that has to show when the unachieved text is done? It just assume once you hit Return you completed the unachieved text and are moving on to the achieved one?


#198

Yep. The old “unachieved” description will be dumped forever when you achieve the achivement.


#199

Yep! A gosub or gosub_scene always means the game will return exactly where you were, without even losing your *temp variables. You could think of the game going somewhere else and running code until it hits a *return, then going back to its original spot. However, I like to think of the game as borrowing code from another scene and dropping it in wherever you put the gosub. Subroutines are just portable bits of code you can reuse and drop in anywhere, over and over again.

You don’t have to type out the code to check for player death and reset every single spot the play might die. Instead you write it in one spot and give it a (*label) name, then basically tell the game to run that bit of code for me – the one that checks if the player’s dead


#200

Alas! Doing my first actual playtest in a while instead of just running Quick/random in order to check stat levels, and came upon an issue.

*if (mountain = 0)
    "You two have also been inciting some of those Drake Valley hicks to start revolting, which I did not need since they were plenty revolting enough to begin with, hyuk hyuk hyuk."
    
*if (shotturd = 1)
    "You flushed one of our most promising TURDs, Number 33, with your stubborn unwillingness to lay down and die."
    
*if (transportcrash = 1)
    "You hijacked and crashed a very fancy, and not entirely paid for, troop transport.  Which goes to show why we can't have nice things."
    
    "You also managed to wipe out far too many of my more seasoned Blitztroopers.  People with actual combat experience don't just fall from the slagging sky, you know.  Well, sometimes they do, but not often enough."
    
*if (transportcrash = 2)
    "You insensitively got blood all over my very fancy, and not entirely paid for, troop transport.  Which goes to show why we can't have nice things."
    
    "You forced my soldiers to expend several dozen yunis worth of ammunition and supplies in repeatedly detaining and defeating you.  It’s not much, but little expenditures can add up to big budgetary headaches later on.”
    
*if (Insanity > 20)
    "Last but not least, you have thoroughly weirded out everyone you have come into contact with."  Solus looks you over.  "Myself included."
    
As she finishes listing your deeds, you cannot help but feel that this severe woman seems oddly familiar.  There is little time to follow that chain

So shotturd and Insanity >20 showed up like they should have, but transportcrash didn’t, despite me having it = 1 because I crashed the thing. The stat is in startup, and all the other stats that got +1 where it did were added correctly. What’s happened?