Hello. It's been a long time since I've done any Grimrock modding and I was hoping someone could help me with a few things I can't find an answer for (although I fear the answer is going to be, "no I can't!")
Is there a way to handle custom user input (i.e. keyboard commands)? Example usage could be detecting if the SHIFT key is down to make the party sprint.
Also can you enforce game modes like "Ironman" and "Single use crystals"?
Scripting - user keyboard input
Re: Scripting - user keyboard input
Yes, you can use keyboard input. The GraphicsContext class has a keyDown() function that tells you whether a key is currently pressed, although it doesn't work for every key.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Scripting - user keyboard input
Thanks for the reply minmay.
I saw the GraphicsContext in the scripting reference and assumed it was just for handling GUI. I'll be sure to try it. How do I access the GraphicsContext in script? Is there an example of its usage anywhere? Is there a list of valid keys/ids on this forum that can be passed into the keyDown() func?
I don't suppose there is a way of detecting onKeyDown()?
I also spotted this in the reference: Config.getKeyBinding(action)
Seems a bit strange to me that this exists without a Config.setKeyBinding(key, action)?
I saw the GraphicsContext in the scripting reference and assumed it was just for handling GUI. I'll be sure to try it. How do I access the GraphicsContext in script? Is there an example of its usage anywhere? Is there a list of valid keys/ids on this forum that can be passed into the keyDown() func?
I don't suppose there is a way of detecting onKeyDown()?
I also spotted this in the reference: Config.getKeyBinding(action)
Seems a bit strange to me that this exists without a Config.setKeyBinding(key, action)?
Re: Scripting - user keyboard input
OK I have worked out the bare essentials for this. I'm on my way now, I can just record keyUps and keyDowns. Piece of cake
Can anyone confirm if its possible to enforce game modes like "Ironman" and "Single use crystals", other than asking the user nicely in the description to use such settings?

Code: Select all
onDrawGui = function(self, context)
print(context.keyDown("shift"))
end
Re: Scripting - user keyboard input
It is not. (Not really sure why you'd want to, either.) If you want to make a single-use crystal, you can always give it a cooldown of math.huge.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.