My coding questions


I sincerely hope no one finds this a problem, but it just seems easier for me to keep all my questions in one thread for my future reference. And here’s my first question.

I’ve got contenteditable.html open from the editor sub-folder, and I copy & pasted one of my scenes. I had created & set a variable for arenavisit (a true/false setting) in my startup.txt, and when I run my arena.txt through the contenteditable.html, it stops at the arenavisit check (for true/false setting) and tells me its a non-existant variable…which it is, in arena.txt, but I originally set it in startup.txt.

What do I do? It wont let me check anything passed that line.


If your just running arena.txt through it then it wouldn’t run start.txt to set the variables. May I ask why your using contentedible.html I’ve never had to do that to test the game. I just open index.html


From the brief while playing with contenteditable (edible? :D) I found it useful for when you want to test a particular snippet of your code without having to mess with existing variable structure. It’s like a code editor in the browser. Not sure if it becomes irrelevant since the startup thingy was introduced, assuming less people are using mygame.js now. I think it worked with browser other than Firefox, too - I used Opera back then, which is not much usable for offline tests.

But yeah, it didn’t seem to pass variables around with more than what’s in the one txt you’re working on. I suppose you can always paste in from the other file the bit where you define all the variables needed to make them local?


I think contenteditable is something Dan’s been slowly working on, I would imagine it’s still incomplete at this stage, you’re best testing your game directly through running index.html.

Or if you really want to use it, you could try including ‘mygame.js’ as a script source in the header - but that’s assuming you’re using mygame.js, not the *create command.


@Nocturnal_Stillness This is my first CoG I’ve ever made, so I’m just trying a little of everything to see how they work.

@CJW I’m using the *create command, and I have no idea how to use mygame.js.


I tried 2 different methods of coding so far. The first was to put all the choices & goto statements at the beginning of startup.txt, with all the blocks of in-game text at the bottom…seemed to work well. The second time, I tried doing it all branch-style (for lack of knowing the proper term) with the choices leading straight to the text.

Turns out I suck at the second way I tried doing it. The first way, I can’t be certain as I’m a beginner at this, but I feel like there must be some way to tighten it up a bit. Can I have a coding pro volunteer to have a look at it? Its just character creation and all the pre-game stuff I’ve already DropBox’d for all to see, so there are no spoilers in it.


Alright, well that second way (indented, couldn’t think of the word yesterday), still isn’t working for me. I blame myself, not the tool. Back to my original way of doing it.


     #Click me
        This is how you do it!
        New page...
        Another choice!?
            #What is this madness!?
               Well done. You win.
               Have a medal!
     #Or me
        Different text!
        End of game.


Thank you, but I’m also having trouble with choices within choices and if statements. Its almost absurd how much I remember Basic from nearly 30 years ago (which is quite similar) and I can envision how I’d write it that way.

I think I need a voluntary private mentor to answer my questions as they come up. I’m gonna feel bad hogging the board with questions that’ve probably already been asked a dozen times.


Feel free to message me - but keep in mind that if you post it publicly others with the same problem can learn too :slight_smile:


@DaveDPF This is your thread! Don’t feel bad about ‘hogging the board’ there’s no such thing. Everyone needs to learn. It can also be better if you post publicly, that way if one person can’t answer the question someone else can, and other people in your situation will also learn things.

I have issues with choices within choices. I just use the *goto command so I don’t need to deal with lots and lots of nested choices and trying to keep track of my indentations.

I also had huge issues with if statements and trying to wrap my head around the logic when I first started on choicescript. It was so bad that I tried to do everything in my first game to avoid them. I think I had one small section with an if statement and it took a ridiculous amount of time for me to write it.

I remember writing my first ever text adventure in Basic from a book I borrowed from the library. It wasn’t a very good game, or very long either, but I was determined that I was going to try. Choicescript is just so much better. :slight_smile:


Yeah, Choicescript is brilliant once you get the hang of it. Dan Fabulich … ha, more like Dan FabuLOUS.

I’m here all night, ladies and gents. … Try the veal.


You guys and gals here at CoG really are pretty awesome. Thanks for the encouragement, I truly appreciate the support…sure beats seeing replies that just say RTFM. :wink:

Rock on, my fellow CoGers!


In an effort to avoid anything even slightly spoiler-ish, I’ll replace some text here with x’s, but the error I’m currently getting is Expected option starting with # (at the line that starts “That’s odd”)…

*label examine

*if Brains > 2
  In particular, you notice xxxxxxxxx.
*label bas_relief
  *hide_reuse #xxxxxxxxxxxxxxx.
    *goto bas_relief
  *hide_reuse #xxxxxxxxxxxxxxx?
    *goto bas_relief
  *hide_reuse #xxxxxxxxx?
    *goto bas_relief
  *hide_reuse #xxxxxxxxxxxx.
    *goto bas_relief
  *hide_reuse #xxxxxxxxxxxx?
  *if Brains > 2
    *goto bas_relief
    That's odd, xxxxx.
    *goto bas_relief
  #Nah, I'm done here.
    *goto arena_entrance


When using *if statements, you need an *elseif for every option that isn’t the last option (which is *else).

*if blah = 0
*elseif blah = 1
*elseif blah = 2
Whatever comes after 2.


You might have replied while I was editing my post, please check again? Where did I go wrong with my if/else lines? (and I know it isn’t indenting properly, can’t seem to post screen caps).

*if Brains > 2
*goto bas_relief
That's odd, xxxxx.
*goto bas_relief


You don’t need elseif or even else. I just use ifs.


You can put code in the forums by doing

< pre>
Code here
< /pre>

with no space between the < and the pre>

like so

Code here

It will preserve your formatting.


You don’t need to use else? o.O My whole life has been a lie.


You don’t need to use it. If you cover every option with an if statement, then you don’t need else, since there’s nothing else left.

Else can be useful of course, for everything you’ve not covered.

It’s probably bad coding of me not to use it, mind you.