Tip: how to allow your player to attribute stats without inputs

Kln

I experimented with this method out of curiosity and, while not optimal, it works.
In the same vein as using the rooms as menus, you can use commands to make your player distribute stats.

Prerequisites
A variable that will be used as a point pool. For instance: var statPool = 3
Modify this variable whenever you want to give your player points to allocate.

A function that will do the allocation. Here, the variables are stored in the player object.

function editStat(statName, isIncrease=true) {
  if (!statName){
     errormsg("Stat unknown:" + statNane);
     return world.FAILED;
  }

  if (isIncrease) {
    if (statPool == 0) {
      errormsg("You do not have any points to allocate");
      return world.FAILED;
    } else {
      game.player[statName] ++;
      statPool --;
    }
  } else {
    if (game.player[statName] == 1) {
      errormsg("You cannot decrease " + statName + " further";
      return world.FAILED;
    } else {
      game.player[statName] --;
      statPool ++;
    }
    game.player.statName --;
  }

  return world.SUCCESS;
}

Note that you can add other conditions, such as the player needing to be in a specific room.

Increase command

  new Cmd('Increase', {
    regex:/^(increase) (.+)$/,
    objects:[
      {ignore:true},
      {text:true}
    ],
   script: function(objects) {
     return editStat(objects[0][0]);
   }
  }),

Decrease command

  new Cmd('Decrease', {
    regex:/^(decrease) (.+)$/,
    objects:[
      {ignore:true},
      {text:true}
    ],
   script: function(objects) {
     return editStat(objects[0][0], false);
   }
  }),

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

Support

Forums