Reference 〉Function

Shocks.register( str name, str|tuple param, func valFunc, func(int)|str timerFunc, bool active = True, str desc = None )

Registers a shock to a parameter value. Associated with a value function, which shocks the variable, and a timer function, which determines when and how often to execute the value function.


  • name str, required

    A unique name for the shock, to be displayed in the GUI beside its checkbox.

  • param str|tuple, required

    A parameter identification string or tuple. A string value indicates a global parameter. Per-good parameters can be indicated with a three-item tuple, ('paramName', 'good', 'goodName'). A per-breed parameter can be indicated with a three- or four-item tuple, ('paramName', 'breed', 'breedName', 'primitive'), with the last element optional if there is only one primitive. param can also be set to None, in which case valFunc behaves somewhat differently. See below.

  • valFunc func, required

    A function that returns a new value for the parameter. valFunc takes three arguments: the name of the variable being shocked, the parameter type (None for global parameters, 'breed' or 'good' for per-breed and per-good parameters, respectively), and (for per-breed or per-good parameters) the breed or the good in question. If var is None, however, valFunc takes one argument, the model object. This can be useful for more complex shocks that do not correspond to a particular parameter.

  • timerFunc func(int)|str, required

    A function that takes the current model time and returns a bool, indicating whether to run valFunc that period or not. timerFunc can also be set to the string 'button', in which case a button will be drawn in the control panel that runs valFunc when the button is pressed.

  • active bool, optional

    Whether the shock is active by default when the control panel launches. This can be toggled on and off in the control panel later.

    Default value: True

  • desc str, optional

    A long description to display as a tooltip. Note that tooltips require PMW when using the Tkinter frontend.

    Default value: None

Fatal error: Uncaught TypeError: Unsupported operand types: string - string in /home/dh_nzhxm7/ Stack trace: #0 [internal function]: {closure}(Object(WP_Comment), Object(WP_Comment)) #1 /home/dh_nzhxm7/ usort(Array, Object(Closure)) #2 /home/dh_nzhxm7/ {closure}(Array) #3 /home/dh_nzhxm7/ WP_Hook->apply_filters(Array, Array) #4 /home/dh_nzhxm7/ apply_filters('comments_array', Array, 130) #5 /home/dh_nzhxm7/ comments_template() #6 /home/dh_nzhxm7/ include('/home/dh_nzhxm7...') #7 /home/dh_nzhxm7/ require_once('/home/dh_nzhxm7...') #8 /home/dh_nzhxm7/ require('/home/dh_nzhxm7...') #9 {main} thrown in /home/dh_nzhxm7/ on line 200