mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-28 12:17:04 -05:00
Updated Scripting (markdown)
82
Scripting.md
82
Scripting.md
@@ -54,7 +54,7 @@ def get_condition_defaults():
|
||||
# This function will be used by the advanced scene switcher to determine if a condition evaluates to true or false.
|
||||
# The settings for each instance of this condition type will be passed via the data parameter.
|
||||
###############################################################################
|
||||
def my_python_condition(data):
|
||||
def my_python_condition(data, instance_id):
|
||||
target = obs.obs_data_get_double(data, "probability")
|
||||
value = random.uniform(0, 100)
|
||||
return value <= target
|
||||
@@ -86,7 +86,7 @@ def script_unload():
|
||||
```
|
||||
|
||||
|
||||
The `Advanced Scene Switcher helper functions` boilerplate code mentioned above can be found here for [Python](https://github.com/WarmUpTill/SceneSwitcher/blob/master/scripting/examples.py#L115-L305) and [Lua](https://github.com/WarmUpTill/SceneSwitcher/blob/master/scripting/examples.lua#L111-L283).
|
||||
The `Advanced Scene Switcher helper functions` boilerplate code mentioned above can be found here for [Python](https://github.com/WarmUpTill/SceneSwitcher/blob/a51b7f6b13be1c65f5f8057ce9a83f8422a78e3b/scripting/examples.py#L162-L428) and [Lua](https://github.com/WarmUpTill/SceneSwitcher/blob/a51b7f6b13be1c65f5f8057ce9a83f8422a78e3b/scripting/examples.py#L162-L428).
|
||||
Usually you can just copy it directly into your script without any modifications.
|
||||
|
||||
## Discord chat bot action
|
||||
@@ -174,7 +174,7 @@ def restart_bot():
|
||||
###############################################################################
|
||||
|
||||
|
||||
def run_action(data):
|
||||
def run_action(data, instance_id):
|
||||
message = obs.obs_data_get_string(data, "message")
|
||||
channel_id_string = obs.obs_data_get_string(data, "channel_id")
|
||||
try:
|
||||
@@ -331,7 +331,7 @@ def restart_server():
|
||||
###############################################################################
|
||||
|
||||
|
||||
def check_condition(data):
|
||||
def check_condition(data, instance_id):
|
||||
global received_messages
|
||||
expected_message = obs.obs_data_get_string(data, "value")
|
||||
return_value = False
|
||||
@@ -438,6 +438,9 @@ The advanced scene switcher offers the following [procedure handlers](https://do
|
||||
* `bool advss_deregister_script_condition(in string name)`
|
||||
* `bool advss_get_variable_value(in string name, out string value)`
|
||||
* `bool advss_set_variable_value(in string name, in string value)`
|
||||
* `bool advss_register_temp_var(in string temp_var_id, in string temp_var_name, in string temp_var_help, in int instance_id)`
|
||||
* `bool advss_deregister_temp_vars(in int instance_id)`
|
||||
* `bool advss_set_temp_var_value(in string temp_var_id, in string value, in int instance_id)`
|
||||
|
||||
## advss_register_script_action
|
||||
|
||||
@@ -802,4 +805,73 @@ def advss_set_variable_value(name, value):
|
||||
|
||||
obs.calldata_destroy(data)
|
||||
return success
|
||||
```
|
||||
```
|
||||
|
||||
## advss_register_temp_var
|
||||
|
||||
Registers a macro property associated with a given action or condition instance.
|
||||
|
||||
### temp_var_id
|
||||
|
||||
The `temp_var_id` field of calldata object associated with this procedure should specify the unique id of the macro property you want to register.
|
||||
|
||||
### temp_var_name
|
||||
|
||||
The `temp_var_name` field of calldata object associated with this procedure should specify the user facing name of the macro property you want to register.
|
||||
|
||||
### temp_var_help
|
||||
|
||||
The `temp_var_help` field of calldata object associated with this procedure should specify the user facing help message of the macro property you want to register.
|
||||
This value can be an empty string.
|
||||
|
||||
### value
|
||||
|
||||
The `value` field of calldata object associated with this procedure should specify the value you want to set for the specified macro property.
|
||||
|
||||
### instance_id
|
||||
|
||||
The `instance_id` field of calldata object associated with this procedure should specify the unique id of the macro segment for which the macro property value shall be set.
|
||||
The `instance_id` is passed as an argument to the signal with a given `trigger_signal_name` name.
|
||||
See `advss_register_script_action` for more details.
|
||||
|
||||
### Return value
|
||||
|
||||
The return value can be queried via `success` from the calldata object associated with this procedure.
|
||||
Returns `true`, if the operation was successful, and `false` otherwise.
|
||||
## advss_deregister_temp_vars
|
||||
|
||||
Deregister all macro properties associated with a given action or condition instance.
|
||||
|
||||
### instance_id
|
||||
|
||||
The `instance_id` field of calldata object associated with this procedure should specify the unique id of the macro segment for which all macro properties should be deregistered.
|
||||
The `instance_id` is passed as an argument to the signal with a given `trigger_signal_name` name.
|
||||
See `advss_register_script_action` for more details.
|
||||
|
||||
### Return value
|
||||
|
||||
The return value can be queried via `success` from the calldata object associated with this procedure.
|
||||
Returns `true`, if the operation was successful, and `false` otherwise.
|
||||
|
||||
## advss_set_temp_var_value
|
||||
|
||||
Set the value of a macro property associated with a given action or condition instance.
|
||||
|
||||
### temp_var_id
|
||||
|
||||
The `temp_var_id` field of calldata object associated with this procedure should specify the unique id of the macro property you want to modify.
|
||||
|
||||
### value
|
||||
|
||||
The `value` field of calldata object associated with this procedure should specify the value you want to set for the specified macro property.
|
||||
|
||||
### instance_id
|
||||
|
||||
The `instance_id` field of calldata object associated with this procedure should specify the unique id of the macro segment for which the macro property value shall be set.
|
||||
The `instance_id` is passed as an argument to the signal with a given `trigger_signal_name` name.
|
||||
See `advss_register_script_action` for more details.
|
||||
|
||||
### Return value
|
||||
|
||||
The return value can be queried via `success` from the calldata object associated with this procedure.
|
||||
Returns `true`, if the operation was successful, and `false` otherwise.
|
||||
|
||||
Reference in New Issue
Block a user