Querying Input from a Lua Script #551
Replies: 1 comment 1 reply
|
The specific error is from BMS exposes enum construction through the global local keyW = construct(types.KeyCode, { variant = "KeyW" })See constructing arbitrary types and the repository's Lua enum-construction test. With the resource and its local buttons = world.get_resource(types["ButtonInput<KeyCode>"])
local keyW = construct(types.KeyCode, { variant = "KeyW" })
if buttons:pressed(keyW) then
print("W key pressed")
endThe colon passes the resource as the method receiver. There are two separate requirements here: registering a type allows reflection, but doesn't by itself expose every Rust method. If the enum construction succeeds and the next error is that |
Uh oh!
There was an error while loading. Please reload this page.
I'm trying to see how I can query the input of a player from a script. I was thinking maybe I can do something similar to how it's done in rust but it doesn't seem to want to work with the way I'm approaching it. I registered
ButtonInput<KeyCode>as a type but it's not really working when fetching it in Lua. I don't think this is the approach at all, but I saw that types like GamepadButton are available so why not be able to query which button or key is currently pressed? For reference, this is my script to test this outAnd this is the error I'm getting
All reactions