Topic: Variable Support on Lock Camera

Last night I had a great idea for an object, a camera locker which automatically adjusted to fit the boss arena.  However, when I tried to make this idea a reality it backfired.  I have posted the code below (With all animations commented to avoid having to post dependencies), and I believe that the main reason it doesn't work is there is no variable support on the lock_camera modifier.

// -----------------------------------------------------
// blackboxcameralocker.obj
// This is a camera locking object for Open Surge
// Originally designed for: Open Surge Lunar Mod
// Version 1.0
// Author: lunarrush
// -----------------------------------------------------
object "Black Box Camera Locker"
{
requires 0.2.0
always_active
category "camera locking technology" "blackbox"
hide_unless_in_editor_mode
state "main"
{
//set_animation "BLACK_B" 0
let "$_walls_found = 0"
let "$_locker_destruction_signal = 0"
let "$_locker_left_wall = -50"
let "$_locker_right_wall = 50"
let "$_locker_ceiling = -50"
let "$_locker_floor = 50"
create_child ".Left Wall Sensor"
create_child ".Right Wall Sensor"
create_child ".Ceiling Sensor"
create_child ".Floor Sensor"
change_state "wait"
}
state "wait"
{
if "$_walls_found >= 4" "lock"
}
state "lock"
{
lock_camera "$_locker_left_wall" "$_locker_ceiling" "$_locker_right_wall" "$_locker_floor"
if "$locker_destruction_signal == 1" "destroy"
}
state "destroy"
{
destroy
}
}
// -----------------------------------------------------
// leftwallsensor.obj
// This is a camera locking object for Open Surge
// Originally designed for: Open Surge Lunar Mod
// Version 1.0
// Author: lunarrush
// -----------------------------------------------------
object ".Left Wall Sensor"
{
requires 0.2.0
always_active
hide_unless_in_editor_mode
state "main"
{
//set_animation "TEST_1" 0
move -500 0
on_left_wall_collision "sense"
}
state "sense"
{
let "$_locker_left_wall = xpos()"
let "$_walls_found += 1"
destroy
}
}
// -----------------------------------------------------
// rightwallsensor.obj
// This is a camera locking object for Open Surge
// Originally designed for: Open Surge Lunar Mod
// Version 1.0
// Author: lunarrush
// -----------------------------------------------------
object ".Right Wall Sensor"
{
requires 0.2.0
always_active
hide_unless_in_editor_mode
state "main"
{
//set_animation "TEST" 0
move 500 0
on_right_wall_collision "sense"
}
state "sense"
{
let "$_locker_right_wall = xpos()"
let "$_walls_found += 1"
destroy
}
}
// -----------------------------------------------------
// ceilingsensor.obj
// This is a camera locking object for Open Surge
// Originally designed for: Open Surge Lunar Mod
// Version 1.0
// Author: lunarrush
// -----------------------------------------------------
object ".Ceiling Sensor"
{
requires 0.2.0
always_active
hide_unless_in_editor_mode
state "main"
{
//set_animation "TEST_1" 0
move 0 -500
on_ceiling_collision "sense"
}
state "sense"
{
let "$_locker_ceiling = ypos()"
let "$_walls_found += 1"
destroy
}
}
// -----------------------------------------------------
// floorsensor.obj
// This is a camera locking object for Open Surge
// Originally designed for: Open Surge Lunar Mod
// Version 1.0
// Author: lunarrush
// -----------------------------------------------------
object ".Floor Sensor"
{
requires 0.2.0
always_active
hide_unless_in_editor_mode
state "main"
{
//set_animation "TEST" 0
move 0 500
on_floor_collision "sense"
}
state "sense"
{
let "$_locker_floor = ypos()"
let "$_walls_found += 1"
destroy
}
}

My question is, will there ever be variable support on this command, and if so when can I expect it to be there?  I think this object could be a great help to all level designers, and I want them to be able to use it.  Also, if you think there is another reason why the nanoparser has a fit every time I try to select this object please post your reason so that I can debug the code.
thanks,
-lunarrush

If I knew then what I know now I'd tell you that the story's true.  Cause whatever you do, it comes back to you.  -Slaughter, Burning Bridges

Re: Variable Support on Lock Camera

It does support variables.

There are two problems in here.

One is with the command itself, the other is with your code.

The problem with your code: lock_camera expects positions relative to the object, but you're passing absolute positions to it

The problem with the command: once the engine reads the object, it will read the lock_camera tag and complain the coordinates are incorrect, since all variables are initially set to zero. Also, the red rectangle you see in the editor won't be transformed as it should. This is in fact a problem that must be fixed.

You can't do much today about this second problem today, but I'll show you a workaround. You can make your smart boss arena today by using

lock_camera "$_locker_left_wall" "$_locker_ceiling" "1+$_locker_right_wall" "1+$_locker_floor"

so it won't complain about the wrong coordinates. Also, make the calculations in such a way that you pass relative positions instead of absolute ones. It's a matter of subtracting xpos() and ypos()

Re: Variable Support on Lock Camera

All the problems I said earlier related to the command are now fixed (rev. 431).

Use lock_camera freely.