Logic World Wednesdays: Console Scripting and Configurable Input

by @MouseHatGames 2019-09-04
Advanced Console Functionality - Felipe

Last week I talked about LICC, a common console framework for the client and server that takes care of registering and running commands defined by mods or by the game itself. This week I’ve been extending LICC by adding LSF (LICC Script File), a scripting language heavily inspired by Bash. It’s got functions, variables and if, for and while statements, as well as most of the usual math and boolean operators (including the ternary operator). Here’s a sample file:

lsf.png

LSF is completely integrated into LICC, meaning that you’ll be able to use the same script file on both the client and the server!

You can run any script file at any time with the exec command and in LSF files you can also import other script files, allowing you to reuse code. LICC will also automatically run a script called called autoexec.lsf on startup if it exists, allowing you to modify settings or run maintenance tasks.

Input System Overhaul - Jimmy

I spent most of this week working on a total overhaul of Logic World’s input system. The input system is what translates your controls in real life, like clicking the mouse or pressing a keyboard key, into actions in the game. I’ve focused on customizability with the new system. I want everyone to be able to configure the game’s controls to how they want them, or - in the case of people with motor disabilities - how they need them.

Here’s an overview of how the system works:

  • each action the game can interpret - walk forwards, jump, place item, etc - has one or more bindings that can trigger it.
  • bindings can reference direct input like key presses or other bindings. For example, the jump action is bound to space, and the fly up action is bound to jump.
  • bindings can reference multiple direct inputs or other bindings, requiring you to press both of them to trigger the action
  • bindings which can be held down have two options: actually hold them down, or tap once to toggle on and tap again to toggle off
  • bindings can reference double or triple taps/clicks

In addition to being far more personally configurable, the new input system has several advantages over the old one:

  • a much greater variety of input devices are supported, and adding new supported input devices is much easier
  • the bindings can be edited at runtime
  • mods can add and use custom bindings
  • the new system is significantly more performant
  • binding data is stored in an easily-editable file next to the game executable, rather than in the registry

Unfortunately I didn’t have time this week to make the in-game menu for editing the controls, but you can expect to see that next week. In the meantime, you can check out the bindings file - all 79 of our configurable controls.


If you’d like to receive an email each time we post one of these blogs, you can sign up for our newsletter. Be sure also to wishlist Logic World on Steam and join the official Discord.

See you next Wednesday!

Read previous Logic World Wednesdays


20 comments
@Nik 2019-09-05

Ok you win. This is fucking amazing. LICC is even more capable than I thought it would be, and I already thought it was pretty ground-breaking.

It’s interesting that FlyUp is one of the CanBeHeld:True controls, but Jump is not. And yet FlyUp is triggered by Jump!
Um, I wish you luck making a UI for this! Perhaps a simple and advanced mode?

I’m also wondering a few things:
- Is CanBeHeld user configurable?? because I’m not sure what would happen if you set it to false for MoveForward - Could you also add digital controls for moving your view around? i.e. LookLeft, LookRight, LookUp, LookDown. And maybe for moving the mouse cursor around the menus as well? That would strongly increase ease-of-access, since that’s one of the aspects you mentioned in the post. - Side-question; can you use tab or arrow keys to navigate around the menus without using the mouse cursor? - Do LICC commands exist for these controls as well? For example triggering Jump from a script. I’m asking because LICC seems very separated from this bindings file. - Can binds be modified in-game using the console? This aspect is useful for scripting, if you want to swap to a different set of controls for recording vs playing vs creating, or etc. - Can releasing a button trigger an action as well? - Can you bind things to trigger console commands? For example pressing P to run exec high_performance.lsf - Are the double tap detection timings able to be modified?
- Is analog movement is supported? i.e. a joystick on a controller, to allow the player to move in any direction at any speed? Because with all this control over controls (ha) I would love to set up this game on my steam controller, and analog movement would be wonderful - Are these scripts and control files user-specific? Like if I make another user account on my computer for my sister, would she be unexpectedly playing LW with my weird control scheme?

@Jimmy 2019-09-05

It’s interesting that Fly is one of the CanBeHeld:True controls, but Jump is not. And yet Fly is triggered by Jump!

Jumping is a single, instantaneous action, whereas flying up or down is something you continuously do, same as any other direction of movement. And it’s not so much that FlyUp is triggered by Jump, but rather that the binding for FlyUp is synchronized to the same binding as Jump; if you change your Jump key, the key for FlyUp is automatically updated.

