Real Basic Question about Making and Controlling Integers

DShittyAdmiral
04 May 2018, 04:10

Hello.
Just wanted to know how to declare a characters initial stats as integer variables for the start of the game, and then how to change those integers with events in the game. I've been using set variable and it doesn't seem too work.

What I want for clarity purposes is a player to start with a strength stat of say 5, and then when they interact with an object, that variable goes up by 1 * a multiplier of sorts.

If someone can point me where I can control integers and then use if statements with them, like if the strength stat is under 5, don't let the player do x, that'd be great.


CheeseMyBaby
04 May 2018, 07:49

Set an initial value:
player.strength = 100 // or whatever you want it to be at the start. This goes in the start script.

Changing the attribute:
player.strength = player.strength +1 // if you want to add +1to whatever the value is at the moment.


The IF statement

if (player.strength < 5) {
  msg ("Go to the gym already!")
}
else {
  msg ("Hey Arnold!")
}

Was this what you're looking for?
I'm still fairly new to this myself :)


hegemonkhan
04 May 2018, 11:52

here's some links/guides for you:

http://textadventures.co.uk/forum/general/topic/ljjm32av4e2t9ot49k478g/help#710be61e-eae1-4af1-8363-520cc718ba1c

(in particular, look at the 'attributes and if script usage' link/guide of mine, and within it, scroll down to about half way, to the' two super scripts' section, covering Attributes and then the 'if' Script)

ask if you need help with anything


DShittyAdmiral
04 May 2018, 14:03

So how would you do less than or equal to for the if?


DShittyAdmiral
04 May 2018, 14:07

Nvm. Figured that out. Thanks for the replies.


hegemonkhan
04 May 2018, 18:25

I always have a hard time remembering which side the equals is on...


quest's operators/operations (might be missing some):

lesser than or equal to: XXX <= XXX
greater than or equal to: XXX >= XXX

equal to (comparison): XXX = XXX

assignment: XXX = XXX

not equal to (A): XXX <> XXX
not equal to (B): not XXX = XXX

lesser than: XXX < XXX
greater than: XXX > XXX

concatenation: +

escape: \X

addition: XXX + XXX
subtraction: XXX - XXX
multiplication: XXX * XXX
division: XXX / XXX
modulus: XXX % XXX

comment line (A): // XXX
comment  block/line (B): <!-- XXX -->

scripting assignment/syntax: XXX => { XXX }