Ultimate Noob Coding

how do you mean?
and it might be that my thing there’s missing a paranthesis or they are in the wrong place

I think you’re going to have to set it every time the components are updated. Try:

*set morale 0
*set morale + ((var1 + var2 + var3 + var4) /4)

I think that should work; might be a less clunky way of going about it though.

Tried that didn’t work so I tried adding parantheses now it says open parenthesis

Maybe this is shorter:
*set morale (((var1 + var2) + (var3 + var4)) /4)

1 Like

YES, that works that’s good

MAkes the game load laggy as hell tho for some reason

No, if you want the average of four values you don’t need to add the new average to the old one.

(50 + 25 + 60 + 55) / 4 would be 47.5 average
while let’s say 47.5 + ((45 + 35 + 65 + 50) /4) would be (rounded) 104.4 or something

edit: @Classified try

*set morale round(((var1+ var2) + (var3 + var4)) /4)

without round the game might run into infinite numbers i think

Yes this is what I used *set Morale (((Brett + Linda) + (Herby + Samirah)) /4) and it worked

I set the stat for morale to be in percentages

Do I still need the round if it’s set in %?

Never feel bad about being the only one asking questions here. I was the only one for like the first 70 posts or so. And I left it open specifically because it could be a good spot for people to ask questions with no judgment, as the title sorta shows you’re needing help with the basics.

Also would *create Morale (((Brett + Linda) + (Herby + Samirah)) /4)


Only once. You can use create to set the starting value but not for updates.

So I create it to be 0 and set it later. it works, but i’m just wondering if there was a way to make the code more efficient.

No, it will show an error.
Invalid create instruction, value must be a a number, true/false, or a quoted string.

I know, I tried it and it didn’t work. exact error as you showed.

Is it only for showing in stats or for other purposes in the game as well?

Ask that in my Thread please this is for Coding purposes only

If it was only for showing in stats, setting it in stats scene file would be enough.

It’ll play a part later in the game, setting this up just for show isn’t enough. People want romance so I gotta give it to them

1 Like

Morale will be changing every time a relationship stat changes, so it needs updating every time. You can either use that *set command every time, or creating a subroutine like this:
*label setting_morale
*set Morale round(((Brett + Linda) + (Herby + Samirah)) /4)
So then you change a stat, you can do this:

Brett likes what you do.
*set Brett +10
*gosub setting_morale

You can read about *gosub and *gosub scene.

1 Like

A sub routine can be created anywhere right? and it doesn’t need to be link to anything right? Or does it have to be created in a specific txt file?

It can be created somethere at the end of the scene file where it’s used (if you use *gosub), but if you need to update that variable in several scene files, you should either add that subroutine in every file, or create a new scene file for subroutines and use *gosub_scene.
Or use that *set Morale round(((Brett + Linda) + (Herby + Samirah)) /4) everywhere.