UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Help with puzzle

broken avatar :(
Created 8 years ago
by niick555
0 Members and 1 Guest are viewing this topic.
4,198 views
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 8 June 2015
Last active: 7 years ago
Posts
38
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
niick555's Groups
niick555's Contact & Social Links
Good night, all right?
I'm doing a puzzle on my map, which will have five objects that should be activated in an order, otherwise the order is reset... Just like the map Malibu Drive makes for hulk... I need to know if the correct object was activated in the same way that the waittill("trigger") does, but need to use in an if/else... Any ideas?
Thank you!
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 3 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
Signature
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
Hold all the triggers in order in an array and thread all of them to a secondary function (with array_thread()). In that function waittill (inside a while loop) for the trigger to be triggered and notify something on the level, passing the trigger in the notify, like this:
Code Snippet
Plaintext
self waittill( "trigger" ); // can get also the player if you want and pass it to the other function
level notify( "ANY_STRING_YOU_WANT", self );
Then make a loop in the main function that will waittill that level notify and check if the trigger is the next, like:
Code Snippet
Plaintext
// triggers is your array with all the puzzle triggers in order
for( i = 0; i < triggers.size; i++ )
{
    level waittill( "ANY_STRING_YOU_WANT", trig );
    if( trig == triggers[ i ] )
    {
        // it's the correct trigger; do whatever you want here
    }
    else
    {
        i = -1;
        level notify( "puzzle_reset" ); // so you can make the secondary function wait after a trig has been triggered
    }
}
// every trigger has been activated when we're here
Haven't tested, but it might work.
Marked as best answer by niick555 8 years ago
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Possibly another solution, also not tested:

Code Snippet
Plaintext
RandomizeTriggerOrder(){
//script to randomize the order of triggers to be hit in
//thread RandomizeTriggerOrder();//thread this
ptrigs = GetEntArray( "ptrigs","targetname" );//all trigger use with same kvp ptrigs
ptrigs = array_randomize( ptrigs );
level.lastPuzzleTrig = 0;
for( i=0;i<ptrigs.size;i++ ){
ptrigs[i] thread HitMeInOrder(i,ptrigs.size);
}
}
HitMeInOrder(order,done){
self SetCursorHint( "HINT_NOICON" );
// self SetHintString( "" );
while(level.lastPuzzleTrig<done){
self waittill( "trigger", player );
if(int(order) == level.lastPuzzleTrig) level.lastPuzzleTrig++;//might not need int(order), just order (i swear it passes as a string sometimes. Maybe just when it is an attribute...)
else level.lastPuzzleTrig = 0;
wait(.1);//no spam button
}
if(order==0) thread PuzzleReward();
}
PuzzleReward(){
//replace the following with your reward
IPrintLnBold( "You go the right order, here's your reward!" );
}

To test, put as many trigger_use's as you like with targetname ptrigs in radiant
Last Edit: February 16, 2016, 07:07:24 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 8 June 2015
Last active: 7 years ago
Posts
38
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
niick555's Groups
niick555's Contact & Social Links
Hold all the triggers in order in an array and thread all of them to a secondary function (with array_thread()). In that function waittill (inside a while loop) for the trigger to be triggered and notify something on the level, passing the trigger in the notify, like this:
Code Snippet
Plaintext
self waittill( "trigger" ); // can get also the player if you want and pass it to the other function
level notify( "ANY_STRING_YOU_WANT", self );
Then make a loop in the main function that will waittill that level notify and check if the trigger is the next, like:
Code Snippet
Plaintext
// triggers is your array with all the puzzle triggers in order
for( i = 0; i < triggers.size; i++ )
{
    level waittill( "ANY_STRING_YOU_WANT", trig );
    if( trig == triggers[ i ] )
    {
        // it's the correct trigger; do whatever you want here
    }
    else
    {
        i = -1;
        level notify( "puzzle_reset" ); // so you can make the secondary function wait after a trig has been triggered
    }
}
// every trigger has been activated when we're here
Haven't tested, but it might work.

Possibly another solution, also not tested:

Code Snippet
Plaintext
RandomizeTriggerOrder(){
//script to randomize the order of triggers to be hit in
//thread RandomizeTriggerOrder();//thread this
ptrigs = GetEntArray( "ptrigs","targetname" );//all trigger use with same kvp ptrigs
ptrigs = array_randomize( ptrigs );
level.lastPuzzleTrig = 0;
for( i=0;i<ptrigs.size;i++ ){
ptrigs[i] thread HitMeInOrder(i,ptrigs.size);
}
}
HitMeInOrder(order,done){
self SetCursorHint( "HINT_NOICON" );
// self SetHintString( "" );
while(level.lastPuzzleTrig<done){
self waittill( "trigger", player );
if(int(order) == level.lastPuzzleTrig) level.lastPuzzleTrig++;//might not need int(order), just order (i swear it passes as a string sometimes. Maybe just when it is an attribute...)
else level.lastPuzzleTrig = 0;
wait(.1);//no spam button
}
if(order==0) thread PuzzleReward();
}
PuzzleReward(){
//replace the following with your reward
IPrintLnBold( "You go the right order, here's your reward!" );
}

To test, put as many trigger_use's as you like with targetname ptrigs in radiant

Thank you! Both ways work fine!
A single detail: The script MakeCents, had to change the line:

Code Snippet
Plaintext
if(order==0) thread PuzzleReward();

for:

Code Snippet
Plaintext
if(level.lastPuzzleTrig >= done) thread PuzzleReward();

Thank you so much!
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
A single detail: The script MakeCents, had to change the line:

Code Snippet
Plaintext
if(order==0) thread PuzzleReward();

for:

Code Snippet
Plaintext
if(level.lastPuzzleTrig >= done) thread PuzzleReward();

Thank you so much!

Sure thing. But... that line I had was only so it thread the reward only once. Your change would thread it for each trigger use you have, which may not be what you want. I'm not sure why it wouldn't thread with my line, but it was just meant to keep it from threading multiple times. you could change it to 1, or maybe you modified something? Doesn't really matter if you got it working, I just didn't want you to thread that reward once per trig is all.
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 8 June 2015
Last active: 7 years ago
Posts
38
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
niick555's Groups
niick555's Contact & Social Links
Sure thing. But... that line I had was only so it thread the reward only once. Your change would thread it for each trigger use you have, which may not be what you want. I'm not sure why it wouldn't thread with my line, but it was just meant to keep it from threading multiple times. you could change it to 1, or maybe you modified something? Doesn't really matter if you got it working, I just didn't want you to thread that reward once per trig is all.

I understand... But this way, I can not make the script work properly ...: \
I have a question that arose changing some code... I had to make some changes to when the puzzle is finished, change the trigger does... And for that I used flag, but when active the flag through flag_set (""), the game crashes by some 2 seconds... what could be happening? I tested put flag_set in various places in the script and keeps crashing...
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
I understand... But this way, I can not make the script work properly ...: \
I have a question that arose changing some code... I had to make some changes to when the puzzle is finished, change the trigger does... And for that I used flag, but when active the flag through flag_set (""), the game crashes by some 2 seconds... what could be happening? I tested put flag_set in various places in the script and keeps crashing...

Did you ever flag_init("flagname");

also, I think the prob with my script was it needed the int like this:

Code Snippet
Plaintext

RandomizeTriggerOrder(){
//script to randomize the order of triggers to be hit in
//thread RandomizeTriggerOrder();//thread this
ptrigs = GetEntArray( "ptrigs","targetname" );//all trigger use with same kvp ptrigs
ptrigs = array_randomize( ptrigs );
level.lastPuzzleTrig = 0;
for( i=0;i<ptrigs.size;i++ ){
ptrigs[i] thread HitMeInOrder(i,ptrigs.size);
}
}
HitMeInOrder(order,done){
self SetCursorHint( "HINT_NOICON" );
// self SetHintString( "" );
while(level.lastPuzzleTrig<done){
self waittill( "trigger", player );
if(int(order) == level.lastPuzzleTrig) level.lastPuzzleTrig++;//might not need int(order), just order (i swear it passes as a string sometimes. Maybe just when it is an attribute...)
else level.lastPuzzleTrig = 0;
wait(.1);//no spam button
}
if(int(order)==0) thread PuzzleReward();//added int
}
PuzzleReward(){
//replace the following with your reward
IPrintLnBold( "You go the right order, here's your reward!" );
}
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 8 June 2015
Last active: 7 years ago
Posts
38
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
niick555's Groups
niick555's Contact & Social Links
Did you ever flag_init("flagname");

also, I think the prob with my script was it needed the int like this:

Code Snippet
Plaintext

RandomizeTriggerOrder(){
//script to randomize the order of triggers to be hit in
//thread RandomizeTriggerOrder();//thread this
ptrigs = GetEntArray( "ptrigs","targetname" );//all trigger use with same kvp ptrigs
ptrigs = array_randomize( ptrigs );
level.lastPuzzleTrig = 0;
for( i=0;i<ptrigs.size;i++ ){
ptrigs[i] thread HitMeInOrder(i,ptrigs.size);
}
}
HitMeInOrder(order,done){
self SetCursorHint( "HINT_NOICON" );
// self SetHintString( "" );
while(level.lastPuzzleTrig<done){
self waittill( "trigger", player );
if(int(order) == level.lastPuzzleTrig) level.lastPuzzleTrig++;//might not need int(order), just order (i swear it passes as a string sometimes. Maybe just when it is an attribute...)
else level.lastPuzzleTrig = 0;
wait(.1);//no spam button
}
if(int(order)==0) thread PuzzleReward();//added int
}
PuzzleReward(){
//replace the following with your reward
IPrintLnBold( "You go the right order, here's your reward!" );
}

Oh yeah, it worked perfectly now! Thank you! About flag_init ("flagname"), I have not used... I did not know it was necessary to use... Should I use the script from the beginning, or shortly before flag_set?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Oh yeah, it worked perfectly now! Thank you! About flag_init ("flagname"), I have not used... I did not know it was necessary to use... Should I use the script from the beginning, or shortly before flag_set?

To set a flag, it needs to have it init. I'm not following you on the last part. I would init your flag either via kvp, or just manually in your function.
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 8 June 2015
Last active: 7 years ago
Posts
38
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
niick555's Groups
niick555's Contact & Social Links
To set a flag, it needs to have it init. I'm not following you on the last part. I would init your flag either via kvp, or just manually in your function.

Ah yes... Thank you for all the information! I understand better now (:

 
Loading ...