a Lever


(Lock Ness Monster) #1

ok, im trying to make a lever, im trying new things everyday lol. Ive ran into some problems, it wont move. I dont know y cause ive never made one like it before and i would search, but my crappy dial up keeps cutting me off every few mins so i dont get to stay on long enough

here is the map for it

// entity 0
{
“classname” “worldspawn”
“mapcoordsmins” “-9408 5312”
“mapcoordsmaxs” “9408 -5376”
// brush 0
{
( 320 -751 -1404 ) ( 320 -767 -1404 ) ( 320 -767 -1588 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 339 -751 -1404 ) ( 320 -751 -1404 ) ( 320 -751 -1588 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 325 -765 -1407 ) ( 325 -749 -1407 ) ( 325 -749 -1591 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 320 -766 -1404 ) ( 339 -766 -1404 ) ( 339 -766 -1588 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 309 -767 -1565 ) ( 309 -751 -1565 ) ( 328 -751 -1565 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 339 -751 -1588 ) ( 320 -751 -1588 ) ( 320 -767 -1588 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
}
// brush 1
{
( 350 -751 -1588 ) ( 331 -751 -1588 ) ( 331 -767 -1588 ) metal_misc/ametal_m03_nonsolid -22 0 0 0.500000 0.500000 0 8 0
( 320 -767 -1565 ) ( 320 -751 -1565 ) ( 339 -751 -1565 ) metal_misc/ametal_m03_nonsolid -22 0 0 0.500000 0.500000 0 8 0
( 331 -766 -1404 ) ( 350 -766 -1404 ) ( 350 -766 -1588 ) metal_misc/ametal_m03_nonsolid -22 0 0 0.500000 0.500000 0 8 0
( 336 -767 -1407 ) ( 336 -751 -1407 ) ( 336 -751 -1591 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 350 -751 -1404 ) ( 331 -751 -1404 ) ( 331 -751 -1588 ) metal_misc/ametal_m03_nonsolid -22 0 0 0.500000 0.500000 0 8 0
( 331 -751 -1404 ) ( 331 -767 -1404 ) ( 331 -767 -1588 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
}
// brush 2
{
( 339 -748 -1588 ) ( 320 -748 -1588 ) ( 320 -764 -1588 ) metal_misc/ametal_m03_nonsolid 0 6 0 0.500000 0.500000 0 8 0
( 309 -764 -1565 ) ( 309 -748 -1565 ) ( 328 -748 -1565 ) metal_misc/ametal_m03_nonsolid 0 6 0 0.500000 0.500000 0 8 0
( 326 -766 -1405 ) ( 345 -766 -1405 ) ( 345 -766 -1589 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 331 -764 -1407 ) ( 331 -748 -1407 ) ( 331 -748 -1591 ) metal_misc/ametal_m03_nonsolid -6 0 0 0.500000 0.500000 0 8 0
( 339 -764 -1406 ) ( 320 -764 -1406 ) ( 320 -764 -1590 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 325 -748 -1404 ) ( 325 -764 -1404 ) ( 325 -764 -1588 ) metal_misc/ametal_m03_nonsolid -6 0 0 0.500000 0.500000 0 8 0
}
// brush 3
{
( 325 -742 -1574 ) ( 325 -766 -1574 ) ( 325 -766 -1579 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 331 -763 -1575 ) ( 325 -763 -1575 ) ( 325 -763 -1580 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 331 -766 -1574 ) ( 331 -742 -1574 ) ( 331 -742 -1579 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 325 -764 -1574 ) ( 331 -764 -1574 ) ( 331 -764 -1579 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 325 -766 -1573 ) ( 325 -742 -1573 ) ( 331 -742 -1573 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 331 -742 -1579 ) ( 325 -742 -1579 ) ( 325 -766 -1579 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
}
}
// entity 1
{
“target” “door_callscript”
“classname” “func_invisible_user”
“cursorhint” “HINT_ACTIVATE”
// brush 0
{
( 315 -751 -1557 ) ( 315 -766 -1557 ) ( 315 -766 -1596 ) common/trigger 0 0 0 0.500000 0.500000 0 7 0
( 357 -750 -1557 ) ( 301 -750 -1557 ) ( 301 -750 -1596 ) common/trigger 0 0 0 0.500000 0.500000 0 7 0
( 341 -768 -1557 ) ( 341 -753 -1557 ) ( 341 -753 -1596 ) common/trigger 0 0 0 0.500000 0.500000 0 7 0
( 301 -766 -1557 ) ( 357 -766 -1557 ) ( 357 -766 -1596 ) common/trigger 0 0 0 0.500000 0.500000 0 7 0
( 301 -766 -1557 ) ( 301 -751 -1557 ) ( 357 -751 -1557 ) common/trigger 0 0 0 0.500000 0.500000 0 7 0
( 357 -751 -1596 ) ( 301 -751 -1596 ) ( 301 -766 -1596 ) common/trigger 0 0 0 0.500000 0.500000 0 7 0
}
}
// entity 2
{
“classname” “script_mover”
“scriptname” “doorlever”
“spawnflags” “2”
// brush 0
{
( 326 -759 -1573 ) ( 326 -766 -1573 ) ( 326 -766 -1577 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 325 -742 -1573 ) ( 320 -742 -1573 ) ( 320 -742 -1577 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 330 -766 -1573 ) ( 330 -759 -1573 ) ( 330 -759 -1577 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 320 -766 -1573 ) ( 325 -766 -1573 ) ( 325 -766 -1577 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 320 -766 -1574 ) ( 320 -759 -1574 ) ( 325 -759 -1574 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
( 325 -759 -1578 ) ( 320 -759 -1578 ) ( 320 -766 -1578 ) metal_misc/ametal_m03_nonsolid 0 0 0 0.500000 0.500000 0 8 0
}
// brush 1
{
( 325 -759 -1578 ) ( 320 -759 -1578 ) ( 320 -766 -1578 ) common/origin 0 0 0 0.500000 0.500000 0 15 0
( 320 -766 -1574 ) ( 320 -759 -1574 ) ( 325 -759 -1574 ) common/origin 0 0 0 0.500000 0.500000 0 15 0
( 320 -766 -1573 ) ( 325 -766 -1573 ) ( 325 -766 -1577 ) common/origin 0 0 0 0.500000 0.500000 0 15 0
( 330 -766 -1573 ) ( 330 -759 -1573 ) ( 330 -759 -1577 ) common/origin 0 0 0 0.500000 0.500000 0 15 0
( 324 -764 -1573 ) ( 319 -764 -1573 ) ( 319 -764 -1577 ) common/origin 0 0 0 0.500000 0.500000 0 15 0
( 326 -759 -1573 ) ( 326 -766 -1573 ) ( 326 -766 -1577 ) common/origin 0 0 0 0.500000 0.500000 0 15 0
}
}
// entity 3
{
“classname” “target_script_trigger”
“origin” “298 -720 -1564”
“targetname” “door_callscript”
“scriptname” “door_trigger”
“target” “door_lever”
}

its just a prefab model,no ground or nothing

and here is the script

door_trigger
{
spawn
{
}
trigger doorleverup
{
accum 1 abort_if_not_equal 1
trigger doorlever up
accum 1 set 0
wait 9000
}
trigger doorleverdown
{
accum 1 abort_if_not_equal 0
trigger doorlever down
accum 1 set 1
wait 9000
}
}

doorlever
{
spawn
{
}
trigger up
{
setrotation 45 0 0
}
trigger down
{
setrotation -45 0 0
}
}

Hope someone can teach me how to make one of these things, i need one really bad for my level


(Lock Ness Monster) #2

SORRY about the double post on the site, i hope someone can delete the other one, my internet cut me off right as i sent the first one and i didnt know it went in, sorry everyone


(Oxygen - o2) #3

got a script_multiplayer?


(Lock Ness Monster) #4

yea, i got one in the map that it came from


(zl1corvette) #5
{
"classname" "target_script_trigger"
"origin" "298 -720 -1564"
"targetname" "door_callscript"
"scriptname" "door_trigger"
"target" "door_lever"
}

this entity calls something like this in the script


door_trigger
{
trigger door_lever
{
//do stuff
}
}


(Gringo Starr) #6

The target of the target_script_trigger has to be the name of the trigger in the script. You have the target as door_lever, while the door_trigger script has doorleverup and doorleverdown. If you want the user to control both activating and deactivating the lever, maybe you can have the func_invisible_user target 2 different target_script_triggers, and control which one runs the script_mover according to accums.


(Lock Ness Monster) #7

i would do that, but i dont understand much about accums yet


(TFate) #8

accums are very easy to use, I suggest you take a look at the .script files in xscript.pk3 to get a general idea of how they’re used. Believe me, they’re much easier to understand than this lever stuff.


(Gringo Starr) #9

The func_invis will target 2 target_script_triggers, and the script for those will look like this:

lever_trigger_up
{
spawn
{
accum 1 set 0  //starts in up position, so do not allow this to be run before going down
}
trigger setaccum  //accums are only relevant to the specific script they are in,
		  // so this allows other scripts to change the accum local to this script
{
accum 1 set 1  //this is triggered when the lever is moved down, to enable it to come back up
}
trigger leverup  //target of target_script_trigger
{
accum 1 abort_if_not_equal 1
accum 1 set 0  //prevents up from being run next
trigger lever_trigger_down setaccum  //allows down to be run next
trigger doorlever up
wait 9000
}
}


lever_trigger_down
{
spawn
{
accum 1 set 0
}
trigger setaccum
{
accum 1 set 1
}
trigger leverdown
{
accum 1 abort_if_not_equal 0
accum 1 set 1  //prevents down from being run next
trigger lever_trigger_up setaccum //allows up to be run next
trigger doorlever down
wait 9000
}
}

doorlever
{
spawn
{
}
trigger up
{
setrotation 45 0 0
}
trigger down
{
setrotation -45 0 0
}
} 

(Lock Ness Monster) #10

thanks, im understanding alittle about the accums stuff, that is the main thing that is still confusing me, but least im learning lol, thanks for ur help


(carnage) #11

accums are basical 8 sets of vairiables (names that can hold a number)

each object can hold 8
e.g.

door
{
}

door is a object so it can have 8 inside that part of the script

when you have accums with numbers inside them you can use code to say stop running that part of the scritp

obort is accum 3 > 1

so the script will only be able to run right to the end if the accum 3 is less than 2. When you understand that you can use them to cleverly manipulate your script.

and btw you dont need a script multiplayer to run a test script map, the poaint of a script multiplayer is to give the object

game_manager
{
}

so inside that it can control the entire game


(Gringo Starr) #12

I hope you use the script I wrote, because it will work. But I’d understand if you’d be uncomfortable using something you didn’t write. :slight_smile:


(Lock Ness Monster) #13

i tried the script, but it didnt work for some odd reason, i dont know what is wrong


(Gringo Starr) #14

Did you add the 2 target_script_triggers named lever_trigger_up and lever_trigger_down? Lever_trigger_up will have a targetname of leverup, and down will have a target of leverdown. Both target_script_triggers will have a targetname of door_callscript, according to the func_invisible you posted above.


(EB) #15

just in case you start over…HeRe

and accum and script tutorials…best I have found >>>HeRe


(Gringo Starr) #16

There you go, it’s the same system of setting accums I suggested. I actually learned most of my scripting by studying BoltyBoy’s work in WildWest. :slight_smile:


(Lock Ness Monster) #17

ok, i got the lever to work and to some added scripting, i got it to make the gate do up and down

But now i have to questions

First, How do u get it to start in a -45 angle

Second, when i pull it up it doesnt want to work anymore, how can u make it where it keeps working?


(Gringo Starr) #18

Post the script you are using now. To start it at a certain angle, you can either rotate the brush in Radiant, or each time the map loads.

Do this:

doorlever
{
spawn
{
wait 100 //allows time for entity to be created before trying to move it
setrotation -45 0 0
}


(Lock Ness Monster) #19

ok, here is my new script

game_manager
{
spawn
{

	setchargetimefactor 0 soldier 0.1\par
	setchargetimefactor 0 lieutenant 0.1\par
	setchargetimefactor 0 medic 0.1\par
	setchargetimefactor 0 engineer 0.1\par
	setchargetimefactor 0 covertops 0.11\par

	setchargetimefactor 1 soldier 0.1\par
	setchargetimefactor 1 lieutenant 0.1\par
	setchargetimefactor 1 medic 0.1\par
	setchargetimefactor 1 engineer 0.1\par
	setchargetimefactor 1 covertops 0.1\par

	wm_axis_respawntime	1
	wm_allied_respawntime	1
	wm_set_round_timelimit	30

	wm_number_of_objectives 1

	wm_set_defending_team 0

	wait 2000
}

}

lever_trigger_up
{
spawn
{
accum 1 set 0
}

trigger setaccum
{
	accum 1 set 1
}
trigger leverup
{ 
	accum 1 abort_if_not_equal 1
	accum 1 set 0
	trigger lever_trigger_down setaccum
	trigger door_lever up
	trigger Gate up
	wait 1000
}

}

lever_trigger_down
{
spawn
{
accum 1 set 0
}

trigger setaccum
{
	accum 1 set 1
}
trigger leverdown
{ 
	accum 1 abort_if_not_equal 0
	accum 1 set 1
	trigger lever_trigger_up setaccum
	trigger door_lever down
	trigger Gate down
	wait 1000
}

}

door_lever
{
spawn
{
wait 100
setrotation -45 0 0
}
trigger up
{
faceangles 0 0 45 2000
}
trigger down
{
faceangles 0 0 -45 2000
}
}

Gate_up
{
spawn
{
accum 1 set 0
}

trigger setaccum
{
	accum 1 set 1
}
trigger leverup
{ 
	accum 1 abort_if_not_equal 1 
	accum 1 set 0
	trigger Gate_down setaccum
	trigger Gate up
	wait 1000
}

}

Gate_down
{
spawn
{
accum 1 set 0
}

trigger setaccum
{
	accum 1 set 1
}
trigger leverdown
{ 
	accum 1 abort_if_not_equal 0
	accum 1 set 1
	trigger Gate_up setaccum
	trigger Gate down
	wait 1000
}

}

Gate
{
spawn
{
}

trigger up
{
	gotomarker Gate_up 40 wait
}

trigger down
{
	gotomarker Gate_down 40 wait
}

}


(Gringo Starr) #20

Here is the problem:

lever_trigger_down
{
spawn
{
accum 1 set 0
}

trigger setaccum
{
accum 1 set 1 <-------this should be 0
}
trigger leverdown
{
accum 1 abort_if_not_equal 0
accum 1 set 1
trigger lever_trigger_up setaccum
trigger door_lever down
trigger Gate down
wait 1000
}
}

Also, it looks like the gate_up and gate_down blocks are pointless, but maybe you were experimenting. I would steer clear of using capital letters, just in case (except for text the player will see of course :)).