Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

MSIRGB not running scrips on startup; how do I run them seperately?-FIXED WITH WORKAROUND #159

Closed
Dylan-B-Johnson opened this issue Oct 27, 2020 · 9 comments
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@Dylan-B-Johnson
Copy link

Dylan-B-Johnson commented Oct 27, 2020

Here is my Lua Lighting Script:
Lighting.SetColour(1,0,0xf,0xd) Lighting.SetColour(2,0,0xf,0xd) Lighting.SetColour(3,0,0xf,0xd) Lighting.SetColour(4,0,0xf,0xd) Lighting.SetColour(5,0,0xf,0xd) Lighting.SetColour(6,0,0xf,0xd) Lighting.SetColour(7,0,0xf,0xd) Lighting.SetColour(8,0,0xf,0xd)
Every time I wake my computer up or turn it on, my lighting gets reset to red and the script doesn't change it back to blue until I manually open up the application. I even tried setting it up so the app opens on startup, but this didn't fix it either. How can I run the .lua script by myself so that task scheduler runs it on startup?

(I have neither MSI Dragon Center nor Valorant).

@ixjf
Copy link
Owner

ixjf commented Oct 28, 2020

This is a known issue, see #116. Unfortunately, I haven’t had the time nor patience to debug this :(

@Dylan-B-Johnson
Copy link
Author

So there's no way I could make a batch file to run the script myself?

@ixjf
Copy link
Owner

ixjf commented Oct 29, 2020

No, there isn't, but you can set a timer to delay the execution of the script, or, alternatively, you can run your script in an infinite loop. That gets around the bug.

@Dylan-B-Johnson
Copy link
Author

Dylan-B-Johnson commented Oct 29, 2020

I figured out another way to solve it. I made the following batch script:

@Echo Off
timeout 6
net stop MSIRGB.ScriptService
timeout 1
net start MSIRGB.ScriptService

And then made a shortcut to run it as an admin. Then I created a task in task scheduler that ran it whenever I logged on or woke the computer up (here is how to do that).
I'll try the delay method too, that sounds more elegant; thanks for the help, and thanks for making the tool in the first place.

@Dylan-B-Johnson Dylan-B-Johnson changed the title MSIRGB not running scrips on startup; how do I run them seperately? MSIRGB not running scrips on startup; how do I run them seperately?-FIXED WITH WORKAROUND Oct 29, 2020
@Dylan-B-Johnson
Copy link
Author

I'm just going to leave this open for anyone else that has the problem.

@ixjf
Copy link
Owner

ixjf commented Oct 29, 2020

Well, yeah, you can do that too :) Thanks!

@ixjf
Copy link
Owner

ixjf commented Feb 6, 2021

As I thought, this isn't MSIRGB's fault. MSIRGB runs the script fine and the settings are applied, but something resets the chip afterwards. I have no idea what, but maybe if I can delay the start of the script service, I can avoid these problems.

@ixjf
Copy link
Owner

ixjf commented Feb 6, 2021

I guess the foolproof way would be for scripts to simply rerun the commands every second or so. Would rather not have to do that, since as little CPU time as it consumes, it's still wasted time, but that's the only foolproof way.

@ixjf
Copy link
Owner

ixjf commented Aug 23, 2021

Right, so the way I "fixed" this is by adding a Lua class Timer. Basically, just keep resetting lighting settings every X seconds. This is actually good because some other program could change the configuration at any time without MSIRGB knowing it. It's also the way Mystic Light works. For effects that already have an infinite loop (Hue Wheel, Strobe, Police Lights, Heartbeat), this wasn't an issue in the first place and you don't need to change anything. For static effects, you can do:

local Timer = require('base.timer')

Timer.Set(function()
    -- your Lighting.<something> calls
end, Timer.DefaultInterval)

where Timer.DefaultInterval is a predefined interval of 3 seconds between updates to the chip (you can use other values, but 3 s seems okay-ish in terms of performance).

It's also a good idea to have ALL Lighting calls within this function passed to Timer.Set, and otherwise for effects with an infinite loop, to have all these calls WITHIN each iteration of the loop, for the reason above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants