Reference 〉 Function

Helipad.param(paramstr|tuple, valstr|bool|num|list[str]None)

Sets or gets a parameter. Note the parameter must have been previously registered with Params.add().

Parameters

  • param str|tuple, required

    A parameter identification string or tuple. A string value indicates a global parameter or a dict of values for per-item parameters. Individual settings of per-breed or per-good parameters can be indicated with a two-item tuple, ('paramName', 'goodName') or ('paramName', 'breedName').

    If only this argument is set, the function returns the value of the named parameter.

  • val str|bool|num|list[str], optional

    If this argument is set, the function sets the value of the parameter to val. The data type must be appropriate to the parameter type: a slider takes a number, a menu takes a string, a checkbox takes a bool, a checkentry takes a bool, a string, or an int, depending on the type, and a checkgrid takes a list of strings.

    Note that per-item parameters can only be set on an individual basis; i.e. the val argument will only be accepted for per-item parameters if the item is specified in the param argument with a tuple.

    Default value: None

Return Value str|bool|num|dict|None

If val is not set, returns the parameter value: a string if the parameter is a menu, a boolean if a checkbox, a number if a slider, a bool, int, or string if a checkentry, or a list of strings if a checkgrid. If a two-item tuple is passed for param without specifying an item, the function returns a dict with parameter values for all relevant items. If val is set, the function sets the parameter to val and does not return a value.

Notes and Examples

  1. charwick

    Mar 24, 2020 at 3:33

    This example doubles the value of the 'agentSpeed' parameter.

    currentSpeed = model.param('agentSpeed') #Getting the value (1 argument)
    model.param('agentSpeed', 2 * currentSpeed) #Setting the value (2 arguments)
  2. charwick

    Jun 25, 2020 at 19:47

    A few examples to show the uses of the parameter identification pattern.

    a = model.param('pSmooth') #Gets the value of the global pSmooth parameter
    b = model.param('rbd') #Gets the value of the  rbd breed parameter and returns a dict of values for all breeds
    model.param(('rbd','hobbit'), 50) #Sets the value of the rbd breed parameter for the hobbit breed to 50
  3. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.

History