Press a buton (func_door) which calls a function of script..


(general_daniel) #1

Hi!

I tried some searching in this forum but i don’t really find something to help me, so…

In my “deatmatch”-map i want to simply one (not-really-)objective for changing the winner-team at the end of round.

There are two buttons in the middle of the map and one should change the “wm_setwinner” 1 and the other to 0.

I saw that there is target_script_trigger, i tried out with that by connecting the button (func_door) to the target_script_trigger. I add the key scriptname and target in it as axis_btt or allies_btt.

the mapname.script looks like this:


game_manager
{
	spawn
	{
	// Game rules
	wm_axis_respawntime	1
	wm_allied_respawntime	1
	wm_set_round_timelimit	40

	// Stopwatch mode defending team (0=Axis, 1=Allies)
	wm_set_defending_team	0

	// Winner on expiration of round timer (0=Axis, 1=Allies)
	wm_setwinner	0
	
	setautospawn	"Axis Spawn A" 0
	setautospawn	"Allies Spawn B" 1
	
	wait 1000
	}
	
	trigger axis_btt
	{
		wm_setwinner 0
		wm_announce "The Axis have pushed their button!"
   }

   trigger allies_btt
   {
		wm_setwinner 1
		wm_announce "The Allied have pushed their button!"
   }
}

:disgust: surely it doesn’t work… :banana:

so, what do i wrong, what is needed else or where to write the code elsewhere?

Thx for helping

greetz

_GD


(nUllSkillZ) #2

The “target_script_trigger”-entity must have to key- / value-pairs:

-------- KEYS --------
“target” The name of the trigger
“scriptname” This corrisponds to the block

I guess “target” is used with “axis_btt” / “allies_btt” and “scriptname” is used with “game_manager”.
But I’m not sure at the moment.
So if it doesn’t work try the other way around.


(EB) #3

I don’t think I have enough information to go on for a complete 100% correct answer…but let’s try:

game_manager
{
   spawn
   {
   // Game rules
   wm_axis_respawntime   1
   wm_allied_respawntime   1
   wm_set_round_timelimit   40

   // Stopwatch mode defending team (0=Axis, 1=Allies)
   wm_set_defending_team   0

   // Winner on expiration of round timer (0=Axis, 1=Allies)
   wm_setwinner   0
   
   setautospawn   "Axis Spawn A" 0
   setautospawn   "Allies Spawn B" 1
   
   wait 1000
   }
   
   trigger axis_btt
   {
      wm_setwinner 0
      wm_announce "The Axis have pushed their button!"
   }

   trigger allies_btt
   {
      wm_setwinner 1
      wm_announce "The Allied have pushed their button!"
   }
}

allies_btt
{
	spawn
	{
		wait 200
	}
	activate
	{
		trigger game_manager allies_btt	
	}
}

axis_btt
{
	spawn
	{
		wait 200
	}
	activate
	{
		trigger game_manager axis_btt	
	}
}

(general_daniel) #4

Thx for replies.

No still doesn’t work, maybe then i haven’t it right done in the map-editor (I use 1.4).

Yeah, I#m newbie in Q3-scripting, i can programm, but I don’t understand it. I found tutorials for constructing and objectives… but I don’t find so… basics or a list of functions or whatever…

So just copy paste a script and just learn only this, and take parts of it to call a simple script if u open a door doesn’t work then.

Does anybody has an idea what is needed in map-editor or can someone send me an url for starting or advanced scripting… so calling a function seems not to be start or? ^^

confused greez

_GD


(general_daniel) #5

F*** OFF! Look what I found:

http://simland.planetquake.gamespy.com/ldr1_1/ :eek3: :eek2: :eek:

MUAHAHA :smiley:


(nUllSkillZ) #6

Ifurita has written a very good scripting tutorial:
http://www.planetwolfenstein.com/4newbies/Map_Scripting_4_Newbies.pdf

His main page with some other goodies:
http://www.planetwolfenstein.com/4newbies/


