Creating New Values - Need Some Help With the Setup


I’d like to try and create a ‘sound-level’ system in my game that can trigger specific events (the alerting of guards, for example). Some actions that the player will perform can increase or decrease the sound level. For example:

My problem is getting it all set up. I checked out section 4.5 (Kinds of Values), but I’m not 100% sure where to go after “Sound Level is a value.” Or, is that all there is to it, and I’m mistakenly thinking it’s overly complicated?

Thanks in advance.

Hi Holmes.

You need to tell the game what kind of value it is.

So in your case you’d say:

Sound Level is a number variable.

You could also have said ‘a text variable’, or another kind, but obviously you want number.

Having done that, you’re pretty much good to go. When you create a variable, it starts out blank/empty, or in the case of a number, at zero, unless you say otherwise.

Note that where you say ‘increase Sound Level by 8’ - whenever you’re stating a bit of code that will change something during the running of the game, you need to begin it with ‘now’.

So the line would be:

now increase Sound Level by 8.

The now is really referring to ‘at the moment this line of code is run, do such and such.’

Wow, so it really was that simple. Thanks, severedhand.

A small correction: the “now” phrase’s syntax is actually “now … is …”. “Increase X by Y” is a fixed phrase so “now” is not allowed there. Either “increase Sound Level by 8” or “now Sound Level is Sound Level + 8”.

Oh yeah, you’re right.