|
| 03 Jul 2015 12:05 PM |
local S = settings().Studio local toolbar = plugin:CreateToolbar("Time of day Script Editor") local Toggle = toolbar:CreateButton("Enable", "Enable Time of day Script Editor", "") local Options = {"Background Color", "Comment Color", "Error Color", "Keyword Color", "Number Color", "Operator Color", "Preprocessor Color", "Selection Background Color", "Selection Color", "String Color","Text Color", "Warning Color"} local Original = {["Background Color"] = Color3.new(1, 1, 1), ["Comment Color"] = Color3.new(0, 127/255, 0), ["Error Color"] = Color3.new(1, 0, 0), ["Keyword Color"] = Color3.new(0, 0, 127/255), ["Number Color"] = Color3.new(0, 127/255, 127/255), ["Operator Color"] = Color3.new(127/255, 127/255, 0), ["Preprocessor Color"] = Color3.new(127/255, 0, 0), ["Selection Background Color"] = Color3.new(110/255, 161/255, 241/255), ["Selection Color"] = Color3.new(1, 1, 1), ["String Color"] = Color3.new(127/255, 0, 127/255),["Text Color"] = Color3.new(0, 0, 0), ["Warning Color"] = Color3.new(0, 0, 1)} local Active = false
local Lighting = game.Lighting
local function C3V3(c3) return Vector3.new(c3.r, c3.g, c3.b) end
local function V3C3(v3) return Color3.new(v3.x, v3.y, v3.z) end
local function Color3Lerp(start, fin, decimal) return V3C3(C3V3(start):lerp(C3V3(fin), decimal)) end
local function GetLocalTime() local t = tick() local hour = math.floor(t/60/60%24) local minute = math.floor(t/60%60) return hour .. ":" .. minute .. ":00" end
local function GetMinutes(T) local Orig = Lighting.TimeOfDay local Minutes = nil Lighting.TimeOfDay = T Minutes = Lighting:GetMinutesAfterMidnight() Lighting.TimeOfDay = Orig return Minutes end
local function GetDecimal(minutes) return minutes < 720 and minutes/720 or (minutes-720)/720 end
local function DeterminePoints(start, fin, minutes) if minutes >= 720 then return start,fin else return fin,start end end
local function Invert(Color) return Color3.new(1 - Color.r, 1 - Color.g, 1 - Color.b) end
Toggle.Click:connect(function() Active = not Active Toggle:SetActive(Active) while Active do for i = 1,#Options do local Min = GetMinutes(GetLocalTime()) local start, fin = DeterminePoints(Original[Options[i]], Invert(Original[Options[i]]), Min) S[Options[i]] = Color3Lerp(start, fin, GetDecimal(Min)) end wait(60) end end)
Why does this plugin not properly tween the colors based on the local time of day? |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 12:06 PM |
| There are no errors, and it does change the colors of the script editor, but not the proper colors. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 12:07 PM |
| Try messing around with the numbers for the colors then? Or couldn't you do like ("Red")? |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 12:09 PM |
I think the problem is either in the function
GetDecimal
OR
DeterminePoints
But I can't be too sure. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 12:28 PM |
| Update: Another problem (aside from it not properly lerping) is that studio seems to expectantly crash? |
|
|
| Report Abuse |
|
|
| |
|
|
| 03 Jul 2015 12:49 PM |
Syntax highlighting and slightly commented version of code can be found here:
http://stackoverflow.com/questions/31212073/trying-to-tween-color3-values-based-on-local-time |
|
|
| Report Abuse |
|
|
| |
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Jul 2015 05:00 PM |
Are you seriously lerping colours?
You made it a lot more complicated than it has to be bb. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:04 PM |
How would YOU suggest doing this then?
Testing at 6:34PM gives me this: postimg.org/image/mexvle3wv Testing at 7:33PM gives me this: http://postimg.org/image/53vfipk3l
That can't be right? At 6:34PM it was barely readable.
Plus there's still the studio crash problem. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:05 PM |
| The crash is because the for loop is taking a lot of computing power. Try throwing a wait() in there. |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Jul 2015 05:06 PM |
You simple use for loops, compare the current color3 and the desired color3.
Check which of r, g, b has the greatest difference between the desired color3 values using math.max, then use that as a basis for the increment, and change the values at a rate that would match the tween time.
EZ st00f |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:12 PM |
@power This is like the 5th thing you found an error that isn't really there.
There's a wait(60)
@mycheeze Using a for loop for this literally makes no sense. Using math.max has no use in this scenario.
If you don't know what you're doing, please don't post. |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Jul 2015 05:13 PM |
| @war bb, you don't have to be such an idiot <3 |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:15 PM |
"for i = 1,#Options do local Min = GetMinutes(GetLocalTime()) local start, fin = DeterminePoints(Original[Options[i]], Invert(Original[Options[i]]), Min) S[Options[i]] = Color3Lerp(start, fin, GetDecimal(Min)) end wait(60)"
-.-
It's after the loop, the wait(60).
Make it:
for i = 1,#Options do local Min = GetMinutes(GetLocalTime()) local start, fin = DeterminePoints(Original[Options[i]], Invert(Original[Options[i]]), Min) S[Options[i]] = Color3Lerp(start, fin, GetDecimal(Min)) wait(1/30) end wait(60) |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Jul 2015 05:16 PM |
@pow, what'is with the 'wait(1/30)'
wait(1/30) and wait() r the saim fing |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:17 PM |
| Are you positive looping through all the options every 60 seconds takes up too much power? -_- |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:18 PM |
Why don't you just do something like this for getting the time?
game.Lighting:SetMinutesAfterMidnight(tick()/60) |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Jul 2015 05:18 PM |
o, u r max tweening colours based on time.
if you didn't have sucha tl;dr I would've worked hardr. kek |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:21 PM |
Getting the time is NOT the problem.
The syntax highlighting is.
Maybe the script works properly but tweening it wasn't such a good idea because the colors wouldn't always match well? |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:21 PM |
Also. Lerping takes a alpha (decimal) of 0 to 1 (in normal cases). So how about this:
alpha = tick()/60/60/24 |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:22 PM |
You do realise the for loop uses up the most computing power in your entire script?
It has to be one of the main root of the problem.
And also, I like using 1/30 because it looks better? |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:22 PM |
| If the problem is that you just dislike the colours it produces you should use HSL tweening instead of RGB tweening. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:22 PM |
| @builder That could probably severely shorten my code, rewrite the code so it uses that, maybe my math was wrong. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2015 05:23 PM |
HSL tweening? How does that work?
Anyway I gotta go for a jog so I'll brb. |
|
|
| Report Abuse |
|
|