Ludeon Forums

RimWorld => Mods => Topic started by: merthsoft on September 26, 2016, 01:26:43 PM

Title: Timer Switches
Post by: merthsoft on September 26, 2016, 01:26:43 PM
Hello, I've started working on a mod for timer switches, and wanted to see if one already existed. I've searched but the closest I've found is one that adds pretty advanced switches, including one that has a timer, but it's not as fine-grained as my idea. My idea is for it to work like the Restrictions tab, where you can set on or off for each hour. Does something like that exist? Would other people be interested?
Title: Re: Timer Switches
Post by: Dingo on September 26, 2016, 01:28:02 PM
I was looking for a mod like this ever since Day/Night Switches gained popularity. Sometimes you want fine control over those things, and an interface similar to the Restrict tab would be ideal.

I don't think one exists right now, it would be very much welcome.
Title: Re: Timer Switches
Post by: merthsoft on September 26, 2016, 01:44:48 PM
Cool--I'll keep working on it then and keep you updated!
Title: Re: Timer Switches
Post by: gillsminnow on September 26, 2016, 05:11:24 PM
I'd be interested in a simple timer switch.
Title: Re: Timer Switches
Post by: harpo99999 on September 27, 2016, 05:42:18 AM
have you seen the haplo's power switch mod? it has  timer, pawn on room, pawn nearby functionality, and has even partly entered into the base game (just not the extra modes eg timer pawn in room & pawn nearby)
Title: Re: Timer Switches
Post by: merthsoft on September 27, 2016, 03:20:15 PM
I have! And I quite like it, but the interface for the timers is a little clunky. My hope is that we'll be able to combine them and mine can just be absorbed into his.
Title: Re: Timer Switches
Post by: merthsoft on September 27, 2016, 08:09:44 PM
Progress is progressing! http://i.imgur.com/lQ4bX9v.gifv (http://i.imgur.com/lQ4bX9v.gifv)

Sorry for the weird green stuff--not sure what's going on there and I didn't feel like re-recording. Still needs lots of work, but jsut wanted to show something off.
Title: Re: Timer Switches
Post by: Dingo on September 27, 2016, 08:22:42 PM
Just a small suggestion: "timer" switch implies that the switch counts down X amount of ticks/hours and shuts itself off (which is what a timer is, it starts from 100% and goes to 0%). You could say these are time-sensitive switches or something like that.

