-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.cs
95 lines (81 loc) · 3.65 KB
/
package.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// --- Package
//This package allows:
//- Starting and stopping the time tick
//- Nabbing events as they are added and adding them to an array
//%this is the client.
package dayCycleTimePackage
{
function serverCmdEnvGui_SetVar(%this, %variable, %value) // Client that triggered, variable modified, new value
{
if(%variable $= "DayCycleEnabled") //Unfortunately, it doesn't work properly.
{
if(%value) //if the boolean in %value is true...
{
$DayCycles::Enabled = 1;
startDayCycleTimeTick(); //start.
DayCyclesDebug("Starting DayCycle TimeTick at length:" SPC DayCycle.dayLength);
}
else //if the boolean in %value is false...
{
$DayCycles::Enabled = 0; //as of V7 this will actually have the right number in it. why the hell was there a 2 here?
stopDayCycleTimeTick(); //stop.
DayCyclesDebug("Stopping DayCycle TimeTick.");
}
}
if(%variable $= "DayLength" && $DayCycles::Enabled) //catch when the nooby client goes and changes the time on us.
{
startDayCycleTimeTick(); //not starting, updating.
DayCyclesDebug("Updating DayCycle TimeTick with new length:" SPC %value);
}
return parent::serverCmdEnvGui_SetVar(%this, %variable, %value);
}
//everything pertaining to events in this package is credit to Mold. Thanks Mold!
//We have to add the brick to list when the event is added to a brick
function serverCmdAddEvent(%this, %delay, %input, %target, %a, %b, %output, %par1, %par2, %par3, %par4)
{
%i1 = inputEvent_GetInputEventIdx("dayCycleOnDawn"); // Forgot to change these in V6. Oops.
%i2 = inputEvent_GetInputEventIdx("dayCycleOnNoon");
%i3 = inputEvent_GetInputEventIdx("dayCycleOnDusk");
%i4 = inputEvent_GetInputEventIdx("dayCycleOnMidnight");
if(%input == %i1 || %input == %i2 || %input == %i3 || %input == %i4) // Made it nicer just for Mold.
{
$DayCycleBrickList = addItemToList($DayCycleBrickList, %this.wrenchBrick);
DayCyclesDebug("Adding brick to event list:" @ %this.wrenchBrick);
}
return parent::serverCmdAddEvent(%this, %delay, %input, %target, %a, %b, %output, %par1, %par2, %par3, %par4);
}
function fxDtsBrick::addEvent(%this, %delay, %input, %target, %a, %b, %output, %par1, %par2, %par3, %par4)
{
%i1 = inputEvent_GetInputEventIdx("dayCycleOnDawn"); // Forgot to change these in V6. Oops.
%i2 = inputEvent_GetInputEventIdx("dayCycleOnNoon");
%i3 = inputEvent_GetInputEventIdx("dayCycleOnDusk");
%i4 = inputEvent_GetInputEventIdx("dayCycleOnMidnight");
if(%input == %i1 || %input == %i2 || %input == %i3 || %input == %i4) // Made it nicer just for Mold.
{
$DayCycleBrickList = addItemToList($DayCycleBrickList, %this.wrenchBrick);
DayCyclesDebug("Adding brick to event list:" @ %this.wrenchBrick);
}
return parent::addEvent(%this, %delay, %input, %target, %a, %b, %output, %par1, %par2, %par3, %par4);
}
//We have to remove the brick from list when the event is removed from a brick
function serverCmdClearEvents(%this)
{
if(hasItemOnList($DayCycleBrickList, %this.wrenchBrick))
{
$DayCycleBrickList = removeItemFromList($DayCycleBrickList, %this.wrenchBrick);
DayCyclesDebug("Removing brick from event list:" @ %this.wrenchBrick);
}
parent::serverCmdClearEvents(%this);
}
function fxDtsBrick::onRemove(%brick) // thanks nullable
{
if(hasItemOnList($DayCycleBrickList, %brick))
{
$DayCycleBrickList = removeItemFromList($DayCycleBrickList, %brick);
DayCyclesDebug("Removing brick from event list:" @ %brick);
}
parent::onRemove(%brick);
}
//everything pertaining to events in this package is credit to Mold.
};
activatePackage("dayCycleTimePackage");