(general_daniel) #7

This tutorial I have already, thx.

Btw. my link is also not… really… helpfully… just again for dynamitable things or whatever,…

What i want to do is like what the mapper(s) did in this “transmitter” map. At last you must to switch the thing there on the tower inside…

something like this but little easier I nwat too in my map…

So, … what must I do IN THE MAP-EDITOR?

:frowning:

_GD


(codejockey13) #8

go here http://webpages.charter.net/ettutorial/ and download SpeakerButton.zip. This little map and script links a button to a speaker. It will serve the same purpose you need as it calls a routine in the script to turn a speaker on or off.

In a nutshell you need to link your button to a target_script_trigger. When the button is pushed it will run the routines defined in your target_script_trigger.

Someone stated that they downloaded this one in the past and it didn’t work for them. It works on my machine so give it a go.


(general_daniel) #9

:clap: thx i will do…

btw if i only write scriptname axis_btt into the func_door, this is shown after trying to load map:

G_Script_ScriptParse(), Error (line 21) unknown event: allies_btt.

_GD


(general_daniel) #10

the toi and the cmarker are connected and the func_door ( that red button there) is conected with the target_script_trigger No other ocnnection.

only target_script_trigger has the key scriptname axis_btt

and i also only have a script game manager thing… no scriptmove ror whatever…

I watched the map with the button wich is made with script mover… and i saw something like “trigger in”… EB told something like activate…

maybe the problem is to know what is the constant for that, when u push the door ingame… :???:

i get no error again, but no wm_announce and only axis can win…


game_manager
{
	spawn
	{
	// Game rules
	wm_axis_respawntime	1
	wm_allied_respawntime	1
	wm_set_round_timelimit	40

	// Stopwatch mode defending team (0=Axis, 1=Allies)
	wm_set_defending_team	0

	// Winner on expiration of round timer (0=Axis, 1=Allies)
	wm_setwinner	0
	
	setautospawn	"Axis Spawn A" 0
	setautospawn	"Allies Spawn B" 1
	
	wait 1000
	}
} 

allies_btt 
{ 
       trigger in 
       { 
          wm_setwinner 1
          wm_announce "The Allied have pushed their button!"
       } 
}
	
axis_btt	
{ 
       trigger in 
       { 
          wm_setwinner 0
          wm_announce "The Axis have pushed their button!"
       } 
}

If my screenhsot doesnt help and the script file too, i think i must post the map file or?

cu

_GD


(EB) #11

I have an example of a setup like this in my using_paths.pk3 tutorial map. You may find it interesting.

www.spyjuice.com/ld.htm


(general_daniel) #12

:banghead:

Ok, I tried now same what is in your tutorial, EB, …

near the button i have now:


classname: func_invisible_user
target: allies_btt_trigger
cursorhint: hint_activate
(delay: 2 ) // I made one time without and then with, I thought ther emust be a wait-time like wait in trigger_multiples… but seems not so…

classname: target_script_trigger
origin: 1512 -248 272
targetname: allies_btt_trigger
scriptname: alliesBtt


(closely same for the other button…)

and this is my script now:


game_manager
{
	spawn
	{
	// Game rules
	wm_axis_respawntime	1
	wm_allied_respawntime	1
	wm_set_round_timelimit	40

	// Stopwatch mode defending team (0=Axis, 1=Allies)
	wm_set_defending_team	0

	// Winner on expiration of round timer (0=Axis, 1=Allies)
	wm_setwinner	0
	
	setautospawn	"Axis Spawn A" 0
	setautospawn	"Allies Spawn B" 1
	
	wait 1000
	}
} 

// ============================
// Allies Button
// ============================

alliesBtt
{ 
  spawn
  {
    wait 200
  }
  
  activate
  {
    trigger alliesWinSetter alliesWinning
  }
}
	
axisBtt
{
  spawn
  {
    wait 200
  }
  
  activate
  {
    trigger axisWinSetter axisWinning
  }
}

alliesWinSetter
{
  spawn
  {
    wait 200
  }
  
  trigger alliesWinning
  {
    wait 1000
    wm_setwinner 0
    wm_announce "The Allied have pushed their button!"
  }
}

axisWinSetter
{
  spawn
  {
    wait 200
  }
  
  trigger axisWinning
  {
    wait 1000
    wm_setwinner 1
    wm_announce "The Axis have pushed their button!"
  }
}

If I press the button, it seems like there is anything doing (small “lagg”), but I don’t see any text (wm_announce) and still axis will win…

ps: I tried also with hint_door and in script hint_door and only door too:

_GD


(EB) #13

Now you need to read Ifurita’s scripting tutorial. It’ll pay off for sure.


(general_daniel) #14

Ok, i read FULLY now this scripting tutorial for newbies… some things are a little bit clearer now, …

BUT!

I still need to know what event this is if a door open

so like, spawn, death and so on…

btw, EB,

I also tried to make a constructable thing … I did it 100% one to one as u did there in construct.map

After I tried to play my map I got this error:

Thx for reading and answering.

_GD


(general_daniel) #15

LOL, ouch !! :banghead: ok my mistake there with this constructible thing :smiley:

I thought it was meaning like double-door :smiley: … there “key” team— Ok I got it… I hope that if i pres now both “teams” (axis allied ^^) that both can build…

_GD


(S14Y3R) #16

Hi General, to get your button working all you should need is a func_invisible_user, a script_mover for a lever and a few lines of script.

func_invisible_user:
targetname game_button
scriptname game_button

script_mover:
targetname game_lever
scriptname game_lever

script code:

game_manager 
{ 
   spawn 
   { 
   // Game rules - yes it does.
   wm_axis_respawntime   10 
   wm_allied_respawntime   10
   wm_set_round_timelimit   30 

   // Stopwatch mode defending team (0=Axis, 1=Allies) 
   wm_set_defending_team   0 

   // Winner on expiration of round timer (0=Axis, 1=Allies) 
   //wm_setwinner   0 //set below now
    
   //setautospawn  <-null don't need if not changing spawns
    
   } 

   trigger axis_winning
   {
        wm_announce "Axis pushed the button, Allies are Slackers!"
        wait 50
        wm_setwinner 0
   }

    trigger allies_winning
   {
        wm_announce "Allies pushed the button, Axis are Slackers!"
        wait 50
        wm_setwinner 1
   }
}

//==============
//====func_invisible_user stuff=====
game_button
{
   spawn
    {
         
     }

     activate axis  //F_I_U calls this when axis activate
     {
          trigger self axis_have
      }

     activate allies
     {
          trigger self allies_have
     }

     trigger axis_have
     {
         trigger game_lever bump
         wait 50
          trigger game_manager axis_winning
     }

     trigger allies_have
     {
          trigger game_lever bump
         wait 50
          trigger game_manager allies_winning
     }
}

game_lever
{
     trigger bump //changes angle then puts it back
     {
           faceangles 0 -5 0 100 wait
          faceangles 0 0 0 100
      }
}

That should simplify things for ya. I haven’t tested it, but it should work okay. If not, keep posting :stuck_out_tongue: and we’ll try something different.


(general_daniel) #17

:clap:

Thank you very much S14Y3R !!

It works now :slight_smile:

I dunno really why but maybe… it doesnt work with a func_door or whatever…

@EB: I fixed my construct problem too :slight_smile: I think I made this mistake: writing in func_constructable track: Bunker 1 blah blah… for “you are near”… oh no just write like team like func_door ^^ what horrible combination…

ok

I fixed all now… BUT… only one think…

S14Y3R, my “button” (script_mover) Isn’t moving…
Maybe I just link my func_ionvisble_user to my door again :S I hope it works then again :smiley:

Thanks you guys :slight_smile:

ps: the pic is made without lighting compiling :stuck_out_tongue:

_GD