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 notify's

broken avatar :(
Created 11 years ago
by Riptide1106
0 Members and 1 Guest are viewing this topic.
3,267 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2014
Last active: 5 years ago
Posts
103
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
Signature
Dead Palace
×
Riptide1106's Groups
Riptide1106's Contact & Social Links
my problem is that my changes to my variables only remain local to individual functions. so my room_a_door_controller() function will never run. In chat it was suggested to use a notify. However i dont understand how to use them from reading the modsrepository.

Can someone help edit this and show me how a notify can achieve my desired result?



Code Snippet
Plaintext
levera1_controller()
{
levera1origin = getent("levera1origin","targetname");
levera1 = getent("levera1","targetname");
levera1trigger = getent("levera1trigger","targetname");
// level.levera1toggle
levera1 enableLinkTo();
levera1 LinkTo( levera1origin );

while(1)
{
levera1trigger waittill("trigger", player);
if (level.levera1toggle == 0)
{
levera1origin rotatePitch(-90, 1);
level.levera1toggle = 1;
iprintln("levera1toggle = 1");
wait 1;
}

levera1trigger waittill("trigger", player);
if (level.levera1toggle == 1)
{
levera1origin rotatePitch(90, 1);
level.levera1toggle = 0;
iprintln("levera1toggle = 0");
wait 1;
}
}
}

levera2_controller()
{
levera2origin = getent("levera2origin","targetname");
levera2 = getent("levera2","targetname");
levera2trigger = getent("levera2trigger","targetname");
// level.levera2toggle
levera2 enableLinkTo();
levera2 LinkTo( levera2origin );

while(1)
{
levera2trigger waittill("trigger", player);
if (level.levera2toggle == 0)
{
levera2origin rotatePitch(-90, 1);
level.levera2toggle = 1;
iprintln("levera2toggle = 1");
wait 1;
}

levera2trigger waittill("trigger", player);
if (level.levera2toggle == 1)
{
levera2origin rotatePitch(90, 1);
level.levera2toggle = 0;
iprintln("levera2toggle = 0");
wait 1;
}
}
}

room_a_door_controller()
{
doora1origin = getent("doora1origin","targetname");
doora1 = getent("doora1","targetname");
doora2origin = getent("doora2origin","targetname");
doora2 = getent("doora2","targetname");

doora1 enableLinkTo();
doora1 LinkTo( doora1origin );
doora2 enableLinkTo();
doora2 LinkTo( doora2origin );

if (level.levera1toggle == 1 && level.levera2toggle == 1) //arent being effected from previous function
{
iprintln("both toggled");
doora1origin rotateYaw(90, 1);
doora2origin rotateYaw(90, 1);
}
}
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
level.levera1toggle & level.levera2toggle are not defined

level.levera1toggle = 0;
level.levera2toggle = 0;

at the top

basically because they are undefined, I think this part is returning wrong. You can check with prints :

if (level.levera1toggle == 0)
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2014
Last active: 5 years ago
Posts
103
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
×
Riptide1106's Groups
Riptide1106's Contact & Social Links
They are already defined at the top of main(), just like that.

The variables retain their change within each controller function. im just having problems recognizing that change in other functions


level.levera1toggle & level.levera2toggle are not defined

level.levera1toggle = 0;
level.levera2toggle = 0;

at the top

basically because they are undefined, I think this part is returning wrong. You can check with prints :

if (level.levera1toggle == 0)

Last Edit: November 29, 2015, 02:04:52 am by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
They are already defined at the top of main(), just like that.

The variables retain their change within each controller function. im just having problems recognizing that change in other functions

they are stored on "level", it shouldnt matter "where" your accessing  them from

anyway, you havent actually told us what "result" you want, and by the sounds of it, havent posted the full code either

cant even see what is/isnt being threaded
Last Edit: November 29, 2015, 02:06:04 am by Harry Bo21
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet

basically because they are undefined, I think this part is returning wrong. You can check with prints :

if (level.levera1toggle == 0)

Don't you mean:

Code Snippet
Plaintext
if(!isDefined(level.levera1toggle))

? What you suggested *could* print just because the value is actually false and not because the variable is undefined.

p.s. OP, please indent your code next time. It really helps people read your scripts. Just do this:

Code Snippet
Plaintext
levera1_controller()
{
levera1origin = getent("levera1origin","targetname");
levera1 = getent("levera1","targetname");
levera1trigger = getent("levera1trigger","targetname");
// level.levera1toggle
levera1 enableLinkTo();
levera1 LinkTo( levera1origin );

while(1)
{
levera1trigger waittill("trigger", player);
if (level.levera1toggle == 0)
{
levera1origin rotatePitch(-90, 1);
level.levera1toggle = 1;
iprintln("levera1toggle = 1");
wait 1;
}

levera1trigger waittill("trigger", player);
if (level.levera1toggle == 1)
{
levera1origin rotatePitch(90, 1);
level.levera1toggle = 0;
iprintln("levera1toggle = 0");
wait 1;
}
}
}

levera2_controller()
{
levera2origin = getent("levera2origin","targetname");
levera2 = getent("levera2","targetname");
levera2trigger = getent("levera2trigger","targetname");
// level.levera2toggle
levera2 enableLinkTo();
levera2 LinkTo( levera2origin );

while(1)
{
levera2trigger waittill("trigger", player);
if (level.levera2toggle == 0)
{
levera2origin rotatePitch(-90, 1);
level.levera2toggle = 1;
iprintln("levera2toggle = 1");
wait 1;
}

levera2trigger waittill("trigger", player);
if (level.levera2toggle == 1)
{
levera2origin rotatePitch(90, 1);
level.levera2toggle = 0;
iprintln("levera2toggle = 0");
wait 1;
}
}
}

room_a_door_controller()
{
doora1origin = getent("doora1origin","targetname");
doora1 = getent("doora1","targetname");
doora2origin = getent("doora2origin","targetname");
doora2 = getent("doora2","targetname");

doora1 enableLinkTo();
doora1 LinkTo( doora1origin );
doora2 enableLinkTo();
doora2 LinkTo( doora2origin );

if(level.levera1toggle == 1 && level.levera2toggle == 1) //arent being effected from previous function
{
iprintln("both toggled");
doora1origin rotateYaw(90, 1);
doora2origin rotateYaw(90, 1);
}
}



Double Post Merge: November 29, 2015, 02:10:15 am
they are stored on "level", it shouldnt matter "where" your accessing  them from

anyway, you havent actually told us what "result" you want, and by the sounds of it, havent posted the full code either

cant even see what is/isnt being threaded

Yeah, might not have even been called.
Last Edit: November 29, 2015, 02:10:15 am by daedra descent
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
Don't you mean:

Code Snippet
Plaintext
if(!isDefined(level.levera1toggle))

? What you suggested *could* print just because the value is actually false and not because the variable is undefined.

p.s. OP, please indent your code next time. It really helps people read your scripts. Just do this:

Code Snippet
Plaintext
levera1_controller()
{
levera1origin = getent("levera1origin","targetname");
levera1 = getent("levera1","targetname");
levera1trigger = getent("levera1trigger","targetname");
// level.levera1toggle
levera1 enableLinkTo();
levera1 LinkTo( levera1origin );

while(1)
{
levera1trigger waittill("trigger", player);
if (level.levera1toggle == 0)
{
levera1origin rotatePitch(-90, 1);
level.levera1toggle = 1;
iprintln("levera1toggle = 1");
wait 1;
}

levera1trigger waittill("trigger", player);
if (level.levera1toggle == 1)
{
levera1origin rotatePitch(90, 1);
level.levera1toggle = 0;
iprintln("levera1toggle = 0");
wait 1;
}
}
}

levera2_controller()
{
levera2origin = getent("levera2origin","targetname");
levera2 = getent("levera2","targetname");
levera2trigger = getent("levera2trigger","targetname");
// level.levera2toggle
levera2 enableLinkTo();
levera2 LinkTo( levera2origin );

while(1)
{
levera2trigger waittill("trigger", player);
if (level.levera2toggle == 0)
{
levera2origin rotatePitch(-90, 1);
level.levera2toggle = 1;
iprintln("levera2toggle = 1");
wait 1;
}

levera2trigger waittill("trigger", player);
if (level.levera2toggle == 1)
{
levera2origin rotatePitch(90, 1);
level.levera2toggle = 0;
iprintln("levera2toggle = 0");
wait 1;
}
}
}

room_a_door_controller()
{
doora1origin = getent("doora1origin","targetname");
doora1 = getent("doora1","targetname");
doora2origin = getent("doora2origin","targetname");
doora2 = getent("doora2","targetname");

doora1 enableLinkTo();
doora1 LinkTo( doora1origin );
doora2 enableLinkTo();
doora2 LinkTo( doora2origin );

if(level.levera1toggle == 1 && level.levera2toggle == 1) //arent being effected from previous function
{
iprintln("both toggled");
doora1origin rotateYaw(90, 1);
doora2origin rotateYaw(90, 1);
}
}



Double Post Merge: November 29, 2015, 02:10:15 am
Yeah, might not have even been called.

Actually i was just pointing out the particular line i supected may be failing ( that was from his code ), i did not give a example or solution, just a theory ;)
Last Edit: November 29, 2015, 02:24:48 am by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2014
Last active: 5 years ago
Posts
103
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
×
Riptide1106's Groups
Riptide1106's Contact & Social Links
i have two doors and two switches. i want both doors to open only after both switches are switched. Currently the switches rotate correctly (back and forth) which leads me to believe the variables are being switched and maintained within the lever functions as desired. However when both switches are "on" the doors do not open. That is what is leading me to believe the varaibles use in the door_controller function are being read purely from the declaration in main(), not from the manipulation from the lever functions.

