I’m doing a little challenge this weekend and crafting my first attempt at a game. This morning’s timesuck has been an error I’ve been getting in VSCode (with the choicescript extension) that tells me actually nothing when I attempt to run the game other than that there’s an error on the line that holds the following code:
*create trait_optimist false
Earlier in the startup file, I created the related numeric variable that will be used to trigger the above boolean at a certain threshold:
Any insight would be appreciated! I’ve been reading through the available posts, but I haven’t found an exact answer.
I’ve deleted the boolean forming text, cleared the formatting, and then retyped it out - that didn’t work.
These trait booleans are set to false in the startup (and I’ve set them to trigger to true on the stats page according to numeric variables that are affected by choice in prose. Perhaps that’s the issue?)
These exist because I would like the stats page to be narrative instead of numerical. So, eg, a player with a trusting stat 80 or above would have their trait_optimism set to true on the stats page, which would then show a sentence like “You tend to believe the best of people, and you’re not afraid of trying again if proven wrong” instead of just showing the numerical value of the trusting variable (Is there a larger issue with this, perhaps, that I’m not seeing?)
As far as I’m aware of you either can’t or shouldn’t set stats on the stats page, but I’m not sure if that’s what’s causing this issue. To test it, could you remove that code from the stats page and set it after trusting is raised instead?
Edit: The stats cap code also won’t work unless it’s run after every time the trusting stat is raised, by the way. You could put that code and the bit that’s now on the stats page in a gosub or gosub_scene, and then refer to it every time the trusting stat is raised rather than having to type or copy the whole thing over and over.
Thank you! I’ll absolutely be moving those caps over to a gosub or gosub_scene then!
And re the main error: I took out the if (trusting>=80) bit from the stats page and the same error occurred on the aforementioned line. I guess I should note that these create traits and their stat page thresholds also didn’t trigger an error when I was fiddling with it last night, so I’m a bit lost.
Edit: Except!! I totally added choices that affected this variable this morning. I’ll have to dive more into that.
I’ll go read up on gosubs and see if the answer maybe also lies there!
The error message in total reads “error on line 102,” which is what holds the create trusting boolean. For other errors, it’s been more detailed, like unexpected indent change or a variable not being defined, which is why I’m a bit more lost on how to fix this one.
Edit! TURNS OUT my coding program, though set to wrap the text before the edge of the visible window, slid the error message all the way to the right, making it only visible if I extend my typing window across two screens. BUT I found the rest of the error message, which says “invalid create instruction, only allowed at the top of startup,” so it seems @Cecilia_Rosewood’s instincts were solid!
Vague errors are often related to the line above or below where it declares the error. It might be an indentation error, but it could also be something else.
Global variables (the ones made using the create command) also need to be made at the top of the .startup file, and iirc the block of create commands can’t be interrupted (blank lines are fine as long as they’re indented the same as the create commands), so it might also be because you put a comment between two create commands, or because it’s not in the right file.
I’ll absolutely look around the error line a bit closer then! I tried just deleting to what happens, and the same vague error floats to the next line or the new 102.
But I have seen plenty of comments in startup text that seem to work fine when running games, and it’s such a helpful way to keep organized that I dont want to lose it
I think that’s exactly what it was!! I’ve removed them, and everything is running beautifully. I’ve put them back on the stats page, and it seems fine for now!