I will take a look at your script you sent later, as I can't access dropbox at work (it's blocked... Friday is slow...) :P. But I can have a go at what it may look like...
As you like to keep your lines of code to a minimum, you could invest in 'argument passing' or, essentially, parameterising a thread.
For example, if the code to move a script_object requires more than one line, you can always create a thread like so:
Code:
//-------------------------------------------------------------------------------//
// move jail gate
// [gate] togglegate [destination] [speed of gate| default is 2]
//-------------------------------------------------------------------------------//
togglegate local.dest local.speed:
if (local.speed == NIL)
local.speed = 2 //set a default speed
self speed local.speed
self moveto local.dest.origin
self waitmove //perhaps wait local.speed instead...
end
Then when it comes to your current threads do:
Code:
lockeast:
$trigeast_close nottriggerable
$eastgate waitthread togglegate $eastshut 4
iprintlnbold "Allies jail A is locked"
$trigeast_open triggerable // Rest the gate opening trigger, allowing the switch to be toggled
end
openeast:
$trigeast_open nottriggerable // When a player toggles the switch
$eastgate waitthread togglegate $eastopen 4
iprintlnbold "Allies jail A is unlocked"
$trigeast_close triggerable // Rest the gate closing trigger, allowing the gate to be closed again upon trigger
end
There could be glaring mistakes, but that's the gist! It's good abstracting the code at times as you can reuse it a lot, and also simply copy / paste to other projects that'll benefit from them.
You can even get your trigger states in there, as long as you keep to your naming conventions (looks like you do, which is a good habit to have, I'm lazy when it comes to naming stuff...):
Code:
//-----------------------------------------------------------------------------------------------------//
// move jail gate
// [gate] togglegate [destination] [speed of gate| default is 2] [cardinal point] [action]
//-----------------------------------------------------------------------------------------------------//
togglegate local.dest local.speed local.point local.action:
$("trig" + local.point + "_" + local.action) nottriggerable
switch (local.action)
{
open:
local.opposite = close
break
close:
local.opposite = open
break
}
self speed local.speed
self moveto local.dest.origin
self waitmove
$("trig" + local.point + "_" + local.opposite) triggerable
end
Then for all your gate threads:
Code:
lockeast:
$eastgate waitthread togglegate $eastshut 4 east close
iprintlnbold "Allies jail A is locked"
end
openeast:
$eastgate waitthread togglegate $eastopen 4 east open
iprintlnbold "Allies jail A is unlocked"
end
locknorth:
$northgate waitthread togglegate $northshut 4 north close
iprintlnbold "Axis jail A is locked"
end
opennorth:
$northgate waitthread togglegate $northopen 4 north open
iprintlnbold "Axis jail A is unlocked"
end
This is partly academic obviously, and you may be fully aware of these methods, but this is a public forum so I just post as much detail to reach as many people as possible, myself included. I'm still a novice, especially when compared to some of the big MOHAA coders (or ex-MOHAA coders as most are now).