# Ultimate Noob Coding

**URL:** <https://forum.choiceofgames.com/t/ultimate-noob-coding/28655>\
**Category:** ChoiceScript Help\
**Created:** [July 12, 2017, 10:33am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655 "2017-07-12T10:33:30Z")\
**Posts on this page:** 20\
**Page:** 32

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 23, 2023, 10:36am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/631 "2023-11-23T10:36:30Z")

</div>

I was hoping to have them have some text way after their decision to heal (healing takes time, was hoping to reflect that) but it’s kool. I figured it out with a bit of help from my friends.

---

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 23, 2023, 2:35pm UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/632 "2023-11-23T14:35:41Z")

</div>

I asked this before elsewhere but now I can’t find it and I don’t remember what the solution was. ;-;

I’ve also forgotten how to explain anything apparently at this ungodly hour.

Armor has health bar.  
Armor takes damage. Too much damage for armor in this instance.  
Extra damage must go to actual health bar.  
How do?

Leathers-25 gets me a number but I need that number to subtract from another number.

\*Edit:

Wait, am I overthinking this?

25 total damage in this instance…

\*set Health+Leathers-25 ?

Mathematically, it works. Code-wise, I have no idea…

---

<div class="post-metadata">

**Author:** ![Valda\_Reehux](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/valda_reehux/32/126891_2.png) [@Valda\_Reehux](https://forum.choiceofgames.com/u/Valda_Reehux)\
**Post date:** [November 23, 2023, 3:28pm UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/633 "2023-11-23T15:28:24Z")

</div>

adding leather directly to health in a single formula might not be the best idea, let’s say:

health: 100  
leather: 30  
damage: 25

your formula will yields health: 105 which is funny

I think you can do it like this:

leather = leather - damage  
\*if leather \< 0  
health = health + leather

you wait until leather health depletes then apply it to actual health

---

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 23, 2023, 3:45pm UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/634 "2023-11-23T15:45:34Z")

</div>

Ye. I did this (full code)

```choicescript
*if (Leathers >= 25)
  *set Leathers -25
  *goto FacilityEvac
*if (Leathers < 25)
  *set Health + Leathers -25
  *goto FacilityEvac

```

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [November 24, 2023, 5:15am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/635 "2023-11-24T05:15:48Z")

</div>

> [@RascaldeesV2](#):
>
> \*set Health+Leathers-25

You’d need parentheses in there to give CS [only two things at a time](https://forum.choiceofgames.com/t/is-it-possible-making-or-and-statements-with-3-variables/2411/8) to parse, but

```choicescript
*set (Health+Leathers)-25

```

or

```choicescript
*set Health+(Leathers-25)

```

should work.

---

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 24, 2023, 5:20am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/636 "2023-11-24T05:20:48Z")

</div>

Thanks

---

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 24, 2023, 8:00am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/637 "2023-11-24T08:00:31Z")

</div>

I need to put in a checkpoint to reset several temp variables and undo \*hide\_reuse commands that were used earlier.

Is there any way that this can be done? The variables I know I can do by hand but I have no idea for the \*hide\_reuse on how to undo those.

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [November 24, 2023, 8:06am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/638 "2023-11-24T08:06:41Z")

</div>

If you want to be able to undo hiding an option, I’d suggest using \*if variables rather than \*hide\_reuse for the hiding. The latter will only undo if you’re using the new save\_checkpoint functionality; if that’s what you mean by “put in a checkpoint,” then you don’t need to do any of it by hand. But if you’ve got a choice block you want people to be able to come back to separately from restoring a save point, then any hidden options in that block should I think be done using variables.

---

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 24, 2023, 8:07am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/639 "2023-11-24T08:07:21Z")

</div>

save\_checkpoint? When did that become a thing and how do I use it?

Edit:

I don’t see \*save\_checkpoint on the wiki. It’s either really new or I’m an idiot (and both are equally possible)

---

<div class="post-metadata">

**Author:** ![LiliArch](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/liliarch/32/120749_2.png) [@LiliArch](https://forum.choiceofgames.com/u/LiliArch)\
**Post date:** [November 24, 2023, 8:24am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/640 "2023-11-24T08:24:40Z")

</div>

[It is new.](https://forum.choiceofgames.com/t/new-in-choicescript-html-exports-checkpoints-and-achievements/)

(I believe you can reset hide\_reuse by visiting another scene file though, although I could be wrong.)

---

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 24, 2023, 8:27am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/641 "2023-11-24T08:27:41Z")

</div>

I love you.

---

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 24, 2023, 8:28am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/642 "2023-11-24T08:28:40Z")

