Jelly.Console+ - Improving the built-in console

This mod is independent of Jelly.

Jelly.Console+

Jelly.Console+ is extending Stonehearth’s in-game console.

Features

  • Configurable hotkey to open/close the console
  • Arrow keys can be used to the input history. Persistent through game restarts.
  • Extended command parser that is capable of arguments with whitespace in it
  • Simple lua binding to easily add lua-sided functions
  • Resizable output window using console commands

Configuration

Jelly.Console+ adds three new entries in your user_settings.json after the first start:

{
	"mods" : {
		"jelly_console" : {
			"console_key" : 192,
			"height" : "200",
			"last_lines" : []
		}
	}
}
  • console_key is the key that is used to open the console, the default is 192. To figure out which number you have to use, you can use this page. Simply click into the yellow bit, press your desired key and it should write on the page which number to use. This may not work in all browsers, you might need to work Chrome or one of its derivates.
  • height is the height of the console, in pixels. This should not be smaller than 50 or taller than 500.
  • last_lines simply contains your history and can be ignored. It is not configuration relevant.

Command syntax

Usually, each argument is separated by a whitespace, so Hello World would become ["Hello", "World"]. To avoid this, Jelly.Console+ introduces the concept of “long strings” which work in a similar way as for example verbatim strings in C#. The rules for them are somewhat simple:

  • Each long string starts and ends with the same quotation mark, which can be either ' or ".
    Valid: "Hello World", invalid: "Hello World'
  • Within long strings, it’s possible to use the other quotation mark without any special syntax.
    Example: "How's the weather, partner?" 'This is not "Sparta".' will result in [ "How's the weather, partner?", "This is not \"Sparta\".' ]
  • Within long strings, the quotation mark used to mark it can be escaped by using it twice.
    Example: 'How''s the weather, partner?' "This is not ""Sparta""."
  • Double quotation marks at the start or end of a parameter, long or short, will count as escaped and therefore will be cut down.
    Example: ""Quote"" ''Unquote'' "This is not ""Sparta""" will result in ["\"Quote\", "\"Unquote\"", "This is not \"Sparta\""]

If you are confused about how it works, there’s a built-in command, show_arguments which will return the parameters in the new format to you.

There are functions that do not need this advanced parsing up to the point where it could be impossible to use it (for example, eval). These functions are named below with an ‘@’ at the beginning and can be called as such. For example, eval return false -- "^^ will claim that there is an unfinished long string, whereas @eval return false -- "^^ will work as expected. This will turn off command parsing altogether, however - some functions therefore require it to be enabled at all time. For these functions, their @-counterpart does not exist.

All commands that take as first argument an entity require either a “link” to the entity (as a string, like "object://game/1234") or they will use the last selected entity (by clicking on it in the world, followed by the command select).

Commands and current documentation…

… can be found on GitHub.

Download

The current version can be found on GitHub too. Rename the folder to “jelly_console” after extracting.

9 Likes

Quick video showing what it does, which really doesn’t work well in video form:

and screenshots of debugging fun:


It’s part recycled from rp_console, part completely new written. It was essential for me to get this done as soon as possible, as modding without a solid console is a pain.

4 Likes

I will definitely be giving this a go when I return to modding!

3 Likes

sounds awesome @RepeatPan

glad to see you’ve returned to your delicious jelly-filled roots!

I’ve added a whole bunch of features that I forgot in the first release and scheduled for later, including but not limited to:

  • Many new and sometimes even useful commands
  • By using a local scope, you can now define variables freely in eval without fear of getting complaints from strict.lua. The rules are a bit sketchy, but boil down to “get: local before global; set: global if available, local otherwise”. Don’t confuse this with the local keyword in lua.
  • The input history got smarter and won’t keep commands in memory that you’ve just used one second ago. It’s also not going to keep empty lines.
  • Speaking of empty lines, those do not throw an “unknown command” error anymore, but that’s a rather ugly hack. I’ve also added clear to get rid of the window’s contents if necessary.
  • select (as shown in the video) is no longer necessary. With the lua scope change, you can save entities to other variables should you really need them to be persistent.

At the moment, I honestly do not have much that I could improve in this. Moving on to the next thing, then.

1 Like

awesome console tool.
Would be very useful when modding.

2 questions:
Is it possible to set the time to night?
Is it possible to set a person to be hungry? might be something with calories in the attributes.

  • Modifying the time might be a bit difficult as there are many events that rely on a normal flow of time. Maybe a sped up version or something similar could be achieved (like what I did in the sheep rave video, where it suddenly turns to night).
  • Hunger can be set using set_attribute calories, yes. To make them hungry, use set_attribute calories 10 or so - 0 would be starving, 100 would be stuffed.
3 Likes

A little update and a memo that hello, this still exists:

  • Added a bunch of new functions. There’s dozens of them now. Dozens!
  • Added client sided lua (at least eval; running files is TBD at a later point).
  • Updated the example that shows how you can integrate Console+ commands into your game without requiring your players to have it too (aka “How to make console commands optionally available for those with Console+ and not error around for those who haven’t”)
  • Now independent of jelly. That’s right, this is now standalone. I don’t know why exactly I’ve made it dependent of it; probably thought I was going to do the console thing in Jelly itself. Of course, jelly still has pretty functions when you’re @l’ing around, but they’re no longer required.

You can use the controller, to summon the entity (such as decoration, furniture) somewhere?

Using @l or @eval or @lua or whichever alias you prefer, you can execute lua directly on the server side. To spawn things, for example, you can use @l microworld:place_entity(entity_ref, x, z) in microworlds or @l radiant.terrain.place_entity(radiant.entities.create_entity(entity_ref), Point3(x, 0, z)). To make it actually usable, another step is required (namely setting the player id). Or you just throw the loot tool over it.

1 Like