Workflow for instance-specific scripts

What’s the usual process for designers to setup default instance parameters for a script? If you have a small script that does nothing but print the current location of the actor after X seconds of creation (where X is variable), what’s the envisioned flow?

In Blueprint, one of the things we could do is create a custom PrintLocationComponent, give it an editable UPROPERTY and just attach that to actors (the component would get GetOwner() location, setup the timer in its beginplay, etc). How would this simple example be done in Skookum so that it works on any Actor without adding a debug UPROPERTY to the C++ AActor itself? Specifically, how would someone change that X on a per-instance basis?

1 Like

When designing the SkookumScript plugin we have decided to rely on the existing Blueprint class infrastructure to expose such editable variables to the designers. So let’s say you wanted to use a component to implement this behavior as you suggested. In this case you would still create a Blueprint class to hold the variable even though you would not use its event graphs.

Here is how you do it (you need to sync to latest from P4 before you can do this - I had to squeeze in a minor tweak):

  • Create a new Blueprint class called PrintLocationComponentSk derived from SkookumScriptBehaviorComponent
  • Add a variable named Timeout of type Float and make it public
  • Compile it
  • Click the Sk button in the Blueprint editor window of that component - this should open up the IDE and select the SkookumScript class PrintLocationComponentSk
  • Using the Add a Class/Member dialog at the bottom of the member list, add a method on_begin_play (if this is the first time you are adding Sk code to the project, you will have to first confirm a dialog box to allow SkookumScript to store its script files in your project)
  • Implement on_begin_play as follows:
  // A `branch` starts a sequence of expressions that may take more than one frame
  // to complete and moves to the next expression immediately. This allows
  // expressions that take time to be called in a method which must complete instantly.
    println("Hello I am " " and I am at " owner.transform.@translation)
  • Hit F7 or click the Commit (gears) button in the toolbar
  • Add the PrintLocationComponentSk component to the actor class (or actor instances) you’d like to use it with
  • In the level editor, select the actor instances and set the Timeout variable to custom values
  • Run the game - you should see something like the following printed to the SkookumIDE log window:
Hello I am RoboChar1 and I am at (475, -1422, 317.45)
Hello I am RoboChar2 and I am at (2389, -1514, 317.45)
Hello I am RoboChar3 and I am at (3616, -1454, 317.45)

Let me know if that works for you!