Um, I wish you luck making a UI for this! Perhaps a simple and advanced mode?

I’ve already planned out the UI on paper and I think it’s going to work quite well, no advanced mode needed.

is CanBeHeld user configurable?? because I’m not sure what would happen if you set it to false for MoveForward

CanBeHeld is metadata that will be used to enable or disable the Hold Down/Tap to Toggle button in the UI. It’s a per-action distinction between actions that are one-time and instantaneous and actions that need to be continuously activated.

When a binding option is set to Hold Down - the default - you have to actually hold the key down to continuously activate it. When a binding option is set to Tap to Toggle - which you can only enable for actions in which CanBeHeld is set to true - you tap once to start holding it down and you tap a second time to release it.

This is probably kind of confusing, it’ll be much more understandable when I can show you the UI for it. To answer your original question, when a mod adds a binding it can specify whether it can be held or not.

Could you also add digital controls for moving your view around? i.e. LookLeft, LookRight, LookUp, LookDown. And maybe for moving the mouse cursor around the menus as well? That would strongly increase ease-of-access, since that’s one of the aspects you mentioned in the post.

While I don’t know this for certain, I expect that people for whom mouse usage is a barrier to fluid computer use already have a digital mouse-moving solution that works for them. But I suppose it would be pretty easy to add this, so I will! Thanks for the suggestion :)

side-question, can you use tab or arrow keys to navigate around the menus without using the mouse cursor?

There is currently very little keyboard navigation in the UI, but this is something I definitely want to look into before we launch next month. There are shortcuts for common actions, like adding a component to your hotbar, but full keyboard navigation of menus is not possible yet.

Do LICC commands exist for these controls as well? For example triggering Jump from a script.

I’ll add a command for triggering bindings, thanks for the suggestion!

Can binds be modified in-game using the console?

I’ll add a command for this, thanks again for the suggestion! :)

Can releasing a button trigger an action as well?

The action bindings themselves do not distinguish between down, hold, and up, but we can access the state of all three within the code.

Can you bind things to trigger console commands? For example pressing P to run exec high_performance.lsf

Yes, there is a bind command, and it supports the full customizability of regular game controls. So you could do bind LeftCtrl+LeftAlt+P*2 exec high_performance.lsf and it would trigger that command when you held Ctrl and Alt and double tapped P.

Are the double tap detection timings able to be modified?

Yep, the maximum time between taps is globally configurable, and it will be on the same menu as the keybindings themselves.

Is analog movement is supported? i.e. a joystick on a controller, to allow the player to move in any direction at any speed?

Currently the input system itself doesn’t support analog movement, but the player controller is hardcoded to accept analog input from the left stick of a game controller. I’d like to improve this system in the future, but for 1.0 it should be good enough.

with all this control over controls (ha)

sick pun bro

I would love to set up this game on my steam controller

I too am a fan of the Steam controller, and I plan to have an official Logic World configuration at launch :D

Are these scripts and control files user-specific? Like if I make another user account on my computer for my sister, would she be unexpectedly playing LW with my weird control scheme?

All of Logic World’s saves, mods, settings, and scripts are self-contained within the game’s directory, the same folder the executable is in. This is really nice because you can just copy the game folder and have an installation of the game that’s completely separate from the original. So your sister would have your weird control scheme if she was launching the game from the same executable you were, but you could just copy the folder and her game settings would be independent from yours.


Thanks for all the questions!

@Nik 2019-09-05

So happy about ALL of these answers!! Thanks for clarifying some of my confusion too!

I like the portable-installation approach, with everything saved in the same folder. Will there be an option to have a global set of saves/settings? Or a customizable location to save your worlds? This way, players don’t have to copy the same world files between different installations. Minecraft, and the Dolphin emulator both have similar customizations that are able to be turned on/off, and it’s useful sometimes! Especially since both of those games have a lot of reasons to flip between different versions

I’ve also seen fairly clean systems for making settings/saves per-user, with minimal sacrifices. For example some source engine games will store your quicksave files inside a sub-folder named with your steam user ID, so everyone’s saves are still contained in the same install directory. But now, if you open the game while signed into steam with a different account, you’ll only have your own saves showing up in the game, without having to wait on Steam to replace and re-sync all the saves with the ones from your steam cloud. (I don’t even know if LW supports steam cloud saves, or even logging-in with steam, or even logging-in at all, so a lot of this may be completely irrelevant!)

