Skip to content

Commit

Permalink
Merge pull request #83 from dennis/no-version-specific-init.lua
Browse files Browse the repository at this point in the history
Read init.lua, not init-<version-no>.lua
  • Loading branch information
dennis committed Mar 24, 2021
2 parents 424ceae + 1741ba2 commit 4cbf97f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 53 deletions.
4 changes: 2 additions & 2 deletions Backend/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class Engine : Worker, IEngine, IDisposable
private readonly ILogger Logger;
private readonly IEventHandlerController EventHandlerController;

public Engine(ILogger logger, IEventFactory eventFactory, IEventBus eventBus, IPluginFactory pluginFactory, IPluginManager pluginManager, IApplicationVersionService applicationVersionService, EventHandlerControllerBuilder eventHandlerControllerBuilder) : base("engine")
public Engine(ILogger logger, IEventFactory eventFactory, IEventBus eventBus, IPluginFactory pluginFactory, IPluginManager pluginManager, EventHandlerControllerBuilder eventHandlerControllerBuilder) : base("engine")
{
EventFactory = eventFactory.Get<IInternalEventFactory>();
EventBus = eventBus;
Expand All @@ -41,7 +41,7 @@ public Engine(ILogger logger, IEventFactory eventFactory, IEventBus eventBus, IP

// Plugins..
{
var initFilename = $"init-{applicationVersionService.Version}.lua";
const string initFilename = "init.lua";

if (!File.Exists(initFilename))
{
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next version
[Full Changelog](https://github.com/dennis/slipstream/compare/v0.4.1...main)
- No more version specific init.lua. From this point and forward, Slipstream only reads init.lua
- Event: Adds IRacingTrackPosition

## [0.4.1](https://github.com/dennis/slipstream/releases/tag/v0.4.1) (2021-03-20)
Expand Down
54 changes: 3 additions & 51 deletions docs/init.lua.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,11 @@
The init.lua file is the only required Lua script to run the slipstream application.
The file will be created if it does not exist.

Located in %AppData%/Slipstream/init-{app-version}.lua
Located in %AppData%/Slipstream/init.lua

IMPORTANT: init.lua is application version specific and a new default will be generated
on startup of a different version. This is done to prioritise slipstream startup instead
of Lua script compatability during the high churn phases of development and will be looked
at again once plugin development slows down.
IMPORTANT: If init.lua is missing a default one will be generated on startup. As
long as the file exists, Slipstream will not modify it.

## Usage
init.lua can be used to customise the loading of plugins and change the default behaviour of
a plugin. Make sure to look at individual plugins for more information on registration options.

### Default init.lua
```lua

-- This file is auto generated upon startup, if it doesnt exist. So if you
-- ever break it, just rename/delete it, and a new working one is created.
-- There is no auto-reloading of this file - it is only evaluated at startup
print "Initializing"

-- Listens for samples to play or text to speek. Disabling this will mute all
-- sounds. You can add optional argument "output" to device which device to use.
-- Make a small lua script with `audio: send_devices("AudioPlugin")` and look at
-- the incoming `AudioOutputDevice` events.The device index is the value you
-- want to use for the value for "output"
register_plugin({plugin_name = "AudioPlugin"})

-- Delivers IRacing events as they happen
register_plugin({ plugin_name = "IRacingPlugin"})

--Connects to Twitch(via the values provided in Settings) and provide
--a way to sende and receive twitch messages.Generate a token here: https://twitchapps.com/tmi/
--register_plugin({ plugin_name = "TwitchPlugin", twitch_username = " < username > ", twitch_token = " < token > ", twitch_channel = " < channel > "})

--Only one of these may be active at a time.ReceiverPlugin listens
-- for TCP connections, while Transmitter will send the events it sees
--to the destination. Both are configured as Txrx in Settings.
--register_plugin({ plugin_name = "TransmitterPlugin", ip = " < yourip > ", port = < yourport >})
--register_plugin({ plugin_name = "ReceiverPlugin", ip = " < yourip > ", port = < yourport >})

--LuaManagerPlugin listens for FileMonitorPlugin events and acts on them.
-- It will only act on files ending with.lua, which it launches
-- a LuaPlugin for. If the file is modified, it will take down the plugin and
-- launch a new one with the same file.If files are moved out of the directory
-- it is consider as if it were deleted. Deleted files are taken down.
register_plugin({ plugin_name = "LuaManagerPlugin"})

--FileMonitorPlugin monitors the script directory and sends out events
-- every time a file is created, renamed, modified or deleted
register_plugin({ plugin_name = "FileMonitorPlugin"})

--Provides save / replay of events. Please be careful if you use this.There is
--not much filtering, so RegisterPlugin / Unregister plugins will actually make
--slipstream perform these actions
register_plugin({ plugin_name = "PlaybackPlugin"})

```

0 comments on commit 4cbf97f

Please sign in to comment.