Skip to content

Task

We refer to each script as a task.

we write before, task rule is use execute function name main.

def main():
    print("hello puzzle2")

this is the most easiest task.

data

for example, this task works to change scene to 101-200


change_frame.py

def main(event={}):
    cmds.playbackOptions(min=101, max=200)
    print("{} - {}".format(101, 200))

In this scenario, we cannot reuse this task for other situations.
Therefore, we will need to give the minimum and maximum values
from external data sources and make changes accordingly.


change_frame.py

def main(event={}):
    data = event.get("data", {})
    cmds.playbackOptions(min=data["min"], max=data["max"])
    print("{} - {}".format(data["min], data["max"]))

this looks more better.


script.py

and then, this is usage for change_frame.py in puzzle process.
CAUTION: we have to set data to same name as step name

# -*-coding: utf8-*-
import sys
sys.path.append(root)

from puzzle2.Puzzle import Puzzle

# add to order config
config = [
  "step": "main",
  "tasks": [
    {"name": "change_frame",
     "module": "somewhere.change_frame"}
  ]
]

# set data to main step
data = {
    "main": {
        "min": 101, 
        "max": 200
    }
}

puzzle = Puzzle()
puzzle.play(config, data)

# 101 - 200