</div>

And this will also reset all the variables? It will follow the same path backwards or does it work akin to a \*goto where it just searches for the label?

---

<div class="post-metadata">

**Author:** ![LiliArch](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/liliarch/32/120749_2.png) [@LiliArch](https://forum.choiceofgames.com/u/LiliArch)\
**Post date:** [November 24, 2023, 8:29am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/643 "2023-11-24T08:29:40Z")

</div>

I’m not sure what you mean.

---

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 24, 2023, 8:30am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/644 "2023-11-24T08:30:45Z")

</div>

I have I think close to 200 variables to balance right now. If they use the checkpoint system, does it reset those variables itself? Or would I still need to do that?

Edit:

174 variables, not including temporary variables

---

<div class="post-metadata">

**Author:** ![LiliArch](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/liliarch/32/120749_2.png) [@LiliArch](https://forum.choiceofgames.com/u/LiliArch)\
**Post date:** [November 24, 2023, 8:40am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/645 "2023-11-24T08:40:44Z")

</div>

That link I gave you should have all the info you need about that (including some links with extra info).

---

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 24, 2023, 12:33pm UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/646 "2023-11-24T12:33:12Z")

</div>

Do I need a \*gosub file for each \*gosub ? How does the code distinguish which \*gosub to go to if not?

Apologies if this seems like a noob question. I’m not sure how complicated \*gosub is but I’m running into a need for them.

---

<div class="post-metadata">

**Author:** ![coal8](https://avatars.discourse-cdn.com/v4/letter/c/8491ac/32.png) [@coal8](https://forum.choiceofgames.com/u/coal8)\
**Post date:** [November 24, 2023, 12:49pm UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/647 "2023-11-24T12:49:24Z")

</div>

> [@RascaldeesV2](#):
>
> Do I need a \*gosub file for each \*gosub ? How does the code distinguish which \*gosub to go to if not?

you can have multiple \*gosub commands in a single file. The code distinguishes which \*gosub to go to based on the label you provide after the \*gosub command.

For example:

\*label TEXT HERE  
\*gosub text1  
\*gosub text2

\*label text1  
Hello!  
\*return

\*label text2  
Goodbye!  
\*return

---

<div class="post-metadata">

**Author:** ![RascaldeesV2](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rascaldeesv2/32/144587_2.png) [@RascaldeesV2](https://forum.choiceofgames.com/u/RascaldeesV2)\
**Post date:** [November 24, 2023, 12:55pm UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/648 "2023-11-24T12:55:16Z")

</div>

Thanks Coal.

Is there ever any reason at all to have multiple gosub files? Or not really?

---

<div class="post-metadata">

**Author:** ![coal8](https://avatars.discourse-cdn.com/v4/letter/c/8491ac/32.png) [@coal8](https://forum.choiceofgames.com/u/coal8)\
**Post date:** [November 24, 2023, 12:59pm UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/649 "2023-11-24T12:59:34Z")

</div>

in most cases not really ¯⁠\⁠\_⁠(⁠ツ⁠)⁠\_⁠/⁠¯

---

<div class="post-metadata">

**Author:** ![The\_Lady\_Luck](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/the_lady_luck/32/212891_2.png) [@The\_Lady\_Luck](https://forum.choiceofgames.com/u/The_Lady_Luck)\
**Post date:** [November 24, 2023, 3:29pm UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/650 "2023-11-24T15:29:25Z")

</div>

\*gosub doesn’t go to a different file, though. It points to a label in the same file.  
It’s \*gosub\_scene that would be used to go to labels in a dedicated gosub file.  
(unless that’s been canged in the last few years?)

Having multiple files can be nice if you have a lot of technical subroutines, that you call a lot.  
Like, if every stat-raise requires a subroutine, it can be nice to have them in one file, to easily be able to find them. But you might want to keep subroutines that does something completely different in another file.  
And if you have all your romance scenes being accessed by \*gosub commands, you might want to have them in their own file as well.

It’s all mainly a question of structure and organisation.  
Technically, you could write your entire game in a single scene file, though my brain shudders at the thought.

[Previous page](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655.md?page=31)

[Next page](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655.md?page=33)
