Can't get battle attributes right

jmnevil54

I use the online web version.
I can't get these attributes right. I've tried making it specific to the object. I've tried typing it as "player.something," but the game mistakes it as an object.
Images
http://imgur.com/yDNiWgS
http://imgur.com/pjEl9LG
http://imgur.com/OL431MP
http://imgur.com/jX4ePxZ


The Pixie

That is not how verbs are designed to be used (they are a short hand for commands), however, it is certainly one way to add scripts to an object in the web version. Be aware that any player typing the name of a verb, followed by the object name will trigger the script.

As to your question, it looks like "health 3" is done right. You need to use "Set variable", and the variable you set must be typed in as the name of the object, followed by a dot, followed by the attribute name ("Chikorita1.csethealth").

Alternatively you can set the object attribute as you are almost doing in attack 5, however, the object needs to be "Chikorita1", not "damage". I do not use the graphic interface; I am not sure if the attribute name needs quotes or not.

Looking at "attack 3", you are setting "damage", a local variable not attached to any object, which is lost when the script ends.

By the way, I suggest checking if health is zero or less to see if the player or monster is dead.

You might find this useful too:
https://github.com/ThePix/quest/wiki/The-Zombie-Apocalypse-(on-the-web-version)


hegemonkhan

here's a guide on Attributes and the 'if' Script usage:

https://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

or if the above doesn't work, then try this:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

and if you want to take a look at some combat code (although it is old and is very bad/poor code and has some mistakes in it as well, as this was when I was learning to code for my first time, laughs):

https://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread#22483
https://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread#22486 (key/legend: I've learned to never ever do abrevs ever again, lol)

or if the above doesn't work, then try this:

http://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread#22483
http://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread#22486 (key/legend: I've learned to never ever do abrevs ever again, lol)


jmnevil54

@The Pixie, maybe others
Thanks.
I don't know what you mean by the verbs comment. I was just told that the only way to do attributes in the web version was through verbs. Correct me if I'm wrong.
I don't know how to type "zero or less" in script.


DarkLizerd

<
if (player.health<1) {
msg("Sorry, but you just died...")
finish
// or your end game sequence...
}


hegemonkhan

for the 'set a variable or attribute' Script, it puts in the assignment (=) operator/operation for you:

(the Assignment operator/operation is different from the 'equal' conditional operator/operation, even though quest uses the same symbol for user friendliness)

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION

and since 'if' uses conditionals, it has the '[EXPRESSION]' script option for the 'if' Script, letting you put in the needed conditional operators:

if [EXPRESSION] NAME_OF_OBJECT.NAME_OF_ATTRIBUTE  CONDITIONAL_OPERATOR VALUE_OR_EXPRESSION

---------

CONDITIONAL_OPERATORS:

equals: =
not equals A: <>
not equals B: not NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR _EXPRESSION
greater than: >
lesser than: <
greater than or equal to: >= // (try to remember that the '=' is on the right side)
lesser than or equal to: <= // (try to remember that the '=' is on the right side)

if you're doing this directly in code (non-GUI/Editor usage), than you need to encase your scripting in the 'CDATA' tag:

the 'CDATA' tag tells quest that the '<' and '>' symbols within the 'CDATA' tag are to be seen as conditional operators and not as code tags, else you'll get errors as your code isn't read/parsed correctly by quest, with it thinking your code syntax is wrong

<object name="NAME_OF_OBJECT">
  <attr name="NAME_OF_SCRIPT_ATTRIBUTE/NAME_OF_VERB" type="script">
    <![CDATA[
      // scripting
      // example:
      // if (player.life <= 0) {
      //   msg ("You were killed or you've died.")
      //   msg ("GAME OVER")
      //   finish
      // }
    ]]>
  </attr>
</object>

The Pixie

The point of verbs is to make it easy to do commands like ATTACK GOBLIN. On the goblin object, you create an "attack" verb, and in the background Quest creates a verb object called "attack" (which you cannot see if the web version) and also adds a script called "attack".

If you add a "health 3" verb to a goblin, then the goblin will have a script called "health 3" (or maybe "health3"), which is what you want. But Quest will have also created that verb object, so the player can type HEALTH 3 GOBLIN, and that will make the script run when you probably do not want it to.


Log in to post a reply.

Support

Forums