Ultimate Noob Coding

Well, your recommended fix was off. However, it was the hashtag giving me troubles. I don’t know how that got there. Thanks

Yea, u’re welcome.
(20 obligatory chars)

It’s that time at last; I am moving deeper into coding Nuclear Powered Toaster, and I need to set up gender selection for each MC, and then figure out how to do it for the MC you are not playing as. How does it work with pronouns and whatnot as I go on from here? And, for that matter, when you give a player the choice to create their own name?

Hu?
I thought we get to choose between 2 of pre-set MCs on your NPT :confused:

Which program are you using for that layout?

It’s CSIDE (an app of glory and joy—that’s to say, loads of features and super convenient). Plenty of details and download links in that thread, and feel free to ask away there if you’ve any questions. (:

1 Like

If I want to design random encounters in an area, I know there is a dice roller (there is, right?). But how would I make it continue with the event they were involved with after it ended? Or would I have to do different random encounters for each story path?

For example, you’re in the basement of a facility. You can search for ship parts, try to shut something down, or dash for the exit (among other options). I want to have random encounters with enemy soldiers, which may or may not vary depending on whether there’s currently an alarm sounding. But unless I make the encounters unique to each story, how would I make them go back to the event at hand when the encounter ends?

1 Like

Use *gosub_scene battle (or similar) to go to a new file, battle.txt, where you have the random encounters. Finish the file battle.txt with the command *return.

4 Likes

I didn’t know you could have sub scenes. Neat!

1 Like

i’ve tried adding numbers in my game with *set but i don’t really know how to do it

on one choice i did *set cantrememberwhatitwascalled 1 or it can bet set to 0

but in a later choice i tried *set cantrememberwhatitwascalled + 1 and the first error i ran into was because i had the same *label in, so i took one label out but now it just loops back to the previous choice.

That’s just a problem with your code-flow. Do you mind posting your code here? (and don’t forget the Preformat tag </>)

i’ll try to remember what i did,

`*choice
 #option 1
  some words
  *set relationshipSam 1
  *set relationshipJesse 0
  *goto relationshipSam
  *goto relationshipJesse
 #option 2
  some other words
  *set relationshipSam 0
  *set relationshipJesse 1
  *goto relationshipSam
  *goto relationshipJesse
*label relationshipSam
*label relationshipJesse

then the second choice goes like this

*choice
 #option 1
  some words
  *set relationshipalex 1
  *goto relationshipalex
 #option 2
  some other words
  *set relationshipalex 1
  *goto relationshipalex
 #option 3
  some different other words
  *set relationshipSam + 1
  *goto relationshipSam
*label relationshipalex

i’m guessing it might have something to do with the goto command

Hmm, I see. Loops back, huh?

You said that your error is because you have a same label, so why you don’t name said label differently?


On your #Option3, 2nd choice, you have that *goto relationshipSam. With your current code, selecting that option will make the player loops back to the 2nd choice, instead of progressing forward.

2 Likes

ChoiceScript can’t use both of these *goto commands. As it reads down the lines from the top, it will hit the first command and jump to *label relationshipSam, skipping the second. Once at the *label, it will proceed automatically through it and into the next one (which you imply is *label relationshipJesse.) If this is intended behavior—if you actually want all players to see both labels—then why not simply place the contents of both labels under a single one?

Something like:
*choice
  #option 1
    *set relationshipSam 1
    *set relationshipJesse 0
    *goto next_label
  #option 2
    *set relationshipSam 0
    *set relationshipJesse 1
    *goto next_label
*label next_label

If showing both scenes to all players is not what you want, you’ll need to separate the content of the two labels. There are several ways to do this; the easiest is likely indenting the content inside the options of the choice, before the *goto command. If you’d rather not do it that way, and want to keep the content in separate labels, you’ll want to give each option a different *goto. Whichever label comes first in the code should end with another *goto that skips the second label, by jumping forward to where both segments meet up again.

Something like this:
*choice
  #option 1
    *set relationshipSam 1
    *set relationshipJesse 0
    *goto first_label
  #option 2
    *set relationshipSam 0
    *set relationshipJesse 1
    *goto second_label

*label first_label
*goto it_all_comes_back_together

*label second_label

*label it_all_comes_back_together

Now, looking at your second *choice, because that seems to be where your accidental loop was created…

Why does the *goto command under option 3 send ChoiceScript back to *label relationshipSam instead of a new label with a new name? Choosing either of the first two options of that choice will send ChoiceScript forwards, to the new relationshipalex label, but the final option doesn’t have a new label of its own to go to in this sample. It just loops back to the old *label relationshipSam that was after the first choice and before the second. Giving that last *goto a new place to go should break the loop quite handily.

Something like this:
*choice
  #option 1
    *set relationshipalex 1
    *goto relationshipalex
  #option 2
    *set relationshipalex 1
    *goto relationshipalex
  #option 3
    *set relationshipSam + 1
    *goto relationshipSam2
*label relationshipalex
*goto paths_rejoin
*label relationshipSam2
*label paths_rejoin

Of course, as long as the name of the new label is unique, it doesn’t much matter what it actually is. It could be anything from relationship_sam_again to abc123 by way of help_i’ve_fallen_and_i_can’t_get_up.

Looks like @Szaal beat me to the reply. Eventually I’ll type faster.

1 Like

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.

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
2 Likes

That should do for a start. Danke!

1 Like

Bitte :wave:t4:
Mandatory 20chars

2 Likes

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.

3 Likes

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"
4 Likes