SET variables

The KSirc Handbook
Prev | Chapter 5. Programming Your Sirc Client | Next

# 5.3. SET variables

A script can access SET variables:

- to read them, you just need to look at `$set{"VARIABLE"}`, where the variable name is written in caps

- to set them, call `&doset("variable", "value");` the variable name can be in either case (case is not significant) and the value is checked

A script can also add its own SET variables, providing a default value and a hook to check and set a new value. To do this, the script must:

- set the variable to a default value, with `$set{"VAR"}="whatever";` sirc will not let the user `/set` a variable if a value for it in `%set` does not exist

- define a sub called `set_somename`, and call `&addset("var", "somename");` the variable name can be passed in either case.

The subs that serve as hooks for SET variables get called with the proposed value as the first argument. They may (or not) change the actual value in `$set{"VAR"}`, to the value given or to another one. By convention, they should not `&tell` anything, and should ignore invalid values.

What goes in `$set{"VAR"}` must still be human-readable; for things like toggles, it is suggested that the values in `$set{"VAR"}` should be "on", "off" or similar, and that `&doset` can set a variable (internal to the script) to 0 or 1, which will be the one actually checked by the script.

Prev | Home | Next
Hooks | Up | Userhost requests