PDA

View Full Version : Triggers place...



Moczulak
11th January 2013, 10:31
Hey i have problem ,i write this script and if several items that trigger works only one.
I use this table:


level.burntriggers = [];
level.burntriggers[0] = SpawnStruct();
level.burntriggers[0].origin = (-2806,1874,25);
level.burntriggers[0].radius = 40;
level.burntriggers[0].height = 72;

level.burntriggers[1] = SpawnStruct();
level.burntriggers[1].origin = (-2950,1915,25);
level.burntriggers[1].radius = 40;
level.burntriggers[1].height = 72;

level.burntriggers[2] = SpawnStruct();
level.burntriggers[2].origin = (-2857,1880,25);
level.burntriggers[2].radius = 40;
level.burntriggers[2].height = 72;

level.burntriggers[3] = SpawnStruct();
level.burntriggers[3].origin = (-3020,1870,25);
level.burntriggers[3].radius = 40;
level.burntriggers[3].height = 72;

Work only one table... :( Please help me.


placeTriggers()
{
for(i = 0; i < level.burntriggers.size; i++)
{
trig = spawn("trigger_radius", level.burntriggers[i].origin, 0, level.burntriggers[i].radius, level.burntriggers[i].height);

while(1)
{
trig waittill("trigger", player);

if(player istouching(trig))
{
player iprintlnbold("1");
}
}
}
}

kung foo man
11th January 2013, 10:37
Did you tried it this way?




triggerThink()
{
player = self;
player iprintlnbold("1");
}

placeTriggers()
{
for(i = 0; i < level.burntriggers.size; i++)
{
trig = spawn("trigger_radius", level.burntriggers[i].origin, 0, level.burntriggers[i].radius, level.burntriggers[i].height);

while(1)
{
trig waittill("trigger", player);
player thread triggerThink();
}
}
}


(its a scripting question, so it belongs into the scripting section)

Moczulak
11th January 2013, 11:03
My problem is that the script reads the first table, one of the four tables, other tables are not loaded :(

kung foo man
11th January 2013, 11:10
Ah, didnt understood first time:




triggerThink()
{
while(1)
{
trig waittill("trigger", player);
player iprintlnbold("1");
}
}

placeTriggers()
{
for(i = 0; i < level.burntriggers.size; i++)
{
trig = spawn("trigger_radius", level.burntriggers[i].origin, 0, level.burntriggers[i].radius, level.burntriggers[i].height);
thread triggerThink();
}
}

Moczulak
11th January 2013, 11:37
It works ,thanks man! :)

Mitch
12th January 2013, 19:37
Hey i have problem ,i write this script and if several items that trigger works only one.
I use this table:
(see below)

Work only one table... :( Please help me.



Your script keeps waiting until it gets triggered and it also loops the first trigger. You need to add a thread after you spawn the trigger.


placeTriggers()
{
for(i = 0; i < level.burntriggers.size; i++)
{
trig = spawn("trigger_radius", level.burntriggers[i].origin, 0, level.burntriggers[i].radius, level.burntriggers[i].height);

while(1)
{
trig waittill("trigger", player);

if(player istouching(trig))
{
player iprintlnbold("1");
}
}

// the script never comes here
// so can never spawn the second trigger
}
}

Tally
12th January 2013, 20:38
Your script keeps waiting until it gets triggered and it also loops the first trigger. You need to add a thread after you spawn the trigger.


placeTriggers()
{
for(i = 0; i < level.burntriggers.size; i++)
{
trig = spawn("trigger_radius", level.burntriggers[i].origin, 0, level.burntriggers[i].radius, level.burntriggers[i].height);

while(1)
{
trig waittill("trigger", player);

if(player istouching(trig))
{
player iprintlnbold("1");
}
}

// the script never comes here
// so can never spawn the second trigger
}
}

Did you not see the reply Kung gave? It produced this result:


It works ,thanks man! :)

Try not to be redundant. Always strive to be relevant.

Mitch
12th January 2013, 21:06
Did you not see the reply Kung gave? It produced this result:



Try not to be redundant. Always strive to be relevant.
I saw it too late.