Ok folks, I feel like this should be an easy one, but I'm trying to work out the best way to do this and getting myself in a muddle.
I've got several instances of an object, and I want them all to run a simple piece of code at a specific time. I want this to be triggered from another object, but I'm not sure how best to do this. I hope this makes sense.
To go into more detail about what I'm doing: I have a queue of customers who will sometimes choose to leave. When one leaves, I want all of the other customers to realise that and take appropriate action (ie: move forwards if the person leaving was in front of them). So ideally I want that person to shout out "I'm leaving, and I was in position 4", and for all the other customers to be listening out for that shout. They will then check if their position is greater than 4, and move forward appropriately.
Many thanks.
Simple trigger question.
Started by Bglamb, Jul 12 2012 01:15 PM
3 replies to this topic
#1
Posted 12 July 2012 - 01:15 PM
#2
Posted 12 July 2012 - 01:17 PM
You're probably looking for with. Pseudo-code example:
if (the_customer_leaves) {
with (obj_customer) {
if (position > 4) move_forward_appropriately();
}
}
#3
Posted 12 July 2012 - 01:23 PM
Use "with" and "other", they are so d*mn usefull it's unbelivable.
By using "with" followed by the name of the object (or instance id) you can execute code with ALL the instances of that object.
With "other" you can get values from the instance that called the "with".
Example, obj_ctrl will tell obj_customer to move forward IF they have a larger "queue value" then the customer who left:
By using "with" followed by the name of the object (or instance id) you can execute code with ALL the instances of that object.
With "other" you can get values from the instance that called the "with".
Example, obj_ctrl will tell obj_customer to move forward IF they have a larger "queue value" then the customer who left:
queue_left = 5
with obj_customer
{
if queue_value > other.queue_left
{
queue_value -= 1
//move forward
}
}
Edited by filulilus, 12 July 2012 - 01:24 PM.
#4
Posted 12 July 2012 - 02:07 PM
Aha, I knew it would be simple.
That's superb. Thanks to you both!
That's superb. Thanks to you both!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











