Sign in to follow this  
Followers 0
Pixel

Parameter 2 does not exist

11 posts in this topic

Never seen this error before so I don't know how to fix it. Tried googling, but the only result was foreign.

 

It's probably a mistake in this array I did, since I am still learning them, but I don't know. 

 

Console error: http://gyazo.com/c2be89561a2acaa0b2855ea2d948107c

 

Script: 

 

rotaterecttrap()
{
trigger = getent("recttrap_trig");
brush = getEntArray( "rectbrush", "targetname" );
trigger waittill("trigger");
trigger setHintString("^5>> ^3Trap Activated ^5<<");
 
for(i=0 ; i < brush.size ; i++)
{
brush[i] rotateRoll(360, 3);
brush[i] waittill("rotatedone");
wait 5;
}
 
trigger delete();
 
}
0

Share this post


Link to post
Share on other sites

you forgot

, "targetname"
in the third line of code.

Replace your code with this:

 

rotaterecttrap()
{
trigger = getent("recttrap_trig", "targetname" ); //original place of error
brush = getEntArray( "rectbrush", "targetname" );
trigger waittill("trigger");
trigger setHintString("^5>> ^3Trap Activated ^5<<");

for(i=0 ; i < brush.size ; i++)
{
brush[i] rotateRoll(360, 3);
brush[i] waittill("rotatedone");
wait 5;
}

trigger delete();

}
0

Share this post


Link to post
Share on other sites

you forgot

, "targetname"
in the third line of code.

Replace your code with this:

 

rotaterecttrap()
{
trigger = getent("recttrap_trig", "targetname" ); //original place of error
brush = getEntArray( "rectbrush", "targetname" );
trigger waittill("trigger");
trigger setHintString("^5>> ^3Trap Activated ^5<<");

for(i=0 ; i < brush.size ; i++)
{
brush[i] rotateRoll(360, 3);
brush[i] waittill("rotatedone");
wait 5;
}

trigger delete();

}

Uh, I'm an idiot, thank you. I was scripting half asleep. No wonder I missed that.

0

Share this post


Link to post
Share on other sites

What means those btw?.. I think its being used for more then 1 brush and you can place those names in 1 list etc?

0

Share this post


Link to post
Share on other sites

I dont get the point of this... I never got a clear answer from the web but cant you just use for( ;; ) instead of using arrays? I dont get the point of using arrays like that

0

Share this post


Link to post
Share on other sites

I dont get the point of this... I never got a clear answer from the web but cant you just use for( ;; ) instead of using arrays? I dont get the point of using arrays like that

for(;;) is a loop, and you can add stuff in between and after the ;; in the parentheses. They're used in most arrays, so maybe someone with more knowledge can help you further. 

0

Share this post


Link to post
Share on other sites

I dont get the point of this... I never got a clear answer from the web but cant you just use for( ;; ) instead of using arrays? I dont get the point of using arrays like that

 

Why the loop?

The reason to useis to be able to go over each individual item in the array. Using nothing would be like the following:

ents = getEntArray("brushes", "targetname");
for (;;)
  ents[ERROR: Unknown local variable] rotate(90, 1);

Since you do not know the size of the array and the current targeted item. The way you use the for is the same as a common while:

while (1);
for (;;);

Why use arrays?

 

The reason to use arrays is to reduce the amount of necessary script and to simplify. E.g.

entA = getEnt("a", "targetname");
entB = getEnt("b", "targetname");
entC = getEnt("c", "targetname");
entD = getEnt("d", "targetname");
entE = getEnt("e", "targetname");
entF = getEnt("f", "targetname");
entG = getEnt("g", "targetname");
entH = getEnt("h", "targetname");
entI = getEnt("i", "targetname");
entJ = getEnt("j", "targetname");
 
for (;;)
{
    entA rotateRoll(360, 3);
    entA waittill("rotatedone");
    wait 5;
    
    entB rotateRoll(360, 3);
    entB waittill("rotatedone");
    wait 5;
    
    entC rotateRoll(360, 3);
    entC waittill("rotatedone");
    wait 5;
    
    entD rotateRoll(360, 3);
    entD waittill("rotatedone");
    wait 5;
    
    entE rotateRoll(360, 3);
    entE waittill("rotatedone");
    wait 5;
    
    entF rotateRoll(360, 3);
    entF waittill("rotatedone");
    wait 5;
    
    entG rotateRoll(360, 3);
    entG waittill("rotatedone");
    wait 5;
    
    entH rotateRoll(360, 3);
    entH waittill("rotatedone");
    wait 5;
    
    entI rotateRoll(360, 3);
    entI waittill("rotatedone");
    wait 5;
    
    entJ rotateRoll(360, 3);
    entJ waittill("rotatedone");
    wait 5; 
}

Can be considered a huge mess, this is generally considered problematic. Imagine something like Windows being written like that, it would be unmaintainable! Or the time it would take to correct bugs as you have to replace it an X amount of times rather than just once. Using arrays it will become easier, more maintainable and less buggy guaranteed! It would become the following:

ents = getEntArray("a", "targetname");
for (i = 0; i < ents.size; i++)
{
    ents[i] rotateRoll(360, 3);
    ents[i] waittill("rotatedone");
    wait 5;    
}
0

Share this post


Link to post
Share on other sites

 

Why the loop?

The reason to useis to be able to go over each individual item in the array. Using nothing would be like the following:

ents = getEntArray("brushes", "targetname");
for (;;)
  ents[ERROR: Unknown local variable] rotate(90, 1);

Since you do not know the size of the array and the current targeted item. The way you use the for is the same as a common while:

while (1);
for (;;);

Why use arrays?

 

The reason to use arrays is to reduce the amount of necessary script and to simplify. E.g.

entA = getEnt("a", "targetname");
entB = getEnt("b", "targetname");
entC = getEnt("c", "targetname");
entD = getEnt("d", "targetname");
entE = getEnt("e", "targetname");
entF = getEnt("f", "targetname");
entG = getEnt("g", "targetname");
entH = getEnt("h", "targetname");
entI = getEnt("i", "targetname");
entJ = getEnt("j", "targetname");
 
for (;;)
{
    entA rotateRoll(360, 3);
    entA waittill("rotatedone");
    wait 5;
    
    entB rotateRoll(360, 3);
    entB waittill("rotatedone");
    wait 5;
    
    entC rotateRoll(360, 3);
    entC waittill("rotatedone");
    wait 5;
    
    entD rotateRoll(360, 3);
    entD waittill("rotatedone");
    wait 5;
    
    entE rotateRoll(360, 3);
    entE waittill("rotatedone");
    wait 5;
    
    entF rotateRoll(360, 3);
    entF waittill("rotatedone");
    wait 5;
    
    entG rotateRoll(360, 3);
    entG waittill("rotatedone");
    wait 5;
    
    entH rotateRoll(360, 3);
    entH waittill("rotatedone");
    wait 5;
    
    entI rotateRoll(360, 3);
    entI waittill("rotatedone");
    wait 5;
    
    entJ rotateRoll(360, 3);
    entJ waittill("rotatedone");
    wait 5; 
}

Can be considered a huge mess, this is generally considered problematic. Imagine something like Windows being written like that, it would be unmaintainable! Or the time it would take to correct bugs as you have to replace it an X amount of times rather than just once. Using arrays it will become easier, more maintainable and less buggy guaranteed! It would become the following:

ents = getEntArray("a", "targetname");
for (i = 0; i < ents.size; i++)
{
    ents[i] rotateRoll(360, 3);
    ents[i] waittill("rotatedone");
    wait 5;    
}

So all the brushes I want to rotate would have to be named "a"? And also if thats the case then why not name all the brushes "a" and do rotateroll function on them without using arrays? I mean I kinda get this but I doubt I do. If i dont make sense to you then you dont have to answer. :) anyways thanks for the reply I did learn from this

0

Share this post


Link to post
Share on other sites

I understand siik, I think he means why bother using arrays for a brushmodel when you can just select them all and give them all the same targetname. May be wrong here but that's what I've gathered from reading this topic.

There is no need for an array or loop when using it on a brushmodel if you are doing a simple move/delete/hide/notsolid etc. However if you want many different brushmodels to rotate around their own axis then you can use an array. As if you don't the brushes will all rotate around one axis in the middle.

For example if you want to play an effect in several places you can place many origins down in different places and use and array to get them all to play an effect. Or using getEntArray( level.player ); to see how many players there are.

I really hope this has explained it because I typed this out on my phone and it took ages (._. )

0

Share this post


Link to post
Share on other sites

Q&A @@siikdude

So all the brushes I want to rotate would have to be named "a"?
Yes, this is the case with the OP.
 
And also if thats the case then why not name all the brushes "a"...
All the brushes were already named "a"
 
...and do rotateroll function on them without using arrays?
It is impossible to rotate them WITHOUT an array. This is simply because there is no way of telling which brush is the one you want to rotate. E.g. is it "a", "a", "a", "a", "a", "a", "a", "a", "a" or "a"??
 
I mean I kinda get this but I doubt I do. If i dont make sense to you then you dont have to answer. :) anyways thanks for the reply I did learn from this
I think you may need to study loops and arrays a bit more. It would definitly clear it up.

 

Okay so here we go with a visual explenation...

 

The OP has multiple brushes that have to be moved one after another. (SB)

 

bIlIdcS.png

The above image shows the three possibilites.

 

SA

This is a single large brush. This one will rotate around its own origin(center). This one should be used in conjunction with:

sa = getEnt("A", "targetname");

But here you could ofcourse also use the array, though I would advise not to.

ents = getEntArray("A", "targetname");
assert(ents.size > 0);
sa = ents[0];

Tip: This is achieved by selecting all the pieces and turning them into a script_brushmodel all at once.

 

SB

Here you have multiple brushes with the same targetname. This can not be done with a single getEnt in the script; because it will result into an error. (Multiple brushes found with the same targetname.)

 

So the only proper way is to use the array, e.g.

ents = getEntArray("A", "targetname");
for (i = 0; i < ents.size; i++) ;

Tip: All the brushes have to be individually turned into a script_brushmodel. After that all the brushes have to be selected and should be given the same targetname. BUT be carefull to not combine them into a single large script_brushmodel. (SA) (See @@Scillman and @@Sentrex's posts.)

 

SC

Here you have multiple brushes with a different targetname. This means you can not use the array!

 

So the only way to solve this is to get all the brushes one-by-one; with cluttered script as a result. (See @@Scillman's post)

 

Tip: All the brushes have to be made individually. All the targetname's have to be set individually. (And one could expect all the brushes to have their own behavior, since they all have an unique targetname.)

0

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0