Page 1 of 2

simplify a script

Posted: Fri Mar 26, 2004 6:45 pm
by fuhrer
i have a lift with 4 floors, trigger use on each floor and 4 triggers inside to move the lift to the desired floor using waypoints. All triggers are using setthreads.

is there a way i can maybe put all of them into one thread, so if i had 15 floors i wouldnt need 30 threads?

Code: Select all

//--------------//
// Lift Buttons //
//--------------//

1st:
	$lift moveto $floor_1	// sets the lifts destination
	$lift move		// moves the lift to that destination
end


2nd:
	$lift moveto $floor_2
	$lift move
end


3rd:
	$lift moveto $floor_3
	$lift move
end


4th:
	$lift moveto $floor_4
	$lift move
end


//--------------//
// Call Buttons //
//--------------//

call_1:
	$lift moveto $floor_1
	$lift move
end


call_2:
	$lift moveto $floor_2
	$lift move
end


call_3:
	$lift moveto $floor_3
	$lift move
end


call_4:
	$lift moveto $floor_4
	$lift move
end



end

Posted: Fri Mar 26, 2004 8:55 pm
by jv_map
Make it like this:

Code: Select all

callthread local.num:
   $lift moveto $("floor_" + local.num)
   $lift move
end
Then you can e.g. simply do:

thread callthread 3

or

thread callthread 4

etc

Posted: Sat Mar 27, 2004 12:44 am
by fuhrer
im unfamiliar with callthread, could ya explain a little at what that is doing?

Posted: Sat Mar 27, 2004 12:52 am
by wacko
callthread is just a name, u could as well call it something else :wink:

Posted: Sat Mar 27, 2004 1:13 am
by fuhrer
ok so what is the local.num doing, i cant see how its working :?

Posted: Sat Mar 27, 2004 2:40 am
by Combat Kirby
thread callthread 3

local.num will = 3



thread callthread 4

local.num will = 4


local.num will pickup the parameter that is sent to it when a value is to the right of the calling thread.

Posted: Sat Mar 27, 2004 9:58 pm
by fuhrer
i think i get it but how do i write that in the script?

Posted: Sat Mar 27, 2004 10:54 pm
by nuggets
there's no point in having two seperate threads for each button inside and outside the elevator that call it to the same floor.

1st:
$lift moveto $floor_1 // sets the lifts destination
$lift move // moves the lift to that destination
end

and

call_1:
$lift moveto $floor_1
$lift move
end

they do the same thing, so have just one setthread

key: setthread
value: call

also if you were to add the floor to each trigger
key: #floor
value: 1 //change respectively 2, 3, 4

you could simplify your script to be no more than

call:
$lift moveto $("floor_" + self.number)
$lift move
end

Posted: Sat Mar 27, 2004 11:21 pm
by fuhrer
so i leave everything as it is now in the map file, cept make all triggers

setthread
call

and have the targetnames on each floor the same i.e.

inner trigger floor 1:

key #floor
value 1

outer trigger floor1:

key #floor
value 1

ah!! is self.number looking at which trigger is pressed and takin the value property??? but then would self.number have to be self.value?

so pressing the inner or outer button for floor 4 it would take the value of 4.

but then would self.number have to be self.value? and would it need to be set in prespawn?


Also....

I now have

Code: Select all

$1st_doors doopen
how do i make the script close the right set of doors?

Posted: Sat Mar 27, 2004 11:46 pm
by wacko
nuggets wrote:also if you were to add the floor to each trigger
key: #floor
value: 1 //change respectively 2, 3, 4

you could simplify your script to be no more than

call:
$lift moveto $("floor_" + self.number)
$lift move
end
atleast me, i don't get this: why is the value given to something called #floor and then taken from something called number

Posted: Sun Mar 28, 2004 1:32 am
by fuhrer
my triggers only work if i unbind them from the lift...

seems using self. wont work if the trigger callin the thread is bound to something :?

also i was trying to be clever with the door closing by using a variable...

Code: Select all

call: 
	
	thread triggers_off
	level.doors doclose
	$lift moveto $("floor_" + self.floor)
	$lift loopsound lift_sound
	$lift waitmove			
	$lift loopsound lift_sound wait
	$("doors_" + self.floor) doopen
	$("doors_" + self.floor) playsound lift_gate
	level.doors = $("doors_" + self.floor)
	wait 1.5
	thread triggers_on
end
now the doors dont close, is there a way i can make that so that the doors on the floor that the lift was last at will close when the lift is called to another floor. (simple way)


AND, is there a command to turn off all the triggers at once, instead of having them turn off in another thread i.e. all triggers nottriggerable

Posted: Sun Mar 28, 2004 11:52 pm
by nuggets
lmao. oops and oversight on my part :P

use self.floor not self.number :oops:

Posted: Mon Mar 29, 2004 2:18 am
by tltrude
The first "level.doors doclose" does not know what the value of "level.doors" is, so it will be "NIL".

Posted: Mon Mar 29, 2004 9:53 am
by fuhrer
hm, so that would work?

Posted: Mon Mar 29, 2004 12:14 pm
by nuggets
post the whole script you've got, i'd imagine that you've set level.doors when your binding the buttons to the elevator