Ultimate Noob Coding


#121

Nope, I’ve got it. I copied the scenes directory and all the images from the old mygame directory. The problem is, I also copied the old index.html file too :blush:


#122

Well, that was rather anti-climactic solution :expressionless:


#123

So, I’m messing around with a scene in my WIP and decided that one of the choices I’ve let people make earlier in the game should force a character to be in a certain scene later. So what is currently:

*choice
	*selectable_if (intheair = 1) #I was avoiding sniper fire and trying to fight back. 
		*if (sawreinforcements = 1) 
			*set dovehackedcomms 1
			*goto evasivemanuevers1
		*elseif (sawreinforcements = 0)
			*goto evasivemanuvers1
	*selectable_if ((snipersspotted = 1) AND (gunissniper = 1)) #I was giving Dove cover and taking out the enemy snipers.
		*if (sawreinforcements = 1)
			*set dovehackedcomms 1
			*goto droppingsnipers1
		*elseif (sawreinforcements = 0)
			
			*goto droppingsnipers1
	#I was firing at exposed guardsmen on the platform. 
		*goto droppingguardsmen1

Should be replaced with the first option going on its own and the others being separate paths. So, can I make an “if/elseif” where the elseif contains the choice and the if statement alone goes to evasivemanuevers?


#124

Two questions, if I may. First, what exactly do you mean by “going on its own” in this context, and what makes that different from just another “separate path”?

Second, why not replace *elseif (sawreinforcements = 0) with *else ? Currently, if the variable sawreinforcements holds any value other than 1 or 0, ChoiceScript won’t know what to do. What should it do if sawreinforcements is 2, or 3, or 0.35? Using *else will collect all the possible values for a variable that haven’t been named already, so ChoiceScript will always know what to do, no matter what value the variable holds.

Now, to answer what I think you’re asking, please correct me if I’ve guessed incorrectly, either:

  1. You want players who have both intheair = 1 and sawreinforcements = 1 to automatically advance to *label evasivemanuvers1 without seeing the *choice at all, or
  2. You want players who chose the first option to go to *label evasivemanuvers1 only if they have sawreinforcements = 1, while players who chose the first option with sawreinforcements = 0 should go to a different *label.

If my first guess is correct, you can stick something like *if (intheair = 1) and (sawreinforcements = 1) ahead of the *choice, so that players who meet both are automatically sent to the appropriate *label before ChoiceScript ever shows the *choice.

Something like so:
*if (intheair = 1) and (sawreinforcements = 1)
	*set dovehackedcomms 1
	*goto evasivemanuvers1

*choice
	*selectable_if (intheair = 1) #I was avoiding sniper fire and trying to fight back.
		*goto create_a_new_label_for_this
	*selectable_if ((sniperspotted = 1) and (gunissniper = 1)) #I was giving Dove cover and taking out the enemy snipers.
		*if (sawreinforcements = 1)
			*set dovehackedcomms 1
		*goto droppingsnipers1
	#I was firing at exposed guardsmen on the platform.
		*goto droppingguardsmen1

If my second guess is correct, just use different *goto commands after *if and the *else (or *elseif, as appropriate.)

Perhaps something like this:
*choice
	*selectable_if (intheair = 1) #I was avoiding sniper fire and trying to fight back.
		*if (sawreinforcements = 1)
			*set dovehackedcomms 1
			*goto evasivemanuvers1
		*else
			*goto create_a_new_label_for_this
	*selectable_if ((sniperspotted = 1) and (gunissniper = 1)) #I was giving Dove cover and taking out the enemy snipers.
		*if (sawreinforcements = 1)
			*set dovehackedcomms 1
		*goto droppingsnipers1
	#I was firing at exposed guardsmen on the platform.
		*goto droppingguardsmen1

You may note that in both my examples, I completely removed the *elseif statement under #I was giving Dove cover and taking out the enemy snipers. In your own example, both the *if and the *elseif used the same *goto, and you didn’t mention changing that. Since the only difference between the *if and the *elseif was the extra variable setting under the *if, I simplified that part of the code until it only set the relevant variable.

If you didn’t actually intend for both sides of the *if/*else to go to the same place, it would be simple to leave the *else in, and give it a different *goto than the *if received.

Again, I’m not entirely sure what you’re asking for help with, and I’m working on my best guesses. I hope this helped, and I apologize if it didn’t.


#125

My computer updated last night and restarted. I reopened my programs (including CSIDE) and it said I had a combo of tabs and spaces, which I didn’t as it would’ve been caught on the Quicktest the night before when I posted my update. Anyways, I’m trying to get my tabs reformed and it keeps complaining about this section.

*choice
	#Lisa
		*set AIName "Lisa"
		*goto FirstStalk
	#Jake
		*set AIName "Jake"
		*goto FirstStalk
	#Samantha
		*set AIName "Samantha"
		*goto FirstStalk
	#Michael
		*set AIName "Michael"
		*goto FirstStalk
	#Didn't you hear me? I said *I* would name ${AIhim}.
		*label input_AIName
		You're right. Go ahead. 
		*input_text AIName
		
		*comment check capitalization
		*if ("${AIName}" != "$!{AIName}")
			#Your AI's name is $!{AIName}, is that right?
				*choice
			(		#Yes.    *comment  Line 295 is here
						*set AIName "$!{AIName}"
						*goto FirstStalk
					#No, I named ${AIhim}, ${AIName}. The mission must be distracting me.
						*goto FirstStalk
					#No, my memory is a bit fuzzy.
						*goto input_AIName


Error: startup line 295: It is illegal to fall out of a *choice statement; you must *goto or *finish before the end of the indented block.

I’m not seeing what is wrong, any ideas?


#126

On that option, you have a conditional check for ("${AIName}" != "$!{AIName}"), but not for its opposite.
As the result, if I input my AIName : “Bobo”, it will pass the check and will “fall out” of the *choice body


Besides, the option #Your AI's name blabla... is not nested on any *choice body (unless you intentionally wanted to show the hash symbol, ofc) :thinking:


#127

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


#128

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


#129

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?


#130

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


#131

Which program are you using for that layout?


#132

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. (:


#133

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?


#134

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.


#135

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


#136

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.


#137

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


#138

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


#139

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.


#140

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.