Create Actions UT2004
From Moviesandbox
Creating your own Actions in MovieSandbox
The (facilitated) support for User-generated Actions will be implemeted in V1320 and is not working in earlier versions.
In order to create your own ScriptNodes, you need three things and a bit of ini work.
- You need ScriptedAction or LatentScriptedAction to execute Commands when called.
- You need a ScriptNode that wraps around your ScriptedActions, creates them when running the Scene and fills their properties.
- You also need a Button to create your NodeButton (the thing you can see, move around and link on screen), assign the ScriptNode to it and fill it with the necessary PropertyButtons to visually assign the ScriptNode's Properties. This Button is referred to a the NodeSpawnButton.
All ScriptNodes extend from MSBCode.ScriptNode. Nodes have a fillsequence Part in which they are filled with a sequence of ScriptedActions.
A ScriptedAction looks something like this:
class MSBAction_someFunctionality extends ScriptedAction;
function bool InitActionFor(ScriptedController C) {
// functions here get executed
return false; }
All the ScriptedActions members get assigned through the ScriptNode. Let's take a look at the ConsoleCommand Action...
class MSBAction_ConsoleCommand extends ScriptedAction;
var(Action) string CommandStr; // The console command to execute var PlayerController P;
function bool InitActionFor(ScriptedController C) { if (CommandStr!="" && P!=None) P.ConsoleCommand(CommandStr,true); return false; }
...and the corresponding ScriptNode, MSBConsoleCommandNode:
class MSBConsoleCommandNode extends MSBScriptNode;
var string Command; var string parameter;
function fillSequence() { local MSBAction_ConsoleCommand cc; local PlayerController P;
Super.fillsequence();
P=Level.GetLocalPlayerController(); cc=new(None) class'MSBAction_ConsoleCommand'; cc.CommandStr=Command@Parameter; cc.P=P;
Actions[0]=cc; }
function Execute(string Data) { local PlayerController P; P=Level.GetLocalPlayerController(); P.ConsoleCommand(Command@Parameter); }
You can see that the ScriptNode Assigns each Property to the Action, after Spawning the Action itself. The Properties themselves get assigned through PropertyButtons or Scriptfunctions (as in the case of the PlayerController).
The ScriptNode's PropertyButtons are set up in the ScriptNode's Creation Button. PropertyButtons take care of assigning the Properties of the ScriptNode when MovieSandbox is running through the Graphical User Interface.
There are different Types of PropertyButtons, the most commonly used are:
- PropertyButtonText - assigns a User's Text Input to the relevant Property.
- PropertyButton3D - assigns an Actor to the relevant Property.
- PropertyButtonBool - switches the Property between true and false.
In case of the ConsoleCommand ScriptNode, we would want to use a PropertyButtonText to assign the properties "Command" and "Parameter".
Let's take a look at the SpawnButton for MSBConsoleCommandNode:
class MSBNodeSpawnConsoleCommand extends MSB2DSpawnButton;
function LeftBtnFinished(Canvas C) { MSBNodeButton(SpawnActor).Order=Spawn(class'MSBActions.MSBConsoleCommandNode'); MSBNodeButton(SpawnActor).BtnName="Command";
MSBNodeButton(SpawnActor).ButtonList[0]="MSBPropertyButtons.MSBPropertyButtonText"; MSBNodeButton(SpawnActor).Properties[0]="Command"; MSBNodeButton(SpawnActor).ButtonList[1]="MSBPropertyButtons.MSBPropertyButtonText"; MSBNodeButton(SpawnActor).Properties[1]="Parameter";
super.LeftBtnFinished(C); }
DefaultProperties { tooltip1="Spawn a Command Node" tooltip2="Place Command Node" BtnName="Command" SpawnActorClassName="MSBCode.MSBNodeButton" }
When the left Mousebutton is pressed to confirm the Spawning of the ConsoleCommand Node, the NodeSpawnButton Spawns the corresponding ScriptNode and assigns it to the NodeButton:
MSBNodeButton(SpawnActor).Order=Spawn(class'MSBActions.MSBConsoleCommandNode');
and it also creates a set of PropertyButtons that refer to the ScriptNodes Properties "Command" and "Parameter":
MSBNodeButton(SpawnActor).ButtonList[0]="MSBPropertyButtons.MSBPropertyButtonText"; MSBNodeButton(SpawnActor).Properties[0]="Command"; MSBNodeButton(SpawnActor).ButtonList[1]="MSBPropertyButtons.MSBPropertyButtonText"; MSBNodeButton(SpawnActor).Properties[1]="Parameter";
Also notice the Tooltips and the Name of the NodeSpawnButton in the Defaultproperties. Don't change the SpawnActorClassName unless you know what you're doing!
If you created al three required classes, in order to make your NodeSpawn appear in the SceneEditor's NodeMenu, you need to add it to the NodeButton list in the MSBCode.ini in the MSBCode.MSBMenuButtonNodes part:
[MSBCode.MSBMenuButtonNodes] ButtonList=MSBMenuButtons.MSBNodeSpawnScriptRoot ButtonList=MSBMenuButtons.MSBNodeSpawnWaitTimer ButtonList=MSBMenuButtons.MSBNodeSpawnTriggerEvent ButtonList=MSBMenuButtons.MSBNodeSpawnTriggerActor ButtonList=MSBMenuButtons.MSBNodeSpawnWaitEvent ButtonList=MSBMenuButtons.MSBNodeSpawnMove ButtonList=MSBMenuButtons.MSBNodeSpawnRotateTo ButtonList=MSBMenuButtons.MSBNodeSpawnSetCam ButtonList=MSBMenuButtons.MSBNodeSpawnSetPose ButtonList=MSBMenuButtons.MSBNodeSpawnSetProperty ButtonList=MSBMenuButtons.MSBNodeSpawnConsoleCommand ButtonList=MSBMenuButtons.MSBNodeSpawnBoneRotate ButtonList=MSBMenuButtons.MSBNodeSpawnChangeSkin ButtonList=MSBMenuButtons.MSBNodeSpawnJump ButtonList=MSBMenuButtons.MSBNodeSpawnPlayAni ButtonList=MSBMenuButtons.MSBNodeSpawnPlaySound ButtonList=MSBMenuButtons.MSBNodeSpawnTween ButtonList=MSBMenuButtons.MSBSpawnKeyInputNodeButton ButtonList=MSBMenuButtons.MSBSpawnUDPInput ButtonList=MSBMenuButtons.MSBSpawnBobInserts ButtonList=MSBMenuButtons.MSBSpawnBobControl ButtonList=MSBMenuButtons.MSBSpawnGuestControl
just add the Name of your Button and your Package to the List like this:
ButtonList=MyPackageName.MyNodeSpawnButtonName
and it should appear in the NodeMenu.
This page gets more overhauls as time goes by. Check back frequently for more information.
--fiezi 21:05, 10 July 2006 (CEST)