StarfallEx icon indicating copy to clipboard operation
StarfallEx copied to clipboard

Editor file auto-reload on upload

Open diogo464 opened this issue 3 years ago • 4 comments

This PR adds an option that, if enabled, will read script files from disk before spawning a starfall chip. This makes it easier to use an external editor side-by-side with Garry's Mod. The option can be toggled with a checkbox in the editor settings. This option is disabled by default so that if nothing is done then everything should continue to work as usual. There is also a confirmation prompt that show's up when clicking theRefresh file button if this button is clicked while there are unsaved changes.

diogo464 avatar Aug 09 '22 18:08 diogo464

Wasn't this already achievable by making sure the file isn't open in the editor and using the tool reload key on a chip you wish to update?

I'll look it all over soon.

thegrb93 avatar Aug 10 '22 21:08 thegrb93

Yeah, you could already make the script reload from disk if it wasn't open in an editor, but it was nasty when you wanted to replace the chip, you had open editor, dig for the file, place the chip, open editor, close tab, close editor... kinda messy, this is a great feature IMO

Even better if we could mark instance to watch it's files for changes and reload automatically :heart_eyes:

adamnejm avatar Aug 11 '22 02:08 adamnejm

Yeah, autoreload sounds like a cool option. Just need to query the file modify time on a timer.

thegrb93 avatar Aug 11 '22 02:08 thegrb93

I added the timer and the query to the file's last modified time. Now you can edit on another editor and see the text update live (when you save on the other editor).

diogo464 avatar Aug 11 '22 14:08 diogo464

That's nice, but not all that useful IMO, I was thinking of having the chip automatically reload with the new code once a change is detected. That way you could just focus on coding and watch the changes update in real time, instead of still having to switch to GMod and reload the chip manually.

adamnejm avatar Aug 14 '22 09:08 adamnejm

Isn't that what he said he added?

thegrb93 avatar Aug 14 '22 09:08 thegrb93

Isn't that what he said he added?

Nah, right now only the code in editor updates once a change is detected, but the chip doesn't reload automatically.

adamnejm avatar Aug 14 '22 09:08 adamnejm

Ah, yeah both features would be good to have.

thegrb93 avatar Aug 14 '22 10:08 thegrb93

That's nice, but not all that useful IMO, I was thinking of having the chip automatically reload with the new code once a change is detected. That way you could just focus on coding and watch the changes update in real time, instead of still having to switch to GMod and reload the chip manually.

Ok, I didn't understand that at first. This new update should have that working. To enabled it just hold C and right click the chip, then in the starfall submenu just enable the option to reupload on reload. For this to work the checkbox in the editor settings must be enabled.

diogo464 avatar Aug 14 '22 13:08 diogo464

Oh, it works for included files too. Amazing feature!

adamnejm avatar Aug 14 '22 14:08 adamnejm

I don't see any issues with the rest of the code. Should be good after that comment is addressed.

thegrb93 avatar Aug 15 '22 14:08 thegrb93