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

How do I use SetLightingState?

broken avatar :(
Created 7 years ago
by muffinmuncher115
0 Members and 1 Guest are viewing this topic.
2,678 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 2 September 2016
Last active: 6 years ago
Posts
12
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
muffinmuncher115's Contact & Social Links
Hi, I'm working on a new map and I'm having trouble using SetLightingState. Lighting states 1 and 2 are set to night, while I have lighting state 3 set to day. I'm trying to make the lighting state change to 3 with reckfullies shootable trigger script, but it doesn't seem to change. Could someone tell me how to set the map to lighting state 3 after all shootables are triggered?

Here is the code, the SetLightingState is towards the bottom.
Code Snippet
Plaintext
function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
level thread shootable_3();
}

function shootable_1()
{
    trig_1 = GetEnt("shootable_trigger_1", "targetname");
model_1 = GetEnt("shootable_model_1", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trigger_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

function shootable_3()
{
trig_3 = GetEnt("shootable_trigger_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 3 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_3 Delete();
model_3 Delete();
}

function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");
SetLightingState( 3 );
}

break;
}
}
If someone can come up with a solution, I will credit you when I release the map, thanks in advance.
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 3 years ago
Posts
306
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
Hi, I'm working on a new map and I'm having trouble using SetLightingState. Lighting states 1 and 2 are set to night, while I have lighting state 3 set to day. I'm trying to make the lighting state change to 3 with reckfullies shootable trigger script, but it doesn't seem to change. Could someone tell me how to set the map to lighting state 3 after all shootables are triggered?

Here is the code, the SetLightingState is towards the bottom.
Code Snippet
Plaintext
function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
level thread shootable_3();
}

function shootable_1()
{
    trig_1 = GetEnt("shootable_trigger_1", "targetname");
model_1 = GetEnt("shootable_model_1", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trigger_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

function shootable_3()
{
trig_3 = GetEnt("shootable_trigger_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 3 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_3 Delete();
model_3 Delete();
}

function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");
SetLightingState( 3 );
}

break;
}
}
If someone can come up with a solution, I will credit you when I release the map, thanks in advance.

The numbers for SetLightingState are messed up. I'm pretty sure 3 will set it to lighting state 2 so try using 4.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 2 September 2016
Last active: 6 years ago
Posts
12
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
muffinmuncher115's Contact & Social Links
That didn't seem to work, do you think there's anything else that would work?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 2 September 2016
Last active: 6 years ago
Posts
12
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
muffinmuncher115's Contact & Social Links
Anyone? I really dont want all of the work I put in on the lighting for both times of day to go to waste.
Marked as best answer by muffinmuncher115 7 years ago
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 3 years ago
Posts
306
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
Anyone? I really dont want all of the work I put in on the lighting for both times of day to go to waste.

Sorry about that, forgot that this wasn't the correct way to set a lighting state.

Add this to your #using section:
Code Snippet
Plaintext
#using scripts\shared\util_shared;

then change
Code Snippet
Plaintext
SetLightingState( 3 );
to
Code Snippet
Plaintext
level util::set_lighting_state(4); // If 4 doesn't work try 3 or 5.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 2 September 2016
Last active: 6 years ago
Posts
12
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
muffinmuncher115's Contact & Social Links
Thank you so much, that fixed it.

 
Loading ...