Scripted Elevator

From MovieBattles II Wiki
Jump to: navigation, search

Contents

Introduction

Scripting an elevator can be one of the most useful uses of the scripting system. There are two types of scripts: a specific script, which works only with the entities you paired it to and a generic script, which uses variables to apply to many entities. This page will explain both.

In either case here's what you need:

Lets get started.

Specific Scripts

When you make a specific script, in BehavEd you make determinations based on the targetnames you gave your entities.

In-Game Entities

First things first, you need to name your lift. Set the following key/value on the func_static:

  • script_targetname: scripted_lift

Next, on your target_scriptrunner set these keys/vaules:

  • usescript: scripts/two_level_lift
  • targetname: lift_runner
  • count: -1
  • parm1: 0

Now, on the trigger_multiple, set these keys/values:

  • target: lift_runner
  • spawnflags: 5
  • wait: 10

For this example, the lift is only moving between two levels. Place two ref_tags, one at each level, in the position where the origin of the func_static will be. Set the keys/values on the upper one and lower one respectively as:

  • targetname: lift_up
  • targetname: lift_down

Now that the entities are set up, you need to make the script that will make them work.

Writing the Script

In BehavEd, you need to generate a script that looks like this (explanations in the comments; they are not part of the script):

if ( get( FLOAT, "SET_PARM1"), =, 0 ) //This conditional is how our lift goes to one level and stays there until it is triggered again.  It runs these commands if and only if parm1 is 0.
{
  affect ( "scripted_lift", /*@AFFECT_TYPE*/ FLUSH ) //The affect block is important, without it the script will run on the target_scriptrunner.
  {
    move ( tag( "lift_up", ORIGIN), 10000 ); //This tells the lift, which is starting at the bottom, to move up to the upper tag over a period of 10000 milliseconds, or 10 seconds.
  }
  wait (10000) //Wait until the lift reaches its destination...
  set (SET_PARM1, 1) //...Then change parm1 on the target_scriptrunner from 0 to 1.
}
else (  ) //The else closes the conditional by running these commands if parm1 is any value other than 0.
{
  affect ( "scripted_lift", /*@AFFECT_TYPE*/ FLUSH )
  {
    move ( tag( "lift_down", ORIGIN), 10000 ); //Works the same way as above except in reverse.
  }
  wait (10000) //Wait until the lift reaches its destination...
  set (SET_PARM1, 0) //...Then change parm1 on the target_scriptrunner from 1 to 0.
}

Generic Scripts

Under Construction

Personal tools