User Tools

Site Tools


Setval works similar to qsets, but allows for much more readable values. You can view a list of values on a player using the “qlist” command as well.


setval(“<arg1>”, <arg2>, <arg3>)

The first argument is a string/name of the value. The second argument is a boolean, string, or numerical value that you want to use to track the value The third argument is whether or not the value will persist through logout.


if mob.vnum == 320 then
    ch:setval("r9_serpent_killed", 1, true)

If this mprog was attached to a mob using a DEATH trigger, when the mob was killed (assuming it was a mob with vnum 320), then a value would be applied to the player. The value would be called serpent killed, with a value of 1, and it would persist through logout.


ch:setval("r9_serpent_killed", nil)

This mprog could be attached to just about anything, with any trigger. It would erase the value on serpent_killed, expunging it from the players' pfile.


if (ch:getval("r9_zombies_killed") or 0)>= 1 and ch:getval("r9_zombies_killed") <8 then
    if mob.vnum == 325 then
        ch:setval("r9_zombies_killed", ch:getval("r9_zombies_killed") + 1, true)

This mprog will check if the value of r9_zombies_killed has been set. If not, it will set it to 1. If it has been set, the value will be incremented by 1. This will only fire when mob 325 (dirty zombie) has been killed.

Best practices: It's important to cleanup these values when they're no longer needed during a quest, so that pfiles stay clean, and players aren't wandering around with many values, set unnecessarily.

Additionally, you should use a prefix on your values that is related to your area name, so that other builders don't end up with similarly named values. The above examples use “r9” as a prefix, denoting that they are tied to remort 9.

See also getval

lua/setval.txt · Last modified: 2015/09/02 21:40 by vodur