I think there’s definitely different strengths for different approaches, just wanted to mention my thoughts!

EDIT: I also just realized your reply is like twice as long as the blog post! Thanks so much for being such a community-driven developer.

@Jimmy 2019-09-05

Will there be an option to have a global set of saves/settings? Or a customizable location to save your worlds? This way, players don’t have to copy the same world files between different installations.

You could fudge this with symbolic links, but I’ll look into adding a proper option for it. Thanks for bringing this up!

some source engine games will store your quicksave files inside a sub-folder named with your steam user ID, so everyone’s saves are still contained in the same install directory. But now, if you open the game while signed into steam with a different account, you’ll only have your own saves showing up in the game, without having to wait on Steam to replace and re-sync all the saves with the ones from your steam cloud.

For what it’s worth, you’re able to tag save files using the same lovely nested system that saved boards use. If you had multiple users sharing an installation, they could tag their saves with their names.

I don’t even know if LW supports steam cloud saves

We most likely will, but no promises. I’d prefer not to have features exclusive to one platform, so we might roll our own cloud saves solution tied to your logicworld.net account if it’s not too difficult or expensive.

or even logging-in with steam, or even logging-in at all

You can log into the game with your logicworld.net account, and you can sign into logicworld.net with Steam. We want Steam users and non-Steam users to be able to play multiplayer together, so authenticating your multiplayer identity with Steam was off the table.

@shamus030 2019-09-05

We want Steam users and non-Steam users to be able to play multiplayer together, so authenticating your multiplayer identity with Steam was off the table.

So just to clarify, a user will not be able to log into their logicworld.net account in-game using their steam account as authentication?

@Jimmy 2019-09-05

Incorrect. You will be able to log into your logicworld.net account in-game using your steam account. I’d like to make it so that when you launch the game through steam, it automatically logs you in this way, so steam users won’t need to worry about it at all.

It’s just that when you connect to a multiplayer server, it isn’t checking your identity via Steam. It’s checking your identity via logicworld.net, and your logicworld.net account is linked to your Steam account.

@Nerd 2019-09-05

I registered here, but I do not want to have a separate Steam account on this site (I am going to buy the game on Steam)

@Jimmy 2019-09-05

If you go to your account settings you can link your Steam account to your existing logicworld.net account. If you don’t want to do that, you will have the option of signing in with a non-linked logicworld.net account when using Steam.

@shamus030 2019-09-05

Cool! I just misunderstood your other comment.

@ForLoveOfCats 2019-09-04

What does the current modding workflow look like? Beyond adding simple custom components, fully modifying game functionality and the like.

@pipe01 2019-09-04

It’s still too early to comment on this, but I do want to add a hook system that allows you to subscribe to certain game events and modify/stop them.

@ForLoveOfCats 2019-09-04

SkyOfSteel actually has a system for that exact thing but I’m not very satisfied with how I implemented it it so I look forward to seeing your approach!

@ForLoveOfCats 2019-09-04

These additions feel a bit familiar…… 🤔

Great job guys! I do have a question though, what drove a custom scripting language as opposed to integrating Roslyn and having runtime C# scripting? More control over the semantics to allow better integration with the existing console system?

@pipe01 2019-09-04

At first LSF began as a simple Windows’ Batch-like format, with which you could run commands and that’s about it. However, I later wanted to add variables and then math operators, so at that point I decided to write a full-on scripting language. I considered using C# scripting but I wanted to let people just write a list of commands that they want to execute and that’s it, whereas with C# you need to understand the language in order to write a script and there wouldn’t be a clean way of simply calling a command.

@shamus030 2019-09-05

There are languages like Lua that already have very powerful support for integrating like this (transferring variables and functions in/out of the scripting environment). Not to mention the tons of documentation/tools already available if you went with an existing scripting language.

Are you planning on providing some basic syntax highlighting and other development tools, or will that be up to the community to create?

@pipe01 2019-09-05

I want to make some custom highlighting for popular editors, especially Sublime Text as it’s the one I use

@Nik 2019-09-05

Well editors like Notepad++ have support for custom syntax highlighting for custom file extensions. No doubt that some people will make and share their configurations for that

@ForLoveOfCats 2019-09-04

Makes sense. Any chance of being able to play with it ahead of the general game’s launch? I’d assume not but I gotta ask ;)

@pipe01 2019-09-04

The repo will be open sourced very soon, so sure!

@ForLoveOfCats 2019-09-04

I look forward to playing with it!