SOLVED - Adding Status Attributes

Hi everyone, first time poster here. I've done some searching on how to add a status attribute and I found that you go to Attribute tab in Player and then add an Integer with the new status attribute's name. In this case it's Shooter and I put in an integer value of 0 as I wanted it to start out as 0. No problems, that worked. Now I want to make a command where people can type Add Shooter at any point (like a command) and have it go up by 1. I went to Commands, called it Add Shooter, and then made a Script on the Command tab that says

Set variable player.shooter = [EXPRESSION] player.shooter + 1

Unfortunately, the game says it doesn't recognise that command so I'm clearly doing it wrong. Could someone please help me? Please note I'm brand new to coding. I've managed to get locked doors and exits and other basics figured out, but I'll need some direction in terms of tabs, etc. rather than getting sections of raw code.

Thanks in advance!

In the GUI/Editor:

"tree of stuff (left side)": 'Objects' -> 'game' -> 'Commands' -> Add -> (see below, for an example)

Command Name: increase_attribute_command

Command Pattern: increase #text#

Command Script: (see below)

add new script -> 'scripts' section/category -> 'if' Script -> (see below)

if [expression] HasAttribute (player, text)

-> then, -> add new script -> 'variables / ???' section/category -> 'set a variable or attribute / ???' Script -> (see below)

// I don't think this will work, but you can try it:

set variable player.text = [expression] player.text + 1

// otherwise, maybe you can use the 'increase counter' script option ('variables' section/category -> 'increase object counter' Script option), which I think looks something like this, along with my example's setup for it:

object counter: [object] player [counter name] text

// but this too may fail... meh....

// this will definitely work, but I don't know how it's done in the GUI-Editor (as I don't/am-unable-to have quest open at the moment) (maybe you can find/figure it out, in how its done with the script options), but here's what it' looks like in code (using my example):

set (player, text, GetAttribute (player, text) + 1)

// or as separated scripts:

incremented_value_variable = GetAttribute (player, text) + 1
set (player, text, incremented_value_variable)

// or (same as above, just very slightly/minorly different):

value_variable = GetAttribute (player, text)
set (player, text, value_variable + 1)

this is a dynamic Command, letting you type in anything, and it checks if you've got such an attribute, and if you do, that attribute is increased by 1, so with my example you'd type in:

increase shooter

and pretending you had a 'strength' Integer Attribute as well, you could enter this as well:

increase strength

etc etc etc for any Integer Attribute that you've got/added to your 'player' Player Object

in code, here's what my Command looks like:

<command name="increase_attribute_command">

  <pattern>increase #text#</pattern>

    if (HasAttribute (player, text)) {
      set (player, text, GetAttribute (player, text) + 1)


if you don't want it to be dynamic, then just change the 'pattern' to NOT having the '#text#' in it and adjust the scripting, for an example (in code):

// you'd just type in: incr
// to activate this 'increase_shooter_command' Command

<command name="increase_shooter_command">


    player.shooter = player.shooter + 1


Hi Laraqua,
Your scripting for the command is fine, it works, your problem is that you've not set up the command correctly.
You need to fill in the box immediately below 'Command pattern/Regular expression' with what you want the player to type to execute the command, otherwise the command will not work and return the prompt 'I don't understand'.
^(push|pull|move) (?<object1>.*)$
make bow;construct bow
^cheat (?<text1>move|set|get) (?<text2>.+)$
or add shooter
Underneath that then is the 'Name' box, this then is the name of the command, it is not essential, but can look a lot better in the 'game tree' than a lot of ^(?
push object
make bow
or add shooter
Hope this helps you.

Hey again, okay I've tried the various script elements and it still not working.

When I went with the simple player.shooter = EXPRESSION player.shooter + 1 it threw up the following error:

Error running script: Error compiling expression 'player.shooter + 1': ArithmeticElement: Operation 'Add' is not defined for types 'Object' and 'Int32'

I get the same Error for: set (player, text, GetAttribute (player, text) + 1)

Select the location where your add script is and make sure it reads this way...
player.shooter = player.shooter + 1

Also, make sure player.shooter exists as an integer attribute before the script runs.

It might help if I show you guys the coding. So here's the code that sits under player:

        <value>Look at</value>
        <value>Add Shooter</value>
        <value>Remove Shooter</value>
      <statusattributes type="stringdictionary">
      <Shield type="int">0</Shield>
      <Stabber type="int">0</Stabber>
      <Shooter type="int">0</Shooter>````

**And this is the code that sits as a new Command:**

````  <command name="increase_shooter_command">
    <pattern>increase shooter</pattern>
    <scope type="string"></scope>
    <shooter type="simplepattern"></shooter>
      player.shooter = player.shooter + 1

<Shooter type="int">0</Shooter>

Quest is case-sensitive, so you need to do player.Shooter = player.Shooter + 1.

It worked! Thank you K.V!

Log in to post a reply.