Me again. I asked chatgpt to tell me what could it be wrong and he fixed it.. Suffice to say, script has not been tested as my internet is still off: anyway, let me send the fixed version:
(Changes Made:
Initialized switch to 0.
Corrected the toggle logic for switch and used == for comparison.
Removed the check for NULL_KEY for strings and used "" to check if the string is empty.
Added a toggle for the switch variable after checking.)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
string daycycle_a = "3545d068-b539-4f55-9687-2d33e1762eb4";
string daycycle_b = "19d7a2a7-e10a-451f-9064-0e2f426f21f1";
integer transition = 1;
integer switch = 0; // Initialize switch to 0 or 1
default
{
state_entry()
{
llSay(PUBLIC_CHANNEL, "Touch to see osReplaceAgentEnvironment usage.");
llSay(PUBLIC_CHANNEL, "Transition: " + (string)transition + " second(s).");
}
touch_start(integer number)
{
key agentKey = llDetectedKey(0);
if (llGetAgentSize(agentKey) != ZERO_VECTOR)
{
integer result;
// Toggle switch state
if (switch == 0)
{
result = osReplaceAgentEnvironment(agentKey, transition, daycycle_a);
llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_a: " + daycycle_a);
switch = 1; // Update switch to 1
}
else
{
result = osReplaceAgentEnvironment(agentKey, transition, daycycle_b);
llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_b: " + daycycle_b);
switch = 0; // Update switch to 0
}
// Check if environment strings are empty
if (daycycle_a == "" || daycycle_b == "")
{
llRegionSayTo(agentKey, PUBLIC_CHANNEL, "The normal environment for the parcel or region has been selected.");
}
// Check result
if (result > 0)
{
llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced with success!");
}
else if (result < 0)
{
llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced without success!");
}
}
}
}
like(1)