Script and Entity.. a bad couple


(LaggingTom) #1

Alright, here I go again.

I’ve made a switch that goes down and up (yay!) I’m sure it does this, as I’ve tested it. Also, I’ve made a door that opens and closes, and changes color accordingly. They work fine individually. Now, both are triggered by a target_script_trigger being targeted by a func_invisible user. Here are the keys/values/random bits and pieces.

The door:

{
"spawnflags" "2"
"targetname" "plane_norm_door"
"scriptname" "plane_norm_door"
"classname" "script_mover"

The door in red colorness:

{
"scriptname" "plane_red_door"
"targetname" "plane_red_door"
"spawnflags" "2"
"classname" "script_mover"

The lever itself:

{
"targetname" "lever_mover"
"scriptname" "lever_mover"
"spawnflags" "2"
"classname" "script_mover"

Lever path up!

{
"targetname" "lever_up"
"origin" "649 -761 189"
"classname" "path_corner"
"scriptname" "lever_up"
}

Lever path down!

{
"classname" "path_corner"
"origin" "649 -761 172"
"targetname" "lever_down"
"scriptname" "lever_down"
}
{
"classname" "func_invisible_user"
"targetname" "lever"
"cursorhint" "hint_button"
"scriptname" "lever"
"target" "lever_tst"
{
"classname" "target_script_trigger"
"origin" "648 -760 216"
"target" "lever_start"
"scriptname" "lever"
"targetname" "lever_tst"
}

And finally, the script:

lever
{
	spawn
	{
		wait 200
		trigger self open
		accum 1 set 1
	}

	trigger activate
	{
		trigger self lever_start
	}
	
	trigger lever_start
	{
		trigger self close
	}

	trigger close
	{
		setstate plane_norm default
		setstate plane_red invisible
		trigger plane_red_door close
		trigger plane_norm_door close
		trigger lever_mover up
		accum 1 set 1
	}

	trigger open
	{
		setstate plane_norm invisible
		setstate plane_red default
		trigger plane_red_door open
		trigger plane_norm_door open
		trigger lever_mover down
		accum 1 set 0
	}
}

lever_mover
{
	spawn
	{
		wait 200
	}

	trigger up
	{
		gotomarker lever_up 50
	}

	trigger down
	{
		gotomarker lever_down 50
	}
}

plane_red_door
{
	spawn
	{
		wait 200
	}

	trigger open
	{
		faceangles 0 0 45 200
		setstate plane_red_door default
	}
	
	trigger close
	{
		faceangles 0 0 0 200
		setstate plane_red_door invisible
	}
}

plane_norm_door
{
	spawn
	{
		wait 200
	}

	trigger open
	{
		faceangles 0 0 45 200
		setstate plane_norm_door invisible
	}
	
	trigger close
	{
		faceangles 0 0 0 200
		setstate plane_norm_door default
	}
}

Whew… that’s a lot of stuff.

Anyway, the door starts open and red just fine, and the lever is down. When I activate the lever, nothing happens except a console error “Warning: Entity Used Itself”. And as bad as I feel for that entity, I’m unsure which it is, much less if I can get it to a doctor so it will stop using itself, and use others, like a good member of the entity society should!


(No1_sonuk) #2

Code:
{
“classname” “func_invisible_user”
“targetname” “lever”
“cursorhint” “hint_button”
“scriptname” “lever”
“target” “lever_tst”

Code:
{
“classname” “target_script_trigger”
“origin” “648 -760 216”
“target” “lever_start”
“scriptname” “lever”
“targetname” “lever_tst”
}

These 2 entities have the same scriptname.

IIRC, the func_invisible_user should have the target_script_trigger as its target, with no scriptname.


(sodsm live) #3

can a func_I_U have a targetname? i’m just wondering cuz i’m having a bad time trying to attachtotag one.


(Shaderman) #4

AFAIK you can attach a func_invisible_user to a tag but it won’t move with a script_mover if that is what you’re trying. The possibility to move some kind of button with a mover would be really great!


(Detoeni) #5

Make the button location the origin of the script mover, attach tag to the mover origin, attach func_invisible_user to tag so it moves with the mover…


(sodsm live) #6

@Shaderman, ya i’ve been going in circles trying to get an elevator working right. Almost to the point of giving up and just having the FIU stretch from the lobby to the top floor, and laying out the buttons for each floor horizontally along the lift’s walls(like in that passcode map except alot smaller). other than it looking unrealistic, you can work the elevator from inside the shaft.

@Detoeni, it might take me a few days to wrap my brain around what you said and figure it out. is this something you’ve had working or is it theory? sorry i’m a bit noobish and not sure what the hard and easy tasks of ET mapping are yet.


(Detoeni) #7

Its something Iv worked with a few times…

The tag block needs to be set as a model2 in the script mover.
You can grab a tag_block from here: http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=5397&highlight=tag


(sodsm live) #8

@Detoeni, a couple post above you gave a procedure to accomplish this.

Make the button location the origin of the script mover…

by this do you mean construct in a way so that the FIU is over the the general area of the origin of the script_mover(like an invisible plane above the fake button face to give the appearance of a working button at run time - this is what i have been doing)? or did you mean to enclose the origin/duplicate it’s dimensions with the FIU? I don’t see much difference in either approach, I just want to be clear on your instructions.

…attach tag to the mover origin…

did you mean attach the script_mover origin to the tag? how do you reference just the origin of the script_mover? is it by the whole script_mover’s targetname or is there a way to single out the origin? am i overthinking this? does using the model2 key attach the model’s tag to the origin or is there an extra step - essentially needing two attachtotag commands in the script to have a single moving FIU?

…attach func_invisible_user to tag so it moves with the mover…

this should just be a single line attachtotag command in the FIU’s spawn script, correct? all i’ve seen of attachtotag is:
attachtotag <targetname> <tagname>

would the script be something like:

<F_I_U name>
{
   spawn
      {
           attachtotag <27tagmodelname?> <tag_xAyBzC>
      }
}

i’m confused about the targetname to use for attachtotag. is it the model’s name? the tagfile’s name? i noticed in the goldrush script something called “tagent,” does that have something to do with it?

i truly appreciate the help. i’ve spent the past week searching here and at surface’s forums as well as using google and i can’t seem to crack it.

BTW the 27 tag model appears as an infinitely small dot in radiant. is it supposed to be that way or are my paths messed up?


(Detoeni) #9
<F_I_U_scriptname> 
{ 
   spawn 
      { 
           wait 300
           attachtotag <scriptname> <tag_name> 
      } 
}

your lift should be made with its origin brush where you want the switch in game. The tag block is set as “model2” in the mover. This will mean the tag block is at the mover/lift origin. The above code would then attach the trigger to the mover lift.

you wont see the tag block in radiant or game as it has no textured plains.


(sodsm live) #10

i hope this hasn’t detracted from lagging tom’s issue but i didn’t want to start a new thread when most of the info is in this one. if a mod wants to split the topic i have no problem with that.

anyway i’m still having a problem. okay, i have:

script_mover(brush + origin brush at first path corner) = model2(/models/mapobjects/sod_lift/27_tags_beta.md3), targetname(button), scriptname(button)
func_invisible_user(just in front of mover origin) = a cursorhint, target(button_TST), scriptname(button_FIU)
target_script_trigger = targetname(button_TST), scriptname(move_button), target(move_to_floor2)
2 path_corners = targetname(floor_01 and floor_02 respectively)
2 drawn brushes = just as a temp so i can find the FIU at runtime since everything is invisible at this point

the script at the moment is:


game_manager
{
	spawn
	{
		wait 2000
	}
}

move_button	//scriptname of TST
{
	trigger move_to_floor2	//target of TST
	{
		trigger button move_dest
	}
}

button		//scriptname of script_mover with 27 tag model2
{
	trigger move_dest
	{
		wm_announce "blah blah blah"
		gotomarker floor_02 32
	}
}

button_FIU	//scriptname of FIU
{
	spawn
	{
		wait 500 
		attachtotag button tag_x0y0z0	//according to readme x0y0z0 is the tag at model's origin(dead center of the cube?)
	}
}

as it is, the map runs(doesn’t crash) with no warning or errors in console. it doesn’t work though. no cursor hint shows up where the FIU should be and the announce message that i put in for testing if the FIU was triggering the script doesn’t appear. to make sure nothing else was broken, i commented out the attachtotag line and now the cursor hint shows up where it should and the announce message fires.

it seems to me i’m still not getting the attachtotag command correct. or maybe the model isn’t loading? is there some specific way i’m supposed to tell ‘attachtotag’ to be using the tag from the ‘27_tags_beta.md3’? or is that implied by the tag name? what happens if you have 2 models that happen to have tags with the same names?

i thought maybe i was using the wrong scriptname in attachtotag. i just tried it with ‘attachtotag button_FIU tag_x0…’ the cursor hint appears and the message fires but it still doesn’t move. is there another model i could use with a known tagname that i could test with so i could at least see if the model is moving or maybe another way to see if anything is moving(other than the cursorhint)?

thanks Detoeni and anyone else that may have suggestions.


(Detoeni) #11

make sure the tag file is in the folder with the md3, make sure the model path is “models/mapobjects/sod_lift/27_tags_beta.md3” without the first “/”
func_invisible_user needs “targetname” “button_FIU”
target_script_trigger needs “targetname” “move_button” (always keep the same target/scriptname in entities)
Give it another go.

Try deleating the func_invisible_user, then remake it with an origin.
Give it another go.


(DerSaidin) #12

When you press the button it runs the script in the button’s scriptname / activate
eg. scriptname = “button_FIU”


button_FIU
{
	spawn
	{
		wait 200
	}
	
	activate
	{		
		wm_announce "blah blah blah"
                gotomarker floor_02 32 
	}
}


(sodsm live) #13

fwiw i put a ‘wait’ at the end of the ‘gotomarker’ and another message to display after it. there is a delay of the amount of time it would take to move the model from path1 to path2 so i know that the model is moving. hitting the button again results in no delay so that reinforces the fact that the model/mover has indeed moved.

the ‘/’ at the beginning of the model path was just a typo i made while making the forum post, it’s not there in the script mover. the tag file is in the folder with the model and has the same name as the model('cept it has the .tag extension).

added targetname - button_FIU to FIU

changed the TST’s targetname to match the scriptname and also changed the target in the FIU to ‘move_button’ to work with the changed TST targetname.

same effect. the model/mover moves but the FIU stays in place

deleted the FIU. made a new trigger brush and origin brush, selected both of them and made them func_invisible_user. added all the properties to the entity.

same effect. model moves but not the FIU.

@Der’saidin, is this another way of having an FIU run code? i have it targeting a target_script_trigger as in nibsworld script_mover tutorial to start the movement script.


(DerSaidin) #14

I dont know, but I know the way I said works.


(sodsm live) #15

holy crap it works! thanks Der’saidin. it seems so simple :slight_smile:

the FIU just needs and origin brush, scriptname, target and path corners to go to and it’s all good.

Detoeni, thanks for being patient with me. i think it was my bad for starting off in the wrong direction.

this was my first major hurdle in mapping, i’m sure i’ll be back for the next one.


(sodsm live) #16

thank you guys so much. the mechanics of my elevator are now finished. it’s only 3 floors at the moment but it’s really just cut & paste in the script up to the 8th floor. i already had moving doors that travel with the elevator figured out but the moving buttons you guys helped me with is the triple-cherry icing on top!
:drink:

i’d post some screens but i don’t think they would show what’s going on. i mean it’s a plain old(but really tall) box map with a lift against the wall that i’m sure everyone has seen a 1000 times anyway. it’s how it works that makes it cool(to a noob like me).

Der’ and Detoeni, there will be a dedication plaque in the elevator thanking the two of you.

if anyone comes back to this thread one last time, do any of you know where i can find more detailed info on scripting? i ask because there were a couple oddities i found while scripting the lift. for instance, in one section i wrote:


floor_02_button
{
        activate
        {
                trigger lift_01 move_to_floor02
                trigger floor_01_button b1flr2
                trigger floor_03_button b3flr2 
                trigger floor_02_button b2flr2
...

i had to put the call to 'trigger floor_02_button b2flr2" last in line because, for some reason, if i just put them in # order the triggers for the floors past the one you called from don’t activate. so as you can see, the first floor button code would have to go 2,3,1(after the call to move the lift). it’s not that important since it works properly already, i’m just naturally curious.


(sodsm live) #17

it would seem that i would have to thank Gerbil as well. apparently he made a multifloor elevator years ago. i was up all night working out the elevator logic and a complicated floor queueing system. 15 minutes ago i found i needed a command for accum that logically should be called “trigger_if_not_equal”. i tried it in a test and the script crashed so i googled it and found a scripting wishlist by Gerbil. i was intrigued because the first one on the list was “trigger_if_equal” which already exists. so i skimmed down to see if there was mention of the “…not_equal” counterpart(i thought maybe it was worded differently) and there i saw snippets of what looked like the code i’ve been writing, only it’s from 3 years ago and arranged a bit differently. i stopped right away and haven’t looked at anymore of that script. i’m not sure what map it’s from or where to get it and i don’t think i want to know. now my problem is that i’m worried that when i release this map i’ll be accused of stealing Gerbil’s elevator script. i’m not sure if i should go on with the map.


(Shaderman) #18

Why don’t you ask him if you may use it for your map?


(sodsm live) #19

if i was at the beginning and not 75% done with this thing then i might concede to asking to borrow some else’s code. it would probably depress me too much knowing that someone else’s pride and joy is at the heart of my map.

gahhh… i think i’ll just finish it anyway and then figure out where to go from there. i guess the worst part is that i thought i was actually going to be able to contribute something to mappers and scripters(it was to be my first tutorial or at least a prefab).