Setting different counters - again

I say 'again' because I have read this thread but I don't understand the work-flow. Maybe I'm using a later version, but I want to do the same. I understand that I first have to set up my variable and then I have to add an integer, but what I can't work out from that thread is how I set it up in the first place.

Assuming I am in script+text mode and I want to create a counter called 'diplomacy', I do the following:

  1. Click 'Add New Script'
  2. Under Variables I select 'Set a variable or attribute'
  3. Click 'Add'
  4. In the 'Set variable' box I type 'player.diplomacy'
  5. It then says '= expression' (expression is in a drop-down but it's the only option)
  6. This is the bit I don't understand. Do I add in the second box 'player.diplomacy' again?

In the code version of the page I have:

 <script type="script">
  player.diplomacy = player.diplomacy
</script>

...which doesn't make sense.

After that, what do I do? How do I add a value of 10 to player.diplomacy on the first page? Am I adding a second script? Is it a counter?

How do I then subtract a value of 5 from player.diplomacy on page 4, for example?

And then how do I display the player.diplomacy value on a page?


OK, so immediately after posting this I solved the most part of my issue and it's explained in another thread quite comprehensively. However I suspect some new users of Quest are a bit like me in that they learn easier from visual prompts than they do reading through text, so here is a simple screen shot of setting up a variable and displaying that variable on a page.


and if you want to do Addition, Subtraction, Multiplication, Division, Modulus:

(quest/programming calls the operation of addition by the value of 1 a 'counter' operation, and also the VARIABLE used for a 'counter' operation, is called a 'counter' VARIABLE)

it's the exact same screen shot, with this change:

Addition:
// Set variable player.diplomacy = [EXPRESSION] player.diplomacy + VALUE
Set variable player.diplomacy = [EXPRESSION] player.diplomacy + 1
// or
Set variable player.diplomacy = [EXPRESSION] player.diplomacy + 2
// or
Set variable player.diplomacy = [EXPRESSION] player.diplomacy + 5
// or
Set variable player.diplomacy = [EXPRESSION] player.diplomacy + 76
// you get the idea...

Subtraction:
// Set variable player.diplomacy = [EXPRESSION] player.diplomacy - VALUE
Set variable player.diplomacy = [EXPRESSION] player.diplomacy - 1
Set variable player.diplomacy = [EXPRESSION] player.diplomacy - 2
Set variable player.diplomacy = [EXPRESSION] player.diplomacy - 6
Set variable player.diplomacy = [EXPRESSION] player.diplomacy - 99
// you get the idea now...

Multiplication:
// Set variable player.diplomacy = [EXPRESSION] player.diplomacy * VALUE

Division (normal division: finding/getting/returning the quotient):
// Set variable player.diplomacy = [EXPRESSION] player.diplomacy / VALUE

Modulus (normal division, BUT it finds/gets/returns the REMAINDER):
// Set variable player.diplomacy = [EXPRESSION] player.diplomacy % VALUE
// Modulus has a lot of useful applications (such as 'cyclic' value/number needs or determining if a number/value is odd/even/etc)

// example of cyclic application via using modulus:
// clock_second_amount = VALUE % 60
// VALUE = 0, clock_second_amount = 0/60 = R:0 = 0
// VALUE = 1, clock_second_amount = 1/60 = R:1 = 1
// VALUE = 59, clock_second_amount = 59/60 = R:59 = 59
// VALUE = 60, clock_second_amount = 60/60 = R:0 = 0
// VALUE = 61, clock_second_amount = 61/60 = R:1 = 1
// VALUE = 119, clock_second_amount = 119/60 = R:59 = 59
// VALUE = 120, clock_second_amount = 120/60 = R:0 = 0
// VALUE = 150, clock_second_amount = 150/60 = R:30 = 30
// VALUE = 170, clock_second_amount = 170/60 = R:50 = 50
// VALUE = 179, clock_second_amount = 179/60 = R:59 = 59
// VALUE = 180, clock_second_amount = 180/60 = R:0 = 0
// the 'clock_second_amount' will always be (and correctly so): 0 to 59

// military_clock_time = VALUE % 24
// it'll always be: 0 to 23

// civilian_clock_time = VALUE % 12
// it'll always be: 0 to 11

Checking if Odd/Even:

if (VALUE % 2 = 1) {
  msg ("The VALUE of " + VALUE + ", is odd")
} else if (VALUE % 2 = 0) {
  msg ("The VALUE of " + VALUE + ", is even")
}

here's a link for more detail on Attributes and the 'if' Script ( the scripting is the same between Game Book and Text Adventure, it's just more limited a bit in the Game Book, and where/how you do the scripting is a bit different in the Game Book too: Page Type: [script] or [script+text] ):

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
(even though this is for Text Adventure, it'll still be helpful for using the Game Book)


Nice one, thank you hegemonkhan.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums