|
Re: trigger switch
[Re: mschoenhals]
#455428
10/19/15 17:56
10/19/15 17:56
|
Malice
Unregistered
|
Malice
Unregistered
|
|
|
|
Re: trigger switch
[Re: mschoenhals]
#455430
10/19/15 18:22
10/19/15 18:22
|
Malice
Unregistered
|
Malice
Unregistered
|
You need a ID skill for your switch Opps EDIT's needed EDIT 2 - Broken first IF in door action so
ENTITY* t_trigger[500]; // set a hard max and do not exceed
var trigger_ids=0;
action trigger_switch()
{
t_trigger[trigger_ids] = me; // index from 0-499
trigger_ids+=1;
my.active_tri = 0; /// active_tri must be moved to a skill not a var
......... All the rest
}
var door_ids=0;
action door_or_platform()
{
wait(3); /// or other wait to make sure level is loaded
door_ids +=1;
my.skill80 =door_ids // 1-500 this id matches t_trigger +1. so t_trigger[2] == my.skill80=3;
my.skill10 = 0;
while(1)
{
my.skill10 = t_trigger[my.skill80-1].active_tri;
if(my.skill10 == 0)
{
...move me one way
}
if(my.skill10 ==1)
{
...move me the other way
}
wait(1);
}
That should work --- But I think it's sleep time for me now.. Have fun ! Mal
Last edited by Malice; 10/19/15 18:39.
|
|
|
Re: trigger switch
[Re: ]
#455474
10/20/15 23:19
10/20/15 23:19
|
Joined: Aug 2013
Posts: 101
mschoenhals
OP
Member
|
OP
Member
Joined: Aug 2013
Posts: 101
|
Hmm, stuck again. I'm getting an error with this: I'm not sure if the variable door_ids needs to be local or global. That's my noobness showing. Any ideas on how to fix this is very appreciated! Here's what I've got so far:
ENTITY* t_switch;
ENTITY* t_trigger[100]; // set a hard max and do not exceed
var trig_percentage;
var t_switch_range = 150;
var trigger_ids=0;
action trigger_switch()
{
while (!player) {wait (1);} // wait until the player is loaded
vec_set (my.skill61, my.x); // store the xyz initial position of the switch inside skill61... 63
t_trigger = me; //this is a pointer defining the entity listed at the top
// var active_tri = 0; //variable defining where the switch is currently at.
t_trigger[trigger_ids] = me; // index from 0-499
trigger_ids+=1;
my.skill10 = 0; /// active_tri must be moved to a skill not a var
while(1)
{
c_scan(my.x, my.pan, vector(360, 180, t_switch_range), IGNORE_ME | SCAN_ENTS); // each switch scans around it, trying to detect the player
if (you) // detected an entity?
{
if (you == player) // and that entity is the player?
{
if (key_enter)
{
if(my.skill10 == 0)
{
trig_percentage =0;
while(trig_percentage < 100) //stops an infinite loop.
{
trig_percentage += 2*time_step;
ent_animate(t_switch, "on", trig_percentage, ANM_SKIP);
wait(1);
}
my.skill10 = 1;
}
else
{
trig_percentage = 0;
while(trig_percentage < 100) //stops an infinite loop.
{
trig_percentage += 2*time_step;
ent_animate(t_switch, "off", trig_percentage, ANM_SKIP);
wait(1);
}
my.skill10 = 0;
}
}
}
}
wait(1);
}
}
action door_or_platform()
{
wait(3); /// or other wait to make sure level is loaded
var door_ids;
door_ids += 1;
my.skill80 = door_ids // 1-500 this id matches t_trigger +1. so t_trigger[2] == my.skill80=3;
my.skill10 = 0;
while(1)
{
my.skill10 = t_trigger[my.skill80-1].active_tri;
if(my.skill10 == 0)
{
my.x += 25
}
if(my.skill10 == 1)
{
my.x -= 25
}
wait(1);
}
}
|
|
|
Re: trigger switch
[Re: mschoenhals]
#455475
10/20/15 23:37
10/20/15 23:37
|
Malice
Unregistered
|
Malice
Unregistered
|
Ok your error is the line before
my.skill80 = door_ids // 1-500 this id matches t_trigger +1. so t_trigger[2] == my.skill80=3;
my.skill10 = 0;
semi-colon missing
my.skill80 = door_ids;
my.skill10 = 0;
Next - Yes door_ids was place in my code above the action door but below the trigger action . Any var place out of a function is Global. Here is the thing about my code - I wrote it so you can use many doors and many triggers. However you seem to be focused on just one door/trigger. You'll have to think ahead or hack after, but you should know if you are writing one door/trigger or many doors/triggers. With just one, then the whole ids' isn't even needed. Good luck Mal EDITS - there are errors in your code - REMOVE t_trigger = me; More edits - you moved the active_tri to skill10 however you need to mod the door function. Look for a next post I'm going to edit your whole code..
Last edited by Malice; 10/20/15 23:40.
|
|
|
Re: trigger switch
[Re: mschoenhals]
#455476
10/20/15 23:46
10/20/15 23:46
|
Joined: Feb 2012
Posts: 371
Dico
Senior Member
|
Senior Member
Joined: Feb 2012
Posts: 371
|
This code not tested , so test it and tell me if it work or not:
action door()
{
while(1)
{
if(my.skill2 == 1)
{
var tmp_z = my.z + 50;
while(my.z < tmp_z)
{
my.z += 5;
wait(1);
}
my.skill2 = 2;
}
if(my.skill2 == 3)
{
var tmp_z = my.z - 50;
while(my.z > tmp_z)
{
my.z -= 5;
wait(1);
}
my.skill2 = 0;
}
wait(1);
}
}
action opener()
{
while(1)
{
c_scan(my.x, my.pan, vector(360, 180, t_switch_range), IGNORE_ME | SCAN_ENTS);
if(you)
{
if((you == player)&&(key_enter))
{
for(you = ent_next(NULL); you; you = ent_next(you))
{
if(you == door_ent)
{
if(you.skill1 == my.skill1)
{
while(!key_enter){wait(1);}
if(you.skill2 == 0)
{
var trig_percentage = 0;
while(trig_percentage < 100) //stops an infinite loop.
{
trig_percentage += 2*time_step;
ent_animate(me, "on", trig_percentage, ANM_CYCLE);
wait(1);
}
you.skill2 = 1;
}
else
{
if(you.skill2 == 2)
{
var trig_percentage =0;
while(trig_percentage < 100) //stops an infinite loop.
{
trig_percentage += 2*time_step;
ent_animate(me, "on", trig_percentage, ANM_CYCLE);
wait(1);
}
you.skill2 = 3;
}
}
}
}
}
}
}
wait(1);
}
}
to use this code , just add a door and give it action door , then add an opener for that door and give it the action opener. every door and opener have the same skill1 will be connected , i mean if door have skill1 = 1 , and the opener have in skill1 = 1 then this opener is for this door. you can add lot of doors and you can also open all door with one opener or multiple opener .
|
|
|
Re: trigger switch
[Re: ]
#455477
10/20/15 23:46
10/20/15 23:46
|
Malice
Unregistered
|
Malice
Unregistered
|
ENTITY* t_switch;
ENTITY* t_trigger[100]; // set a hard max and do not exceed
var trig_percentage;
var t_switch_range = 150;
var trigger_ids=0;
#define skill10 active_tri
action trigger_switch()
{
while (!player) {wait (1);} // wait until the player is loaded
vec_set (my.skill61, my.x); // store the xyz initial position of the switch inside skill61... 63
// REMOVED BY MAL t_trigger = me; //this is a pointer defining the entity listed at the top
// var active_tri = 0; //variable defining where the switch is currently at.
t_trigger[trigger_ids] = me; // index from 0-499
trigger_ids+=1;
my.active_tri = 0; /// active_tri must be moved to a skill not a var
while(1)
{
c_scan(my.x, my.pan, vector(360, 180, t_switch_range), IGNORE_ME | SCAN_ENTS); // each switch scans around it, trying to detect the player
if (you) // detected an entity?
{
if (you == player) // and that entity is the player?
{
if (key_enter)
{
if(my.active_tri == 0)
{
trig_percentage =0;
while(trig_percentage < 100) //stops an infinite loop.
{
trig_percentage += 2*time_step;
ent_animate(t_switch, "on", trig_percentage, ANM_SKIP);
wait(1);
}
my.active_tri = 1;
}
else
{
trig_percentage = 0;
while(trig_percentage < 100) //stops an infinite loop.
{
trig_percentage += 2*time_step;
ent_animate(t_switch, "off", trig_percentage, ANM_SKIP);
wait(1);
}
my.active_tri = 0;
}
}
}
}
wait(1);
}
}
var door_ids =0; // SET AS GLOB BY MAL
#define skill10 door_active
action door_or_platform()
{
wait(3); /// or other wait to make sure level is loaded
door_ids += 1;
my.skill80 = door_ids;// ADDED SEMI-COL MAL // 1-500 this id matches t_trigger +1. so t_trigger[2] == my.skill80=3;
my.door_active = 0;
while(1)
{
my.door_active = t_trigger[my.skill80-1].active_tri;
if(my.door_active== 0)
{
my.x += 25
}
if(my.door_active== 1)
{
my.x -= 25
}
wait(1);
}
}
Ok give it a look over and a test --- Sorry I can't test and i tend to make many minor errors. But I'll check back soon Mal
|
|
|
Re: trigger switch
[Re: ]
#455478
10/20/15 23:49
10/20/15 23:49
|
Malice
Unregistered
|
Malice
Unregistered
|
Ok use Dico's way...
Good luck have fun Mal
|
|
|
Re: trigger switch
[Re: ]
#455479
10/21/15 00:13
10/21/15 00:13
|
Malice
Unregistered
|
Malice
Unregistered
|
@Dico you have a problem with the pointer below. Only one door at a time can be held in this pointer. So regardless of the skill1 settings, this should only open one door or fail here. Because the door_ent point only holds one reference. You could use my door_ids idea with your skill1 id
ENTITY *door_ent[100];
action trigger()
{
my.skill1 =1;
..................
if(you == door_ent[my.skill1])
{
...
}
action door()
{
my.skill1 =1;
door_ent[my.skill1] = my;
............
}
Also if I follow correct,then there is no need for a second check of skill1. However if you instead use a type id
if(you.skill79 == 420)// 420 type code id for all doors
{
Then the second skill1 check can be used as you wish to open many doors. Sorry I'm just bored Mal
Last edited by Malice; 10/21/15 00:20.
|
|
|
Re: trigger switch
[Re: ]
#455480
10/21/15 00:19
10/21/15 00:19
|
Joined: Feb 2012
Posts: 371
Dico
Senior Member
|
Senior Member
Joined: Feb 2012
Posts: 371
|
hi malice , thanks for this note , but what i forget its just ENTITY* door_ent;
and for opener he will search for all doors named door_ent then it will search for its skill 1 and if this skill is the same skill that have the opener then it will open .
Last edited by Dico; 10/21/15 00:22.
|
|
|
Re: trigger switch
[Re: Dico]
#455481
10/21/15 00:21
10/21/15 00:21
|
Joined: Feb 2012
Posts: 371
Dico
Senior Member
|
Senior Member
Joined: Feb 2012
Posts: 371
|
this code is corrected for what i forget:
ENTITY* door_ent;
action door()
{
door_ent = me;
while(1)
{
if(my.skill2 == 1)
{
var tmp_z = my.z + 50;
while(my.z < tmp_z)
{
my.z += 5;
wait(1);
}
my.skill2 = 2;
}
if(my.skill2 == 3)
{
var tmp_z = my.z - 50;
while(my.z > tmp_z)
{
my.z -= 5;
wait(1);
}
my.skill2 = 0;
}
wait(1);
}
}
action opener()
{
while(1)
{
c_scan(my.x, my.pan, vector(360, 180, t_switch_range), IGNORE_ME | SCAN_ENTS);
if(you)
{
if((you == player)&&(key_enter))
{
for(you = ent_next(NULL); you; you = ent_next(you))
{
if(you == door_ent)
{
if(you.skill1 == my.skill1)
{
while(!key_enter){wait(1);}
if(you.skill2 == 0)
{
var trig_percentage = 0;
while(trig_percentage < 100) //stops an infinite loop.
{
trig_percentage += 2*time_step;
ent_animate(me, "on", trig_percentage, ANM_CYCLE);
wait(1);
}
you.skill2 = 1;
}
else
{
if(you.skill2 == 2)
{
var trig_percentage =0;
while(trig_percentage < 100) //stops an infinite loop.
{
trig_percentage += 2*time_step;
ent_animate(me, "on", trig_percentage, ANM_CYCLE);
wait(1);
}
you.skill2 = 3;
}
}
}
}
}
}
}
wait(1);
}
}
Thanks Malice
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|