How can i use a trigger for Moving between scriptpoints?

Topics regarding Scripting with Reality Factory
Post Reply
Veleran
Posts: 903
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

How can i use a trigger for Moving between scriptpoints?

Post by Veleran »

I have a world trigger model,and i want every time someone collides the trigger model and the trigger goes on,
a pawn script to use the trigger name to move from scriptpoint1 to scriptpoint2.

{
Spawn[ ()
{
Console(true);
BoxWidth(30); // set bounding box width/depth
Gravity(false);
NewOrder("Unpressed");
} ]

Unpressed[ ()
{
NewPoint("Plate1_point_1");
MoveToPoint("Idle", 60, "");
SetEventState("Plate_1_pressed", false);
AddTriggerOrder("Pressed", "Pressure_plate_1_Trigger", 0);
} ]

Pressed[ ()
{
NewPoint("Plate1_point_2");
MoveToPoint("Idle", 60, "");
SetEventState("Plate_1_pressed", true);
NewOrder("Waitpressed");
} ]

Waitpressed[ ()
{
DelTriggerOrder("Pressed", "Pressure_plate_1_Trigger", 0);
} ]

}
I can move the plate down to point2 when the trigger goes on,but i cant know when the trigger is off,and move back the pawn back to scriptpoint1.
Does anyone know what i can add to the Waitpressed order to know that the trigger is off,
so the plate pawn will move back to scriptpoint_1?
Veleran
Posts: 903
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Post by Veleran »

I replaced the pawn with a trigger model and aded an electric bolt above it to show the activation.
I still need a pawn that fist will check which plate triggers are active,to activate a door open.
I wanted to know what exactly i must type the list of triggers,and with what between the 4 trigger names?
-space,a #,or something:

AddTriggerOrder("Door_1_open", "Plate1trigger-Plate2trigger-Plate3trigger-Plate4trigger", 0);
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

I would use GetEventState() here.
It returns the state of a trigger.

So in the script it would be something like:

Code: Select all

if(GetEventState("Plate1trigger") and GetEventState("Plate2trigger") ... )
{
      // Do your magic
}
Pain is only psychological.
Veleran
Posts: 903
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Post by Veleran »

AddTriggerOrder(char *Order, char *Trigger, float Time );

Add to list of triggers being checked by the Pawn a trigger called Trigger. When the state of this trigger goes to on the Script Order called Order will be executed by this Pawn. If Time is greater than 0 then the Script Order will wait this number of seconds before being executed. When the trigger goes on it is removed from the list of active triggers. Any number of triggers can be added to the trigger list of a Pawn.
This is what the manual says,and its about multible triggers.
Pickles has this on a landmine script in athe ogre demo:
AddTriggerOrder("RemoveIt",self.EntityName # "Trig",0.1);
Whats this -self.EntityName # in the name of the trigger?

About the example you gave:
I m not sure what to write.Would this work?
if(GetEventState("Plate1trigger") and GetEventState("Plate2trigger") and GetEventState("Plate5trigger") and GetEventState("Statue1trigger")
{
SetEventState("Level_exit_open", true);
}
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

Veleran wrote:
AddTriggerOrder("RemoveIt",self.EntityName # "Trig",0.1);
Whats this -self.EntityName # in the name of the trigger?
Ohh, I didn't know it can be used like that! Cool!
Sorry, it's definately easier to do it like Pickles.

'self.EntityName' is the name of the pawn, but basically it is used as a trigger name in that.
# is a symbol that tells the engine that multiple triggers must be activated. It's like a '+'.

So it should be possible to use the command like this:

AddTriggerOrder("Door_1_open", "Plate1trigger" # "Plate2trigger" # "Plate3trigger" # "Plate4trigger", 0);
Pain is only psychological.
User avatar
QuestOfDreams
Site Admin
Posts: 1525
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

No, no, stop it!
AddTriggerOrder(char *Order, char *Trigger, float Time );

Add to list of triggers being checked by the Pawn a trigger called Trigger. When the state of this trigger goes to on the Script Order called Order will be executed by this Pawn. If Time is greater than 0 then the Script Order will wait this number of seconds before being executed. When the trigger goes on it is removed from the list of active triggers. Any number of triggers can be added to the trigger list of a Pawn.


This is what the manual says,and its about multible triggers.
Yes, a pawn has a list of triggers that it checks, but you add only 1 trigger at a time to this list with the AddTriggerOrder command (the triggers are not related to each other).

Pickles has this on a landmine script in athe ogre demo:
AddTriggerOrder("RemoveIt",self.EntityName # "Trig",0.1);
Whats this -self.EntityName # in the name of the trigger?
Let's have a look at the manual:
self.EntityName
This is a read-only variable which contains the szEntityName of the Pawn entity. It can be used to generate unique trigger names from a script that is being used by multiple Pawns.
and this is exactly what is done here: self.EntityName # "Trig" is the (Simkin syntax for the) concatenation of 2 strings (eg "Pawn1" # "Trig" results in "Pawn1Trig")


A possible way would be to check each trigger using the GetEventState command

Code: Select all

if(GetEventState("Plate1trigger") and GetEventState("Plate2trigger") and GetEventState("Plate5trigger") and GetEventState("Statue1trigger") )
{ 
    SetEventState("Level_exit_open", true); 
}
You may also use some LogicGate entities (Type 0 AND) in your level so you only have to check for the final LogicGate state in the script
example:
if Plate1trigger is on AND Plate2trigger is on then LogicGate1 would be on
if Plate5trigger is on AND Statue1trigger is on then LogicGate2 would be on
if LogicGate1 is on AND LogicGate2 is on then LogicGate3 would be on
-> check the state of LogicGate3 in the script
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

Oh, right, I'm sorry. I'm confusing people again. :oops:

Now that I think of it, yeah, I've used the concetenation in my scripts too.


Veleran, just forget everything I have said and listen to QoD. :)
Pain is only psychological.
Veleran
Posts: 903
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Post by Veleran »

I did nt read carefully the manual because i saved my strenght for making textures,animation etc.
Thats why i did nt remember that the # was the name of a pawn as a trigger-the post about it was back in dairyman's days-when i knew even less about the commands.

Anyway-i was going the easy way with the logic gates.
I still want to know the exact syntax for the GetEventState although i wont use it for opening doors by activating quest objects
is this the right syntax?i dont know yet whats the one
)
or two
))
etc.

if(GetEventState("Blue_gem") )
{
SetEventState("magic_mouth_speak", true);
}
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

From the 'Simkin Script Grammar'
"if" "(" <expression> ")" <compound_statement>
So the syntax for an if-statement is

Code: Select all

if( <expression> )
{
    <statement>
}

Basically, the command is

Code: Select all

GetEventState("TRIGGER");
But when used with 'if' it loses the ';' and becomes

Code: Select all

if(GetEventState("TRIGGER"))
{
     Your stuff here...
}

if(GetEventState("Blue_gem"))
{
SetEventState("magic_mouth_speak", true);
}
Yes, that's correct
Pain is only psychological.
Post Reply