I actually didn't know about Haplo's mod before, shucks. If you can implement this in a way that works alongside (or even merges into) his mod that would be great.
Title: Re: Timer Switches
Post by: merthsoft on September 27, 2016, 08:25:57 PM
It'll definitely work with his, and hopefully just work together. Good idea on the naming--I'll probably implement both things, too.
Title: Re: Timer Switches
Post by: merthsoft on September 30, 2016, 06:14:50 PM
(http://i.imgur.com/IrpjlsV.jpg)

Some progress. You can assign the times and everything. It's not fully functional yet, but it's coming along!
Title: Re: Timer Switches
Post by: merthsoft on October 01, 2016, 11:14:24 PM
Alright! I've got a first release for you guys if you want to test it out!
Download Link (http://merthsoft.com/TimerSwitches.zip)
(http://i.imgur.com/i1Ote35.png)

Let me know what you think!
Title: Re: Timer Switches
Post by: Dingo on October 02, 2016, 06:34:50 AM
Looks really nice. I looked at it in-game, very slick. My only question is why the font on the On/Off designators looks so weird.
Title: Re: Timer Switches
Post by: merthsoft on October 02, 2016, 10:31:12 AM
Oh, yeah, it does that when you call the translate method on it--I'm not sure why. I'll change that so it's not making it weird.
Title: Re: Timer Switches
Post by: avilmask on October 04, 2016, 02:36:40 PM
Your mod works good, except one thing - switches reset when loading a game from save.
Ability to disable sun lamps at "resting" hours so good!
Title: Re: Timer Switches
Post by: BlackSmokeDMax on October 04, 2016, 02:45:26 PM
Quote from: avilmask on October 04, 2016, 02:36:40 PM
Your mod works good, except one thing - switches reset when loading a game from save.
Ability to disable sun lamps at "resting" hours so good!

Are there concrete resting hours, or does that change per latitude? If they don't vary, it'd be nice if there was a pre-set button for those hours.
Title: Re: Timer Switches
Post by: RemingtonRyder on October 04, 2016, 02:47:20 PM
Yes, the resting hours are fixed. There's actually a Day/Night switch mod designed with sun lamps in mind, btw.
Title: Re: Timer Switches
Post by: BlackSmokeDMax on October 04, 2016, 03:11:54 PM
Quote from: MarvinKosh on October 04, 2016, 02:47:20 PM
Yes, the resting hours are fixed. There's actually a Day/Night switch mod designed with sun lamps in mind, btw.

Right, but it doesn't actually match up exactly to the resting period AFAIK. Have seen more than a few posts that are positive that resting hours are slightly less than the night period provided by the day/night switch, meaning you are missing out on some growing time by not either running a battery (on the sunlamp side of the day/night switch) to make up for some of that lost growing time or just running the sun lamp 24 hours/day and thereby wasting power much of the night but still getting a bit more growing.

Now it could be they are wrong and the day/night switch is perfectly setup. Haven't paid close enough attention myself yet to really know.
Title: Re: Timer Switches
Post by: Serenity on October 04, 2016, 03:42:06 PM
Even if Day/Night Switch is not perfect it works well enough for me. There is also Haplo's PowerSwitch which allows you to set the time freely. But the interface is a bit awkward and it's locked behind research, which I don't like.

So this would be nice when it's done.
Title: Re: Timer Switches
Post by: avilmask on October 04, 2016, 05:27:32 PM
Quote from: BlackSmokeDMax on October 04, 2016, 02:45:26 PM
Are there concrete resting hours, or does that change per latitude? If they don't vary, it'd be nice if there was a pre-set button for those hours.
As I know, they're always the same - 19pm-5am.
Title: Re: Timer Switches
Post by: merthsoft on October 05, 2016, 07:08:06 PM
Ah, yes, I didn't have saving in there yet. It's implemented now.

I'm not sure about having a built-on day/night option. I think, design-wise, it's better for people to figure that out on their own, or look it up.

Also, this is gated behind research right now. That's easy to change, though--you can remove that from the defs. Question, then, for everyone: Should I gate it behind research (just microelectronic basics and and specific research), or not?

Current download w/ saving: http://merthsoft.com/TimerSwitches_2.zip (http://merthsoft.com/TimerSwitches_2.zip)
Title: Re: Timer Switches
Post by: Dingo on October 05, 2016, 07:59:23 PM
You're missing the abstract BuildingBase and have some quirky sentence structures in there. I hope you don't mind, I made some very slight changes to reduce redundancy and fix the missing base (see the attachment). The only thing you have left to do is recolour the On/Off buttons and their respective tiles because the colours are too similar, otherwise I think you can release this. It's so good!

[attachment deleted by admin - too old]
Title: Re: Timer Switches
Post by: merthsoft on October 05, 2016, 08:21:03 PM
Thanks! I appreciate the help :)

What colors do you see? I see brown and grey:

(http://i.imgur.com/mfav3oR.png)

Specifically, I'm using the same colors as the Anything and Work buttons on the restrict tab, to make it consistent:
        public static Texture2D OffColor => TimeAssignmentDefOf.Anything.ColorTexture;
        public static Texture2D OnColor => TimeAssignmentDefOf.Work.ColorTexture;
Title: Re: Timer Switches
Post by: Dingo on October 05, 2016, 08:27:05 PM
Brown and grey are way too similar in the colour range IMO, but I might be over-sensitive. I recommend something like blue/grey for sharp contrast.
Title: Re: Timer Switches
Post by: merthsoft on October 05, 2016, 08:31:13 PM
How's this:
(http://i.imgur.com/kc1Aat0.png)

I like it more!
Title: Re: Timer Switches
Post by: Dingo on October 05, 2016, 08:32:43 PM
(https://static-cdn.jtvnw.net/emoticons/v1/64138/3.0)
Title: Re: Timer Switches
Post by: merthsoft on October 05, 2016, 08:44:31 PM
Dope! Here's the most up-to-date version:
http://merthsoft.com/TimerSwitches_3.zip (http://merthsoft.com/TimerSwitches_3.zip)

Will upload on Steam and make a "Finished" thread probably tomorrow. Wanna test it a bit more to make sure it's robust enough :)

Also, I think I got all your changes in there, but forgive me if I missed any--just let me know!
Title: Re: Timer Switches
Post by: merthsoft on October 06, 2016, 09:46:34 PM
Released! https://ludeon.com/forums/index.php?topic=26661.0 (https://ludeon.com/forums/index.php?topic=26661.0)