Functions

NinjaNin
15 Jul 2017, 08:37

So I'm at another roadblock. I'm on the next part of the tutorial and am having problems with the function. I can get the function to run through but it's like looking at bob is the same as using the defibrillator. I have the function set up pretty good, not getting any error messages, but I can't look at bob and use the defibrillator. I kept Bob's description the same with the flagging.

Looking at him brings up the message he's lying still and trying to use the object on him brings up you already revived bob, which is what I put for the message. Can anyone tell me what I need to do? The tutorial is really good but sometimes it feels like they miss some basic things or gloss over details.


Doctor Agon
15 Jul 2017, 08:44

Have you changed the 'look at bob' to an 'if... then... else...' script. Sometimes it's best to check spelling of flags, even capital letters


NinjaNin
15 Jul 2017, 09:06

Yea, I changed the look at bob to the if... then... else script. It works when I look at bob. But it seems the game takes looking at bob the same as using the defibrillator on him.


XanMag
15 Jul 2017, 11:13

I'm not totally sure what the tutorial says to do, but it seems like this question/problem pops up now and again.

Here is what I would do to achieve desired effect:

  1. On defib object, select 'use on other object'
  2. Choose Bob as other object
  3. In the script for this, place an If script and choose 'If object Bob has flag alive' THEN print message "You cannot use a defib on someone who is alive and well!" (or like message). In the Else part of this script, run your print message script reviving Bob AND set flag on object Bob and name it 'alive'.
  4. In the look at description for Bob, place an If script and check for the 'alive' flag. If object Bob has flag 'alive', then print message "Bob is alive. Well done!" ELSE print message "Bob ain't looking so good."

I know you probably already know how to do this, but I typically reserve functions for actions that can be triggered through multiple inputs.

As an example, I might use a function to respond to the player typing "Ask [insert NPC name here] about treasure" and if you want multiple NPCs to respond the same way (or, more advanced, pull from a set of seemingly random responses) you might be better served calling a function. This is a pretty lame example, but I think you understand what I mean. Bottom line, I use functions to clean-up and organize multiple responses. I would never use it for a simple instance like reviving Bob.

As I ramble on... in fact, in a real game, I would likely use a "second" Bob entirely. When you use the defib on the "dead Bob" I would remove object Bob from game and make Bob1 (alias Bob) visible. This way, you can talk to Bob and ask him all sorts of questions and you wouldn't have to fiddle with IF/THEN scripts for every new thing the "dead Bob" couldn't do! =)


hegemonkhan
15 Jul 2017, 23:10
     <object name="defibrillator">
        <inherit name="editor_object" />
        <look>A heart defibrillator can magically revive a dead person, if all those hospital dramas are to be believed.</look>
        <take />
        <use type="script">
          if (player.parent = lounge) {
            revive Bob
          }
          else {
            msg ("You're not even remotely close enough to place the defibrillator on Bob's chest.")
          }
        </use>
      </object>

    <object name="Bob">
      <inherit name="editor_object" />
      <inherit name="male" />
      <usedefaultprefix type="boolean">false</usedefaultprefix>
      <alt type="list"></alt>
      <look type="script">
        if (GetBoolean(Bob, "alive")) {
          msg ("Bob is sitting up, appearing to feel somewhat under the weather.")
        }
        else {
          msg ("Bob is lying on the floor, a lot more still than usual.")
        }
      </look>
      <askdefault type="script">
        if (GetBoolean(Bob, "alive")) {
          msg ("I can't help you, sorry.")
        }
        else {
          msg ("He is dead, you won't get an answer from him.")
        }
      </askdefault>
      <useon type="scriptdictionary">
        <item key="defibrillator">
          revive Bob
        </item>
      </useon>
      <tell type="scriptdictionary" />
      <ask type="scriptdictionary">
        <item key="heart attack cardiac arrest">
          if (GetBoolean(Bob, "alive")) {
            msg ("Well, one moment I was sitting there, feeling pretty happy with myself after eating my afternoon snack - a cheeseburger, pizza and ice cream pie, smothered in bacon, which I'd washed down with a bucket of coffee and six cans of Red Bull - when all of a sudden, I was in terrible pain, and then everything was peaceful. Then you came along.")
          }
          else {
            msg ("He is dead, you won't get an answer from him.")
          }
        </item>
      </ask>
    </object>

<function name="revive Bob">
    if (GetBoolean(Bob, "alive")) {
      msg ("Bob is already alive.")
    }
    else {
      msg ("Miraculously, the defibrillator lived up to its promise, and Bob is now alive again. He says his head feels kind of fuzzy.")
      SetObjectFlagOn (Bob, "alive")
    }
  </function>

NinjaNin
16 Jul 2017, 03:49

I didn't know how to do that exactly but it's a good idea. to be honest I just want to figure out how to use the functions.

Edit: So a few hours later reading through the whole tutorial again I realized that I had another flag on the second part of Bob's description and that's what was messing me up. Thank you everyone for your replies though. Now can someone help me on the part of where you can only use the difib in the same room as bob?

Edit 2: Wait never mind thank you so much for the help!


NinjaNin
16 Jul 2017, 04:01

Wait never mind im still confused on how to make it check for where the player is in the room or not. Right now it just gives me two messages. One where it says you cant use the defib on bob, and the message where you revive him. Where do I put in the extra if command if I'm using Functions?

Edit: I put the script in the function I had and put it as an Else If player is not in lounge. Would it work the same way if I said Player is in the lounge or is that the hard way around? Either way I seem to have done it, finally.


hegemonkhan
16 Jul 2017, 06:28

here's an explanation on the built-in 'parent' Object (reference/pointer) Attribute:

http://textadventures.co.uk/forum/samples/topic/edvc3mylr0amfxqz-ac65w/objects-in-libraries#04260348-4da3-41aa-a765-120f654a87c3

if confused, let me know, and I'll try to explain it in hopefully a less confusing way, lol.


you can use this to do some fancy coding, such as a 'following effect' action:

// team_member.parent = room // team member is currently in the 'room' Room Object
// player.parent = room2 // you are currently in the 'room2' Room Object

if (not team_member.parent = player.parent) // if the team member isn't in the same room as you
  team_member.parent = player.parent // set/place/put/move team member into the same room as you
}

// result:
//
// team_member.parent = room 2// team member is currently in the 'room2' Room Object
// player.parent = room2 // you are currently in the 'room2' Room Object

Doctor Agon
16 Jul 2017, 08:05

Hi NinjaNin, personally, I'd put an 'If object is visable' script on Bob in the 'Revive Bob' function, just in case he starts wandering around and has another attack, then it wouldn't matter if he was in the Lounge or Kitchen.


hegemonkhan
16 Jul 2017, 08:23

'calling' (using/doing) the 'Function' Element:

in the GUI/Editor:

run as script -> add new script -> 'scripts' section/category -> 'call function' Script -> (see below)

Call function NAME_OF_THE_FUNCTION_YOU_WANT_TO_USE/DO/CALL With parameter (inputs/arguments to be stored into the Parameter VARIABLE to be used by the Function's scripting): (our Function's scripting doesn't use any inputs, so do NOT 'ADD' in any inputs/arguments'parameters)

in code: literally type in the name of the function, for example:

// blah blah blah required stuff

<game name="example_game">
  // the special 'game.start' Script Attribute is the first thing done when the game begins, making it great for character creation and/or a game introduction:
  <attr name="start" type="script">
    hi_function // this is a use (a 'function call') of the 'hi_function' Function
    hi_function // this is another use of the Function, we can use/call Functions from anywhere that does scripting throughout our entire game code, we can have an npc Object that upon talking to it, uses the 'hi_function' Function. This global/game-wide usage of Functions make them more easy for people to use. Though, when you got really big complex games, than it can be better to use Objects and Script Attributes (and Delegates for them, so they have the same ability as Functions do: Arguments/inputs into Parameters, and being able to return a Value).
  </attr>
</game>

// this is the 'definition' (creation) of the Function, aka setting it up / what it does:

<function name="hi_function">
  msg ("hi")
</function>

// blah blah blah required stuff

simple example of using a Function's ability to return a Value:

<game name="example_game">
  <attr name="start" type="script">
    player.alias = name_function
  </attr>
</game>

<function name="name_function" type="string"> // 'type' means 'return type' in this case (quest has to be told what Data Type the Value returned by the Function is, as it needs to know, as it matters)
  msg ("What is your name?")
  get input {
    // quest automatically (hidden from you) does this: result = YOUR_INPUT
    return (result)
  }
</function>

simple (and very impractical/bad, lol) example of using Arguments/Parameters:

<game name="example_game">
  <attr name="start" type="script">
    msg ("What is your name?")
    get input {
      name_function (result)
      msg (player.alias)
    }
  </attr>
</game>

// what is going on:
// player.alias <==== string_parameter <=== result <==== YOUR_INPUT

<function name="name_function" parameters="string_parameter">
  player.alias = string_parameter
</function>

too lazy to write/code an exmaple, but you can do both (Arguments/Parameters and have a return type) as well with your Functions.


onimike
17 Jul 2017, 12:39

Here is what you do, make def object under features mark use/give. Now goto Use/Give tab and select use this on (other object), select Handle objects individually. Add Bob to the object to handle then under script go to code view and add this

if (Bob.parent = player.parent) {
  if (not GetBoolean(Bob, "alive")) {
    msg ("It seems to have worked Bob is recovering.")
    SetObjectFlagOn (Bob, "alive")
  }
  else {
    msg ("Bob is already alive no sence to use this.")
  }
}
else {
  msg ("You need to be in same room as person you want to use this on.")
}

Forgewright
04 Aug 2017, 15:45

SOLVED

When calling a function, I noticed an error about not recognizing the (this.attribute) I used in the function. Is there a way to carry a specific attribute value over to a general function so it will recognize this.attribute?
Hope that's understandable.


hegemonkhan
04 Aug 2017, 17:18

the special 'this' key-word/key-command GETS the parent Object of the scripting it's used in, hence the error:

example_function (this.attribute)
// example_function (example_function.attribute) // or: example_function (UNKNOWN/NULL.attribute)
// ERROR!

you just can NOT use 'this' for this (bad pun) type of stuff


<game name="example_game">
  <attr name="state_integer_attribute" type="int">1</attr>
  <attr name="start"> type="script">
    example_function_1 (game.state_integer_attribute)
    // output:
    // 1
    // 2
    // 3
    // NO error
  </attr>
</game>

<function name="example_function_1" parameters="game_state_parameter_1">
  msg (game_state_parameter_1)
  game_state_parameter_1 = game_state_parameter_1 + 1
  example_function_2 (game_state_parameter_1)
</function>

<function name="example_function_2" parameters="game_state_parameter_2">
  msg (game_state_parameter_2)
  game_state_parameter_2 = game_state_parameter_2 + 1
  example_function_3 (game_state_parameter_2)
</function>

<function name="example_function_3" parameters="game_state_parameter_3">
  msg (game_state_parameter_3)
</function>

Forgewright
04 Aug 2017, 18:51

*** SOLVED***
Here's the eat verb:

if (this.dead) {
  eat_it4
  destroy (this.name)
  msg (this.deadeatmessage)
}

I'll end up put more into the verb later.

Here's the eat_it4 function:

<function name="eat_it4"><![CDATA[
    s = player.hitpoints + 4
    player.hitpoints = s
    UpdateHitPoints
    if (player.hitpoints > player.maxpoints) {
      player.hitpoints = player.maxpoints
    }
  ]]></function>

It was maxpoints not maxhitpoints. The cdata did work...
Thanks for the info.


Forgewright
04 Aug 2017, 20:22

I'll just make 3 functions that add different int to hitpoints and only have 3 different eatpoints say, 4, 8, 12, for small, medium, large objects.
Name the functions
eat_it4
eat_it8
eat_it12


hegemonkhan
05 Aug 2017, 01:00

you can do this (I think it'll work as the scripting is a Script Attribute, which means it has a parent Object: the 'katana' Object...,but if it gives you an error, let me know, so I'll know it just can't be done with 'this' at all no matter what):

<object name="katana">
  <attr name="damage" type="int">50</attr>
  <attr name="attack" type="script">
    attack_function (this.damage)
  </attr>
</object>

<function name="attack_function" parameter="example_parameter">
  msg ("Weapon Damage: " + example_parameter)
  // output: Weapon Damage: 50
</function>

if you rather, you can learn how Delegates work, letting you use Objects and their Script Attributes, being able to function as Functions: Parameters/Arguments/inputs and/or returning a value (of a specific data type).

I can help you with learning to use delegates, if you're interested, as being able to use Objects (everything can be self-contained within them: they're "local": encapsulation/compartmentalization/organized-structurally) is much more nice than global (messy) Functions.


hegemonkhan
05 Aug 2017, 01:40

try this (altered your code and added in more functionality:made-dynamic --- not fully: more can be done --- let me know if you want it to be even more dynamic, and made-up stuff for seeing as an example of how its used), and see if it works or not (let me know if it doesn't):

<object name="room">
  <inherit name="editor_room" />
</object>

<object name="demon_cow">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="alias" type="string">cow</attr>

  <attr name="dead" type="boolean">false</attr>

  <attr name="deadeatmessage" type="string">You ate the hamburger, MMMmmm, delicious!!!</attr>

  <attr name="my_eat_script_attribute" type="script">
    if (this.dead) {

      msg ("(TESTING) " + game.pov.name + " Hit Points: " + game.pov.hitpoints)
      msg ("(TESTING) " + game.pov.name + " Max Points: " + game.pov.maxpoints)

      my_eat_function (game.pov, 4)

      msg ("(TESTING) " + game.pov.name + " Hit Points: " + game.pov.hitpoints)
      msg ("(TESTING) " + game.pov.name + " Max Points: " + game.pov.maxpoints)

      my_eat_function (game.pov, 8)

      msg ("(TESTING) " + game.pov.name + " Hit Points: " + game.pov.hitpoints)
      msg ("(TESTING) " + game.pov.name + " Max Points: " + game.pov.maxpoints)

      my_eat_function (game.pov, 12)

      msg ("(TESTING) " + game.pov.name + " Hit Points: " + game.pov.hitpoints)
      msg ("(TESTING) " + game.pov.name + " Max Points: " + game.pov.maxpoints)

      msg (this.deadeatmessage) // this has to be done BEFORE you destroy the Object !!!!
      destroy (this.name) // also, you might just want to remove it (sets its parent to 'null': directly a child of the 'asl' GAME OBJECT: NOT contained within another 'Object' Element) instead (as if this Object is ever referenced/used elsewhere in your code, you'll get an ERROR, as it's destroyed and thus doesn't exist, which quest is looking for, and thus can't find, and thus the ERROR): http://docs.textadventures.co.uk/quest/functions/corelibrary/removeobject.html : RemoveObject (this.name)
    } else {
      msg ("Sorry, but the demon cow is not going to let you eat it, long as it lives...")
    }
  </attr>

</object>

<object name="player_1">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <attr name="parent" type="object">room</attr>

  <attr name="hitpoints" type="int">500</attr>
  <attr name="maxpoints" type="int">999</attr>

</object>

<object name="player_2">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <attr name="parent" type="object">room</attr>

  <attr name="hitpoints" type="int">300</attr>
  <attr name="maxpoints" type="int">699</attr>

</object>

<function name="my_eat_function" parameters="player_object_parameter_1, modifier_integer_parameter">
  player_object_parameter_1.hitpoints = player_object_parameter_1.hitpoints + modifier_integer_parameter
  UpdateHitPoints (player_object_parameter_1)
</function>

<function name="updateHitPoints" parameters="player_object_parameter_2">
  <![CDATA[
    if (player_object_parameter_2.hitpoints > player_object_parameter_2.maxpoints) {
      player_object_parameter_2.hitpoints = player_object_parameter_2.maxpoints
    }
  ]]>
</function>

<verb>
  <property>my_eat_script_attribute</property>
  <pattern>my_eat_script_attribute</pattern>
  <defaultexpression>You can't eat that!</defaultexpression>
</verb>

also, note that there's the special 'changedNAME_OF_ATTRIBUTE' Script Attribute (which IMMEDIATELY ACTS upon the specified Attribute's Value being changed, which can be good or bad... it can mess up your "order of operations", depending on your various coding designs/systems):

<object name="room">
  <inherit name="editor_room" />
</object>

<object name="demon_cow">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="alias" type="string">cow</attr>

  <attr name="dead" type="boolean">false</attr>

  <attr name="deadeatmessage" type="string">You ate the hamburger, MMMmmm, delicious!!!</attr> // this would be an example, of why/when you wouldn't want to use the special 'changed' Script attribute, as you likely have other stuff you want to do first, and thus not want to see the "You ate the hamburger, MMMmmm, delicious!!!" in the middle of those other things you're doing/displaying, lol

  <attr name="my_eat_script_attribute" type="script">
    if (this.dead) {

      msg ("(TESTING) " + game.pov.name + " Hit Points: " + game.pov.hitpoints)
      msg ("(TESTING) " + game.pov.name + " Max Points: " + game.pov.maxpoints)

      my_eat_function (game.pov, 4)

      msg ("(TESTING) " + game.pov.name + " Hit Points: " + game.pov.hitpoints)
      msg ("(TESTING) " + game.pov.name + " Max Points: " + game.pov.maxpoints)

      my_eat_function (game.pov, 8)

      msg ("(TESTING) " + game.pov.name + " Hit Points: " + game.pov.hitpoints)
      msg ("(TESTING) " + game.pov.name + " Max Points: " + game.pov.maxpoints)

      my_eat_function (game.pov, 12)

      msg ("(TESTING) " + game.pov.name + " Hit Points: " + game.pov.hitpoints)
      msg ("(TESTING) " + game.pov.name + " Max Points: " + game.pov.maxpoints)

      msg (this.deadeatmessage) // this has to be done BEFORE you destroy the Object !!!!!
      destroy (this.name) // also, you might just want to remove it (sets its parent to 'null': directly a child of the 'asl' GAME OBJECT: NOT contained within another 'Object' Element) instead (as if this Object is ever referenced/used elsewhere in your code, you'll get an ERROR, as it's destroyed and thus doesn't exist, which quest is looking for, and thus can't find, and thus the ERROR): http://docs.textadventures.co.uk/quest/functions/corelibrary/removeobject.html : RemoveObject (this.name)
    } else {
      msg ("Sorry, but the demon cow is not going to let you eat it, long as it lives...")
    }
  </attr>

</object>

<object name="player_1">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <attr name="parent" type="object">room</attr>

  <attr name="maxpoints" type="int">500</attr>

  <attr name="hitpoints" type="int">999</attr>

  <attr name="changedhitpoints" type="script">
    <![CDATA[
      if (this.hitpoints > this.maxpoints) {
       this.hitpoints = this.maxpoints
      }
    ]]>
  </attr>

</object>

<object name="player_2">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <attr name="parent" type="object">room</attr>

  <attr name="maxpoints" type="int">300</attr>

  <attr name="hitpoints" type="int">699</attr>

  <attr name="changedhitpoints" type="script">
    <![CDATA[
      if (this.hitpoints > this.maxpoints) {
       this.hitpoints = this.maxpoints
      }
    ]]>
  </attr>

</object>

<function name="my_eat_function" parameters="player_object_parameter, modifier_integer_parameter">
  player_object_parameter.hitpoints = player_object_parameter.hitpoints + modifier_integer_parameter
</function>

<verb>
  <property>my_eat_script_attribute</property>
  <pattern>my_eat_script_attribute</pattern>
  <defaultexpression>You can't eat that!</defaultexpression>
</verb>

Forgewright
05 Aug 2017, 07:19

Tested the first one. each test says it only expects one parameter in the updatehitpoints function called in the my_eat_function. I deleted the player parameter and it works! All the tests were successful and kept the hitpoints from going over maxpoints. Just home for lunch hour so no time for second one yet. Thanks. Nice work


hegemonkhan
05 Aug 2017, 13:46

hmm.. it (the logic of it anyways --- as my code likely has more mistakes/typos/etc I'm not finding/seeing/noticing) should work (unless you got some of your code set up a bit differently:

the logic/process of what's going on:

my_eat_function (game.pov, 4)

the 'Argument (input)' of 'game.pov' (this is who-ever is your currently controlled Player Object, the default is the 'player' Player object: game.pov = player) is passed/stored into the 'player_object_attribute_1' Parameter VARIABLE, which is then used by the 'my_eat_function' Function's scripting

same for the '4 Literal Value, Integer Data Type/Value' Argument (input), which is passed/stored into the 'modifier_integer_parameter' Parameter VARIABLE, which is then used by the 'my_eat_function' Function's scripting

within the 'my_eat_function' Function's scripting is the 'function call' to the 'updateHitPoints' Function

err.... just spotting a mistake/typo in my code:

updateHitPoints vs UpdateHitPoints

whoops, stupid case-typo, this is why I hate using caps, lol: all lower case and using the underscore to separate words. I don't like the camel case convention/standard/system, lol. I always have to be careful when I say/type tha,. as when I'm not, I always say or type: camel toe. programmers should know what I meant: camel case.... but whatever, it's still funny..., NOT MY FAULT they're similar, LOLOLOL, heh. At least, I never accidentally said that to my professor... though probably get a laugh out of him/her too, I'm sure it's a common mistake, I'm sure I'm not the first to say/type camel toe instead of camel case

anyways, just back to the logic/process:

within the 'my_eat_function' Function's scripting is the 'function call' to the 'updateHitPoints' Function

UpdateHitPoints (player_object_parameter_1)

so this Argument(input) is taking the Parameter Variable from 'my_eat_function' Function (which remember is: player_object_parameter_1 = game.pov = player)

and is passing/storing it into the 'player_object_parameter_2' Parameter VARIABLE, which is used by the 'UpdateHotPoints' Function's scripting

so, it's like this:

game.pov = player

player_object_parameter_1 = game.pov = player
modifier_integer_prameter = 4

player_object_parameter_2 = player_object_parameter_1 = game.pov = player

(ignoring any arithmetic operations or direct setting/re-setting/assignment operations, causing change to the value of it of course):
player.hitpoints = game.pov.hitpoints = player_object_parameter_1.hitpoints = player_object_parameter_2.hitpoints


though, I'm sure my code has a bunch of other mistakes that I'm not seeing/finding/noticing... meh...

also might have something to do with the 'game.pov', as you might need to set that up correctly if you're using the GUI/editor... it's a bit funky/confusing... lol

or maybe I need to have the 'xxx.name' String Attribute onto it... I easily get confused whether I use the Object reference/pointer directly or its 'name' String Attribute:

<object name="ball"></object>

// scripting:

my_function (ball)

vs:

my_function (ball.name)

Forgewright
05 Aug 2017, 15:35

Was excited at lunch to see the scripts you provided and set them into a game using my libraries (quite on the fly). I quickly made some attribute changes and everything appeared to work. After some rest, I will go over it again step by step and see if I had changed anything I shouldn't . Once I have followed the programing and debugging I'll show what I have.

I was curious as to why you made player 1 and player 2. Then referenced player 1 in the my_eat_function and player 2 in the UpdateHitPoints function. Was that for testing?


hegemonkhan
05 Aug 2017, 23:29

(filler for getting editing post updated/posted)


just to demonstrate that Parameters are VARIABLES, which you pass/store the Argument (input as a VARIABLE or Literal Value), which is then used by the Function's scripting, making it dynamic, it'll work for any Object passed into it as an Argument, though my example was of using Player Objects (player_1 and player_2) so that's what I named the Parameter as 'player_object_parameter_1' (as I like to be descriptive in my names, lol) as to stay consistent (and also the Object would have to have the Attribute used in the example as well). The number at the end of it, is just to show you how one Function's Parameter VARIABLE can be used by another Function's Parameter, but you can name the Parameters watever you want, they can be the same name or different name, pros and cons to both naming schemes.

The number has NOTHING to do with player_1 and player_2, but rather:

player_object_parameter_1: is the parameter for the 'eat_function' Function
player_object_parameter_2: is the parameter for the 'update hitpoints' Function
// just so you can see how they're working (but I never explained any of this in my previous post, lol. I assumed you were telepathic... you disapoint me! joking around here, hehe)

using Parameters (VARIABLES) means that it's "dynamic/universal" (it'll use ANY VARIABLE/VALUE), so one dynamic/universal Function can be used for many different things and it'll still work.

Just like how Commands are dynamic/universal (they can be used for any input) whereas Verbs are static: specific to only work for its parent Object's Script Attributes, the 'talk' Verb for npc1 is not the same as the 'talk' Verb for npc2, each have their own scripting, totally separate from each other.

Parameter VARIABLES are basically a way of "transfering" data to a Function/Command and optionally to other Functions/Commands):

<game name="example">
  <attr name="count" type="int">1</attr>
  <attr name="start" type="script">
    count_function (this.count)
  </attr>
</game>

// game.count = 1

// the 'count_parameters' are 4 SEPARATE/DIFFERENT 'count_parameters' as they're local-scoped to their parent Function, but they're used to give/determine the Value for the next Function's 'count_parameter'

// count_parameter = game.count

// count_parameter = 1

<function name="count_function" parameters="count_parameter">
  msg (count_parameter)
  count_parameter = count_parameter + 1
  count_function_2 (count_parameter)
</function>

// count_parameter = (1) + 1 = 2

<function name="count_function_2" parameters="count_parameter">
  msg (count_parameter)
  count_parameter = count_parameter + 1
  count_function_3 (count_parameter)
</function>

// count_parameter = (2) + 1 = 3

<function name="count_function_3" parameters="count_parameter">
  msg (count_parameter)
  count_parameter = count_parameter + 1
  count_function_4 (count_parameter)
</function>

// count_parameter = (3) + 1 = 4 = game.count

// the Value of the 'cp' (count_paramter -- geting lazy lol) for F1 is: 1
// the Value of the 'cp' for F2 is: 2
// the Value of the 'cp' for F3 is: 3
// the Value of the 'cp' for F4 is: 4
// also, each of these don't exist outside (out of scope) their parent Function: the 'call function' is still within its parent function, and so the cp is being used within its parent function, being set to be pointed to by the next function's cp:
// the arrows represent the value being "transfered" (stored/assigned)
// whereas the 'points to' is saying that the left cp is pointing to the right cp
// F4's cp (4) <---  points to <--- F3's cp (3+1=4) <---  points to <--- F2's cp (2+1=3) <---  points to <--- F1's cp (1+1=2) <---  points to <--- game.count <--- 1
// does this help explain what's going on? or did I make it more confusing?

<function name="count_function_4" parameters="count_parameter">
  msg (count_parameter)
  msg (game.count) // the 'count_parameter' is storing the 'game.count', so they'll both be storing the same value of: 4
</function>

Forgewright
06 Aug 2017, 06:49

I'll have to chew on this one awhile...