Ultimate Noob Coding

I think—though I’m not absolutely certain—that *gosub_scene retains all your settings from the initial scene (and plain *gosub certainly does).

If I understand correctly, *gosub and *gosub_scene essentially are the equivalent of plopping that section of code into your scene file—just, it’s conveniently tucked away somewhere else for tidiness and easy of access. (:

Edit: Oh yes, the Wiki says you are fine. From here:

It is the basic nature of ChoiceScript to “unload” one scene when it loads another (i.e. when using either the *finish or *goto_scene commands), meaning that any existing scene-specific *temp variables and #option _reuse states (*hide_reuse, *disable_reuse & *allow_reuse) are lost from memory - mostly because they’re no longer actually needed once the game advances to a new scene file.

*gosub_scene, however, essentially (if briefly) loads the indicated file behind-the-scenes and does not actually “unload” the current scene file in the process, meaning that unlike for a *goto_scene, all of the current scene’s *temp variables and #option _reuse states are retained in memory and will still apply after the subroutine has been used.

3 Likes

Nope, IIRC.
Gosub works by “borrowing” codes instead of “leaving” the original scene.

*temp, *hide_reuse, and *disable_reuse won’t reset.

1 Like

Thanks! I will insert the gosub into every Endurance check then.

1 Like

Hmm, is there anything… “special” with your Endurance that you need its own scene file?

Honestly, as you can tell I have a pretty limited understanding of gosub due to not having used it elsewhere in the story. I set it up this way because in the original post Alexandra made, that was how she referenced it, as a subroutine in a separate scene file.

@Szaal, if there’s a better way, definitely let me know. I have only implemented it in part of one chapter to test it (it worked), so I still have time to go a different route.

Is it weird that every time I read about someone talking about gosub, I feel like eating Subway?

1 Like

Five. Five dollar. Five dollar subroutines!

2 Likes

Ooh, I remember now :open_mouth:

Yes yes, you’ll need a bunch of extra coding for that all stats -1 mechanic (which is done via that *gosub)

I’m just curious if your *gosub actually makes simple changes that you don’t even need the *gosub itself ._.

More questions, because I’m probably gonna spam this thread tonight before I submit:

How do I include my cover art in the game?

On the submissions page, there is a click and drag box to upload the art files (or you can browse and highlight to upload)

Art is not necessary for the competition however and isn’t part of the judging.

2 Likes

My (hopefully) last question before this monument to my noobness goes idle (at least, until my next project).

I am on my last playtest before submitting. All is well, except an achievement I have tied to getting a stat above 25 keeps popping up with the message every time you go to the stat screen, as if you just unlocked it. How do you get it to stop showing once the achievement’s been gotten?

Are you triggering the achievement from the stat screen? And if so, do you particularly want to carry on doing so rather than from a chapter’s end? (As is, if it’s from the stat screen, this would mean people who don’t check their stats would never receive the achievement—and I don’t know what it’d do to, say, the iOS tablet view where the stats are always visible alongside the code).

Anyway, there’s also the very convenient check_achievements command. You can use:

*check_achievements
*if (choice_achieved_statover25 = false)
    *achieve statover25

With whatever your achievement’s codename happens to be rather than my placeholder.

1 Like

How could I trigger it from somewhere other than the stat screen without cramming the code in everywhere that stat increases occur?

I like the *check_achievements option, but I don’t quite understand what I would put in the *if there.

You could just check at the end of a chapter, or you could use *gosub every time you raise that particular stat to go to a bit of code that checks if it’s over 25 and if the achievement’s already been reached, and then if not it gives the achievement.

Like:

*set cheerful %+20
*gosub cheerful_reward

And then at the bottom of the scene:

*label cheerful_reward
*if (cheerful > 25)
    *check_achievements
    *if not (choice_achieved_cheerful25)
        *achieve cheerful25
*return

Maybe, if you’ve not yet, try taking a look at the wiki page for a detailed explanation on how to use the *check_achievements command, with some ready-made samples? If that doesn’t help, I can try explaining it as well, if that’d be useful.

2 Likes

So i was randomtesting but i got the error:
RANDOMTEST FAILED: Error: line 301: No selectable options

But in the line 301 i have a hide_reuse + selectable_if command. The code looks like this;

*label packing

You've got ${hoursleft} minutes to pack up. 
*line_break
*line_break
What wouldyou like to do…
*choice
    *disable_reuse *selectable_if (hoursleft > 30) #Take a shower. (30mins)
        *set hoursleft -30
        *goto packing
    *disable_reuse *selectable_if (hoursleft > 15) #Put all the clothes you like into your bag. (15mins)
        *set hoursleft -15
        *goto packing
    *disable_reuse *selectable_if (hoursleft > 45) #Put all your clothes, skin care products and your memory box into your bag. You might not come back again at all. (45mins)
        *set hoursleft -45
        *goto packing
    *disable_reuse *selectable_if (hoursleft > 00) #Caffeine! It always helps...
        *set hoursleft -30
        *set caffeine +1
        Some text in different language here.
        *line_break
        *line_break
        Text in different language.
        *page_break
        Text in different language.(Then) You have always been a dreamer, haven't you?
        *choice
            #Yes, i've always liked to dream.
                *set Dreamer +50
                *goto packing
            #Yes, i've liked to dream occasionally.
                *set Dreamer +25
                *goto packing
            #I like to dream sometimes but i don't escape from the truth.
                *set Dreamer +0
                *goto packing
            #I dream rarely. I don't like to escape from truth.
                *set Dreamer -25
                *goto packing
            #No! Dreaming is for losers.
                *set Dreamer -50
                *goto packing
    *disable_reuse *selectable_if (hoursleft > 30) #Text in different language.. (30dk)
        *set hoursleft -30
        *set Combat +3
        Text in different language
        *goto packing
    *disable_reuse *selectable_if (hoursleft > 30) #Text in different language. (30dk)
        *set hoursleft -30
        *set Persuasion +3
        *set Intelligence +3
        Text in different language.
        *goto packing
    *disable_reuse *selectable_if (hoursleft > 00) #You leave.
        *goto check_dreamer
    
*label check_dreamer

Since i was too lazy to translate some of them right now, i just put "text in different language. I guess what randomtest couldn’t get through is that it tries all the options and run out of time so it becomes unable to choose some of the options. But how is it possibleto pass randomtest when you have a code like this ?

Thanks for any help :slight_smile:

try adding a = to the >'s and see if that works.
also, is it intended that you end up with 0 hours at every option?

the 4th option would probably set it to a negative… and I think you can’t have a page_break in there.

I would delete the *selectable_if on #You leave entirely… you always have 0 or more hours left, so it can’t do anything useful.

Similarly, I’d assume that once you decide to leave, you’re done with this section of the game, so probably the *disable_reuse option isn’t doing anything there, either.

So changing that line to just #You leave with no modifiers will probably fix it.

I will try this first. Then…

…Then i will try this on the original code even if Dan’s solution works.

No, hoursleft variable is set to 120 , so you got 120minutes to use.

I will update the first post after i try and you will have an opinion on what was causing that.

Nah, just try out both solutions. If the error still comes up, you can go back here.

However, my guess is that for some reason, your hoursleft goes minus, thus no option can be chosen.

1 Like

RANDOMTEST PASSED :grin:
This worked, thanks everyone.

1 Like