here is an image from radiant to help picture:



ps. thank you for trying to help me with this =)
Marked as best answer by Riptide1106 11 years ago
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Well, if there is nothing to pause the script before
Code Snippet
Plaintext
room_a_door_controller()
is called then it'll just run through and nothing will happen.

Does running a while loop like this help any?

Code Snippet
Plaintext
room_a_door_controller()
{
doora1origin = getent("doora1origin","targetname");
doora1 = getent("doora1","targetname");
doora2origin = getent("doora2origin","targetname");
doora2 = getent("doora2","targetname");

doora1 enableLinkTo();
doora1 LinkTo( doora1origin );
doora2 enableLinkTo();
doora2 LinkTo( doora2origin );

while(1)
{
if(level.levera1toggle == 1 && level.levera2toggle == 1) //arent being effected from previous function
{
iprintln("both toggled");
doora1origin rotateYaw(90, 1);
doora2origin rotateYaw(90, 1);
}
wait(.005);
}
}

Otherwise it isn't getting called.

AFAIK, this why you should be using developer mode. It'd give you a better idea of whats going on than we can, since your not posting the full code.
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
also to answer your original question about "how do i use notifys"

Code Snippet
Plaintext
level thread my_function();

my_function()
{
    level waittill( "this_notify" ); // anything below this wont happen until the notify

    iPrintLnBold( "Your notify happened" );
}
// then in some other function elsewhere :

Code Snippet
Plaintext
level notify( "this_notify" );


That is global, but you can also notify specific entities

Code Snippet
Plaintext
players = get_players();
players[ 0 ] thread my_function();

my_function()
{
    self waittill( "player_notified" ); // anything below this wont happen until the notify

    iPrintLnBold( "Player was notified" );
}

then in some other function elsewhere - a function referencing the player we used in the example before :

Code Snippet
Plaintext
self notify( "player_notified" );




Global you would use if its something ambiguous that only really needs one generic notify ( for example, turning power on - although treyarch used a flag for this ), you would use the entitiy notify type for multiple instances of things, using the same notifies ( eg, dig sites that can all be "dug", may all use self notify( "dug" ) for example )
Last Edit: November 29, 2015, 02:53:33 am by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2014
Last active: 5 years ago
Posts
103
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
×
Riptide1106's Groups
Riptide1106's Contact & Social Links
Yes the while loop fixed it! (i tried one earlier and no dice. prolly cause i put the wait in the wrong spot) Thanks. I did make it so it doesnt revole the whole time. But i am really grateful for everyone's help!

You Guys are Awesome!



Well, if there is nothing to pause the script before
Code Snippet
Plaintext
room_a_door_controller()
is called then it'll just run through and nothing will happen.

Does running a while loop like this help any?

Code Snippet
Plaintext
room_a_door_controller()
{
doora1origin = getent("doora1origin","targetname");
doora1 = getent("doora1","targetname");
doora2origin = getent("doora2origin","targetname");
doora2 = getent("doora2","targetname");

doora1 enableLinkTo();
doora1 LinkTo( doora1origin );
doora2 enableLinkTo();
doora2 LinkTo( doora2origin );

while(1)
{
if(level.levera1toggle == 1 && level.levera2toggle == 1) //arent being effected from previous function
{
iprintln("both toggled");
doora1origin rotateYaw(90, 1);
doora2origin rotateYaw(90, 1);
}
wait(.005);
}
}

Otherwise it isn't getting called.

AFAIK, this why you should be using developer mode. It'd give you a better idea of whats going on than we can, since your not posting the full code.
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
mark the best answer

 
Loading ...