Scripting help :@

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

darkpheonixz4x
CJ Newbie
CJ Newbie
Posts: 51
Joined: July 2nd, 2012, 11:15 am

Scripting help :@

Post by darkpheonixz4x » July 6th, 2012, 3:14 pm

Hi, im new to scripting.
When i test my map, i receive the error "Script Compile Error: Bad Syntax {"
To be honest, i'm not sure what i've done wrong,
so if it's not too much trouble, could you please take a look at it? I really appreciate it. :)
I've attached the error and the script.
Thank you.

Code: Select all

main() 
{
        thread sound(); 
        thread door_slider (); 
} 
 
door_slider() 
{ 
        door = getent( "door", "targetname" ); 
        trig = getent( "doortrig", "targetname" ); 
 
        while(true) 
        { 
                trig waittill ( "trigger" ); 
                //wait 4; 
                door movez ( 94, 5, 0, 0.6 ); 
                door waittill ( "movedone" ); 
                wait 4; 
                //trig waittill ("trigger"); 
                door movez( -94, 4, 0, 0.6 ); 
                door waittill ( "movedone" ); { 
 
        }
 
}
 
sound()
{
 
       trig = getent("sound_activate","targetname");
 
       while(true)
       {
          trig waittill ( "trigger" );   
          musicplay ( "amb_dub" );
 
       }
 
}
 
You do not have the required permissions to view the files attached to this post.

User avatar
Opel
CJ Fan
CJ Fan
Posts: 188
Joined: September 15th, 2008, 12:28 pm
Location: Scotland

Re: Scripting help :@

Post by Opel » July 6th, 2012, 3:19 pm

Code: Select all

door waittill ( "movedone" ); { 
Remove the open bracket from this line, it's not needed.

darkpheonixz4x
CJ Newbie
CJ Newbie
Posts: 51
Joined: July 2nd, 2012, 11:15 am

Re: Scripting help :@

Post by darkpheonixz4x » July 6th, 2012, 3:24 pm

Thank you so much for your immediate reply. This fixed the Bad Syntax error.
But now i am suddenly stuck with Script Runtime Error.
Again, much help is appreciated.
Sorry for being such a newbie :P
You do not have the required permissions to view the files attached to this post.

darkpheonixz4x
CJ Newbie
CJ Newbie
Posts: 51
Joined: July 2nd, 2012, 11:15 am

Re: Scripting help :@

Post by darkpheonixz4x » July 6th, 2012, 3:36 pm

I have rechecked that my trigger is a trigger_use, and that the targetname is set to sound_activate.
Im guessing that the line trig waittill ( "trigger" ) should be set to something else. :S

darkpheonixz4x
CJ Newbie
CJ Newbie
Posts: 51
Joined: July 2nd, 2012, 11:15 am

Re: Scripting help :@

Post by darkpheonixz4x » July 6th, 2012, 3:38 pm

I mean the targetname of the door trigger is set to doortrig*

darkpheonixz4x
CJ Newbie
CJ Newbie
Posts: 51
Joined: July 2nd, 2012, 11:15 am

Re: Scripting help :@

Post by darkpheonixz4x » July 6th, 2012, 4:38 pm

Still not working! arghhhhhhh! Any help? :(

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Scripting help :@

Post by Rezil » July 6th, 2012, 4:52 pm

Try remaking the trigger as a 'trigger_use_touch' and setting the targetname to something a bit more specific. The error says that the entity you are trying to get by using getEnt does not exist so you cannot call waittill("trigger") on it.

How did you create your trigger?
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

darkpheonixz4x
CJ Newbie
CJ Newbie
Posts: 51
Joined: July 2nd, 2012, 11:15 am

Re: Scripting help :@

Post by darkpheonixz4x » July 6th, 2012, 5:04 pm

I made a brush using the trigger texture, right clicked on the 2D grid trigger>trigger_use. Then added the entities. I will redo the whole trigger and get back to you. Thank you very much for your help <3.

Vartazian
CJ Worshipper
CJ Worshipper
Posts: 286
Joined: June 10th, 2011, 9:14 pm

Re: Scripting help :@

Post by Vartazian » July 6th, 2012, 5:21 pm

out of curiosity, is this a cj map? :D

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Scripting help :@

Post by F |Madness| U » July 6th, 2012, 6:11 pm

darkpheonixz4x wrote:I mean the targetname of the door trigger is set to doortrig*
You need to define the trigger in your script, doing so by:

Code: Select all

door_trigger = getent("doortrig", "targetname");
door_trigger can be named whatever you want, just so you recognise it in your script, however where doortrig is, you replace this by the targetname of the trigger in radiant.

After that..

Code: Select all

door_trigger waittill("trigger");
should work fine
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Scripting help :@

Post by Drofder2004 » July 6th, 2012, 7:56 pm

Code is fine (without { ). the problem is the mapped entity.

Open radiant. Select the trigger.
Press 'n'. Type "targetname" in the Key box, and type "doortrig" in the value box.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Scripting help :@

Post by F |Madness| U » July 6th, 2012, 9:17 pm

KillerSam wrote:He already has that, no?
Didn't read it all or see that he already had that, was more explaining it to him in words since he said he's new to it.
-

darkpheonixz4x
CJ Newbie
CJ Newbie
Posts: 51
Joined: July 2nd, 2012, 11:15 am

Re: Scripting help :@

Post by darkpheonixz4x » July 7th, 2012, 6:29 am

Arghhhhhhh! Its still not working!

I followed what Rezil said and changed the trigger to an use_touch trigger. I also made the targetname = door_activator.
Here is my updated script.

Code: Select all

main() 
{
        thread sound(); 
	thread door_slider (); 
} 
 
door_slider() 
{ 
	door = getent( "door", "targetname" ); 
	door_trigger = getent( "door_activator", "targetname" ); 
 
	while(true) 
	{ 
		door_trigger waittill ( "trigger" ); 
		//wait 4; 
		door movez ( 94, 5, 0, 0.6 ); 
		door waittill ( "movedone" ); 
		wait 4; 
		//trig waittill ("trigger"); 
		door movez( -94, 4, 0, 0.6 ); 
		door waittill ( "movedone" ); 
 
        }

}

sound()
{

       trig = getent("sound_activate","targetname");

       while(true)
       {
          trig waittill ( "trigger" );   
          musicplay ( "amb_dub" );

       }

}

And my entities for the trigger.

Sorry for troubling y'all so much! :(
Thanks for the help. :)
You do not have the required permissions to view the files attached to this post.

darkpheonixz4x
CJ Newbie
CJ Newbie
Posts: 51
Joined: July 2nd, 2012, 11:15 am

Re: Scripting help :@

Post by darkpheonixz4x » July 7th, 2012, 6:43 am

LOL the problem was i forgot to compile the BSP.


Image


It works now. I cant thank you guys enough. Seriously, thank you sooo much <3.

darkpheonixz4x
CJ Newbie
CJ Newbie
Posts: 51
Joined: July 2nd, 2012, 11:15 am

Re: Scripting help :@

Post by darkpheonixz4x » July 7th, 2012, 3:39 pm

Man i can't catch a break :P. *new error time*

I get the following error when i activate my trigger to play my ambient track: "alias amb_dub sound mp_mymapname/myfile.wav played as an ambient/music track is not streamed; type must be streamed"
PS - the folder and file isnt actually called mp_mymapname.. i said that for reference.

Any solutions? Anything you would like to see?

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests