Code:
local PLUGIN = PLUGIN;
-- Called when the local player's motion blurs should be adjusted.
function PLUGIN:PlayerAdjustMotionBlurs(motionBlurs)
if ( Clockwork.Client:HasInitialized() ) then
local hunger = Clockwork.Client:GetSharedVar("hunger");
local thirst = Clockwork.Client:GetSharedVar("thirst");
local sleep = Clockwork.Client:GetSharedVar("sleep");
local data = math.max(hunger);
local data2 = math.max(thirst);
local data3 = math.max(sleep);
if (data >= 90 or data2 >= 90 or data3 >= 85) then
motionBlurs.blurTable["needs"] = 1 - ( (0.25 / 10) * ( 10 - (100 - data) ) );
end;
end;
end;
function PLUGIN:GetBars(bars)
local hunger = Clockwork.Client:GetSharedVar("hunger");
local thirst = Clockwork.Client:GetSharedVar("thirst");
local sleep = Clockwork.Client:GetSharedVar("sleep");
if (!self.hunger) then
self.hunger = hunger;
else
self.hunger = math.Approach(self.hunger, hunger, 1);
end;
if (!self.thirst) then
self.thirst = thirst;
else
self.thirst = math.Approach(self.thirst, thirst, 1);
end;
if (!self.sleep) then
self.sleep = sleep;
else
self.sleep = math.Approach(self.sleep, sleep, 1);
end;
local text,color = "Unknown", Color(255,255,255,255);
if ( thirst <= 30 ) then
text = "Hydrated";
color = Color(34,139,34,255); -- green
elseif( thirst <= 50 ) then
text = "Satisfied";
color = Color(102,255,51,255); -- lime green
elseif( thirst <= 70 ) then
text = "Thirsty";
color = Color(255,255,0,255); -- yellow
elseif( thirst <= 80 ) then
text = "Very Thirsty"; -- orange
color = Color(255,140,0,255);
elseif( thirst <= 100 ) then
text = "Dehydrated"; -- red
color = Color(255,0,0,255);
end;
if ( hunger <= 30 ) then
text = "Well Fed";
color = Color(34,139,34,255); -- green
elseif( hunger <= 50 ) then
text = "Satisfied";
color = Color(102,255,51,255); -- lime green
elseif( hunger <= 70 ) then
text = "Hungry";
color = Color(255,255,0,255); -- yellow
elseif( hunger <= 80 ) then
text = "Very Hungry"; -- orange
color = Color(255,140,0,255);
elseif( hunger <= 100 ) then
text = "Starving"; -- red
color = Color(255,0,0,255);
end;
if ( sleep <= 30 ) then
text = "Well Rested";
color = Color(34,139,34,255); -- green
elseif( sleep <= 50 ) then
text = "Rested";
color = Color(102,255,51,255); -- lime green
elseif( sleep <= 70 ) then
text = "Tired";
color = Color(255,255,0,255); -- yellow
elseif( sleep <= 80 ) then
text = "Very Tired"; -- orange
color = Color(255,140,0,255);
elseif( sleep <= 100 ) then
text = "Exhausted"; -- red
color = Color(255,0,0,255);
end;
Clockwork.bars:Add("HUNGER", color, text, self.hunger, 100, self.hunger < 90);
Clockwork.bars:Add("THIRST", color, text, self.thirst, 100, self.thirst < 90);
Clockwork.bars:Add("SLEEP", color, text, self.sleep, 100, self.sleep < 90);
end;
-- Called when the F1 Text is needed.
function PLUGIN:GetPlayerInfoText(playerInfoText)
local hunger = tonumber(Clockwork.Client:GetSharedVar("hunger"));
local thirst = tonumber(Clockwork.Client:GetSharedVar("thirst"));
local sleep = tonumber(Clockwork.Client:GetSharedVar("sleep"));
if (!self.hunger) then
self.hunger = hunger;
else
self.hunger = math.Approach(self.hunger, hunger, 1);
end;
if (!self.thirst) then
self.thirst = thirst;
else
self.thirst = math.Approach(self.thirst, thirst, 2);
end;
if (!self.sleep) then
self.sleep = sleep;
else
self.sleep = math.Approach(self.sleep, sleep, 3);
end;
local text = "Unknown";
local thirstText = "Unknown";
local sleepText = "Unknown";
if ( hunger <= 30 ) then
text = "Well Fed";
elseif( hunger <= 50 ) then
text = "Satisfied";
elseif( hunger <= 70 ) then
text = "Hungry";
elseif( hunger <= 80 ) then
text = "Very Hungry";
elseif( hunger <= 100 ) then
text = "Starving";
end;
if ( thirst <= 30 ) then
thirstText = "Hydrated";
elseif( thirst <= 50 ) then
thirstText = "Satisfied";
elseif( thirst <= 70 ) then
thirstText = "Thirsty";
elseif( thirst <= 80 ) then
thirstText = "Very Thirsty";
elseif( thirst <= 100 ) then
thirstText = "Dehydrated";
end;
if ( sleep <= 30 ) then
thirstText = "Well Rested";
elseif( sleep <= 50 ) then
thirstText = "Rested";
elseif( sleep <= 70 ) then
thirstText = "Tired";
elseif( sleep <= 80 ) then
thirstText = "Very Tired";
elseif( sleep <= 100 ) then
thirstText = "Exhausted";
end;
if (hunger > -1 or thirst > -1 or sleep > -1) then
playerInfoText:Add("Header", "[Physical Needs]");
end;
if (hunger > -1) then
playerInfoText:Add("HUNGER", "Hunger Level: "..text);
end;
if (thirst > -1) then
playerInfoText:Add("THIRST", "Thirst Level: "..thirstText);
end;
if (sleep > -1) then
playerInfoText:Add("SLEEP", "Sleep Level: "..tostring(sleep).."%");
end;
if (hunger > -1 or thirst > -1 or sleep > -1) then
playerInfoText:Add("Header2", " ");
end;
if (hunger > -1 and thirst > -1 and sleep > -1) then
playerInfoText:Add("Header3", "[Other]");
end;
end;
Any help is greatly appreciated here, thanks!