Rainbow Memrec Coloring

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
User avatar
EpicBirdi
Fearless Donors
Fearless Donors
Posts: 64
Joined: Sat Jul 21, 2018 2:22 pm
Reputation: 58

Rainbow Memrec Coloring

Post by EpicBirdi »

I'm trying to create a lua function that will cycle the color of a memrec through a rainbow gradient, and I'm certain I'm close to success here, but I feel like my math is off or something.. it continues flashing to incorrect colors randomly but otherwise works as it should.

If somebody could help I'd greatly appreciate it. Attached is my demo table, comments included for every script. Table's lua script needs to run to function. There's a commented-out debug print where the color is generated in the main lua.

The color is determined by combining three out-of-phase sinewaves and combining them as RGB.
Image
LuaColorCycle.CT
(11.55 KiB) Downloaded 116 times

aSwedishMagyar
Table Makers
Table Makers
Posts: 670
Joined: Mon Jul 06, 2020 3:19 am
Reputation: 1188

Re: Rainbow Memrec Coloring

Post by aSwedishMagyar »

I suspect it's an issue with your biasing. When it suddenly flashes to another color you can assume that the value wrapped around to 257 or -1.

Here's what I came up with that seems to work ok:
Attachments
colorChanger.CT
(6.55 KiB) Downloaded 134 times
Last edited by aSwedishMagyar on Tue Aug 10, 2021 1:18 am, edited 1 time in total.

User avatar
EpicBirdi
Fearless Donors
Fearless Donors
Posts: 64
Joined: Sat Jul 21, 2018 2:22 pm
Reputation: 58

Re: Rainbow Memrec Coloring

Post by EpicBirdi »

Yours works perfectly, thanks a million for the help!
I'll have to see what I can change in mine, or simply adapt yours a bit.. using it as a way to highlight things for a tutorial script lol.
Is there a particular reason you're using n×pi/4 as phases versus their closest counterparts? I couldn't notice much of a difference, but I'd like to know what you think on it.

aSwedishMagyar
Table Makers
Table Makers
Posts: 670
Joined: Mon Jul 06, 2020 3:19 am
Reputation: 1188

Re: Rainbow Memrec Coloring

Post by aSwedishMagyar »

EpicBirdi wrote:
Tue Aug 10, 2021 1:16 am
Yours works perfectly, thanks a million for the help!
I'll have to see what I can change in mine, or simply adapt yours a bit.. using it as a way to highlight things for a tutorial script lol.
Is there a particular reason you're using n×pi/4 as phases versus their closest counterparts? I couldn't notice much of a difference, but I'd like to know what you think on it.
It's mostly just because that's how I think of phase offsets with radians..

I modified that script to also have a background function so you can really see the difference since I can't really tell with the small text on the records.

Oh and the transition will be less choppy if you change the update timer:

Code: Select all

local upTimer = getUpdateTimer()
upTimer.SetInterval(1)

Post Reply

Who is online

Users browsing this forum: No registered users