generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Can't properly lerp these colors?

Previous Thread :: Next Thread 
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
Johnnya101 is not online. Johnnya101
Joined: 30 Dec 2012
Total Posts: 5140
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Jul 2015 12:28 PM
Update: Another problem (aside from it not properly lerping) is that studio seems to expectantly crash?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Jul 2015 12:41 PM
Help
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Jul 2015 04:58 PM
Bump.
Report Abuse
mycheeze is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Jul 2015 05:17 PM
Are you positive looping through all the options every 60 seconds takes up too much power? -_-
Report Abuse
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
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
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
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
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image