Page 1 of 2
Levers and MORE levers
Posted: Sat Aug 21, 2004 2:34 pm
by Dani
OK i need THREE types of lever scripting:
1. a lever to close the gate
2. a lever to open the gate
3. a lever to slide out and then slide in a wall.
How do i do this?
Posted: Sat Aug 21, 2004 2:37 pm
by Dani
for lever 3 would i be rit in saying this?:
Code: Select all
wallsildetrig:
local.yes = 1
if (local.yes = 1) {
$wally moveeast 20
$wally waitmove
local.yes = 0
} else {
$wally movewest 20
$wally waitmove
local.yes = 1
}
Posted: Sat Aug 21, 2004 2:59 pm
by lizardkid
please Dani, dont use the f***ed up braces that those manaic Linux programmers used, you can never tell when something ends and another begins.
if(local.yes = 1)
{[/u][/i]
Posted: Sat Aug 21, 2004 6:06 pm
by Bjarne BZR
Danis brace-placement is exelent as it compacts code (you get rid of the extra lines ), but it sucks badly if you dont combine it with proper indentation.
So please put all code in "code" blocks and use indentation, it greatly increases readability for both yourself and others.
Apart from that: discussing code format standards is as meaningfull as arguing PC/MAC, Windows/Linux, Ford/Nissan and X/Y

Posted: Sat Aug 21, 2004 6:22 pm
by Dani
WOOOOOOOOOOOW look i'm sorry about my braces . But i only know actionscript (which is from javascript), and i don't even know wat language this is programing in, and i just didn't know wat to do, so could some1 give me my code, in the correct format?
Posted: Sat Aug 21, 2004 6:27 pm
by Dani
OHHHHHHHHHHH did u edit it for me? Thx now i know wat u mean.
P.S why do i have to use "local.watevermyvariable = myvalue" ??? can't i do "myvariable = myvalue"?
Posted: Sat Aug 21, 2004 6:58 pm
by lizardkid
no, in MOHAA scripting you need to specify to how many places it can be available, local is to that thread only, level is for all script on that level, game is for the whole game session.
Posted: Sat Aug 21, 2004 8:17 pm
by Dani
so wat programing to i need for the levers, can some tell me plz?
Posted: Sat Aug 21, 2004 9:29 pm
by Splaetos
clarify....
two triggers in seperate locations?
one can ONLY open, other can ONLY close?
also important is if you are actualy using an animated trigger and sounds(see below)
as for the third lever.
Code: Select all
wallsildetrig:
level.wall_open = 1
while(1) {
$wall_trigger waitTill trigger
if (level.wall_open == 1) {
$wally moveeast 20
$wally waitmove
level.wall_open = 0
} else {
$wally movewest 20
$wally waitmove
level.wall_open = 1
}}
end
if it starts open rather then closed name the var level.wall_closed instead if you wish. Using a level variable allows you to reference if its open or not other places in your script. (You may not need to... but never know)
It needs to wait to be triggered, so I insterted a line for that.
oh and changed = to ==
if your using an actual 'lever' the one that moves....
insert after the trigger:
$wall_trigger_lever anim move
(you also might want to add a playsound line here for the lever being used. do a search on playsound and aliascache or look at the tutorial on addign custom sounds. If you dont want your wall to move silently either, add a playsound with its movement.)
and after the move
$wall_trigger_lever anim idle
~~~Ive never actualy used these anim commands, but I believe they work with the trainswitch model if used as above. Or whatever lever (the only real lever ive seen) Bjarne used in 'the Canal'
ps - I never write code like that =p how do you correctly display the last -}}- to close the else, and the while?
Posted: Sun Aug 22, 2004 9:15 am
by Bjarne BZR
Posted: Sun Aug 22, 2004 4:57 pm
by Dani
you close it of like this:
while{
if(){
//your stuff
}
}
Anyway, how do i do the first to levers, i have been thinging and could i do this?:
//set gate closed
level.gateopen = 0
//Lever OPEN
leveropentrig:
if(level.gateopen = 0){
$gate moveup 324
$gate waitmove
level.gateopen = 1
}
end
//Lever CLOSE
leverclosetrig:
if(level.gateopen = 1){
$gate movedown 324
$gate waitmove
level.gateopen = 0
}
end
Could it work? Wat have i done wrong, SOMEONE TELL ME, thx
EDIT: i did leave spaces, but it hasn't shown up??
Posted: Sun Aug 22, 2004 5:37 pm
by Splaetos
you didint use [-code-] take out the - - code in brackets leaves formatting alone, and you end it with [-/code-]
your using setthreads? Otherwise you need trigger info in the threads. Also you need to turn off the other trigger while the gate is moving if it starts a different thread. If it was in the same thread off the same trigger, then it wouldnt be prepated to move the opposite way, but if not, it can be triggered both ways, which isnt good.
Code: Select all
open_trigger nottriggerable
close_trigger nottriggerable
open_trigger triggerable
close_trigger triggerable
Those commands turn off or on your triggers, preventing conflicting orders when movements are taking place in seperate threads.
Remember if you are setting a variable 'equal to' you use =
but if you are checking if a variable is 'equal to' you use ==
level.gate_open = 0
if (level.gate_open == 0)
again... no clue how your setting up your triggers, or if your running threads from the map info(setthread) so not much else can say =)
Posted: Sun Aug 22, 2004 6:10 pm
by Dani
Soz, ignor this post, i keep muking up
Posted: Sun Aug 22, 2004 6:11 pm
by Dani
OK, i am useing use_trigers so if i call my use_triger opengatetrig then i make a thread called opengatetrig, it should work. I forgot about the == soz

.So wat you saying is that my code should look lik this?:
Code: Select all
//set gate closed
level.gateopen = 0
//Lever OPEN
leveropentrig:
if(level.gateopen == 0){
leverclosetrig nottriggerable
$gate moveup 324
$gate waitmove
level.gateopen = 1
leverclosetrig triggerable
}
end
//Lever CLOSE
leverclosetrig:
if(level.gateopen == 1){
leveropentrig nottriggerable
$gate movedown 324
$gate waitmove
level.gateopen = 0
leveropentrig triggerable
}
end
also, i am going to have two pairs of open/close levers, because i have to gates, will it matter if they both open at the same time

And i ALSO have a lever that opens and closes another door will THIS affect the others????????
Posted: Sun Aug 22, 2004 7:56 pm
by Dani
It doesn't work??????????? SOMEONE HELP ME, PLZ!!!