dcsext.setters
A common library of setter functions which can be used in the set function for class properties.
Contents
Functions
t.setBoolean(, _, new)
Force the new value to be a boolean. Intended as the set hook of a dcsext.class managed property, called back with (self, key, newvalue, oldvalue), unused hook arguments are ignored.
Parameters
- _
- unused property key hook argument
- _
- unused property key hook argument
- new
- value assigned to the property
Returns
- the boolean interpretation of new
t.setNumber(, _, new, old)
Force the new value to be a number, if new cannot be converted to a number return the old value. Intended as the set hook of a dcsext.class managed property, called back with (self, key, newvalue, oldvalue), unused hook arguments are ignored.
Parameters
- _
- unused property key hook argument
- _
- unused property key hook argument
- new
- value assigned to the property
- old
- previous value, returned when new is not convertible
Returns
- new as a number or old when new is not convertible
t.setString(, _, new, old)
Force the new value to be a string, if new cannot be converted to a string return the old value. Intended as the set hook of a dcsext.class managed property, called back with (self, key, newvalue, oldvalue), unused hook arguments are ignored.
Parameters
- _
- unused property key hook argument
- _
- unused property key hook argument
- new
- value assigned to the property
- old
- previous value, returned when new is not convertible
Returns
- new as a string or old when new is not convertible
_t.setValFromTable(tbl, _, _, new, old)
Check that new exists as a value in tbl. If new doesn’t exist return old otherwise return new. Intended as the set hook of a dcsext.class managed property, tbl holds the valid values and the remaining arguments are the property hook callback arguments (self, key, newvalue, oldvalue).
Parameters
- tbl
- table of valid values checked against
- _
- unused property key hook argument
- _
- unused property key hook argument
- new
- value assigned to the property
- old
- previous value, returned when new is not found in tbl
Returns
- new when found in tbl otherwise old