Levers and MORE levers

If you're looking for mapping help or you reckon you're a mapping guru, post your questions / solutions here

Moderator: Moderators

Dani
Sergeant Major
Posts: 113
Joined: Mon Mar 08, 2004 6:45 pm
Contact:

Levers and MORE levers

Post 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?
Dani
Sergeant Major
Posts: 113
Joined: Mon Mar 08, 2004 6:45 pm
Contact:

Post 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
}
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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]
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post 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. 8-)

Apart from that: discussing code format standards is as meaningfull as arguing PC/MAC, Windows/Linux, Ford/Nissan and X/Y :roll:
Admin .MAP Forums
Image
Head above heels.
Dani
Sergeant Major
Posts: 113
Joined: Mon Mar 08, 2004 6:45 pm
Contact:

Post 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?
Dani
Sergeant Major
Posts: 113
Joined: Mon Mar 08, 2004 6:45 pm
Contact:

Post 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"?
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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.
Dani
Sergeant Major
Posts: 113
Joined: Mon Mar 08, 2004 6:45 pm
Contact:

Post by Dani »

so wat programing to i need for the levers, can some tell me plz?
Splaetos
Major General
Posts: 730
Joined: Tue Jan 20, 2004 2:55 pm
Contact:

Post 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?
When I am king, you will be first against the wall~
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Admin .MAP Forums
Image
Head above heels.
Dani
Sergeant Major
Posts: 113
Joined: Mon Mar 08, 2004 6:45 pm
Contact:

Post 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 :wink:

EDIT: i did leave spaces, but it hasn't shown up??
Splaetos
Major General
Posts: 730
Joined: Tue Jan 20, 2004 2:55 pm
Contact:

Post 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 =)
When I am king, you will be first against the wall~
Image
Dani
Sergeant Major
Posts: 113
Joined: Mon Mar 08, 2004 6:45 pm
Contact:

Post by Dani »

Soz, ignor this post, i keep muking up
Last edited by Dani on Sun Aug 22, 2004 6:12 pm, edited 1 time in total.
Dani
Sergeant Major
Posts: 113
Joined: Mon Mar 08, 2004 6:45 pm
Contact:

Post 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????????
Dani
Sergeant Major
Posts: 113
Joined: Mon Mar 08, 2004 6:45 pm
Contact:

Post by Dani »

It doesn't work??????????? SOMEONE HELP ME, PLZ!!!
Last edited by Dani on Mon Aug 23, 2004 11:48 am, edited 1 time in total.
Post Reply