hislittlecuzin Posted April 16, 2018 Share Posted April 16, 2018 I created a thread on steam but someone requested me to make a thread here. Please don't lock as spam until I can get the appropriate response. Thanks!! https://steamcommunity.com/app/251810/discussions/0/3288067088097749702/ Quote Steam client Leadworks Game Indie engine with Standard Leadworks Game engine plugin. Link to comment Share on other sites More sharing options...
AggrorJorn Posted April 16, 2018 Share Posted April 16, 2018 I think I have something that fits your need. Will post the code + example when I get home. it will allow you to setup your input like this: --config setup virtualKeys["forward"] = { primaryKey = "W", secondaryKey = "Up" } --usage if input:KeyHit("forward") then --profit end Quote Link to comment Share on other sites More sharing options...
hislittlecuzin Posted April 16, 2018 Author Share Posted April 16, 2018 20 minutes ago, AggrorJorn said: snip I'm eagerly awaiting your solution!! Quote Steam client Leadworks Game Indie engine with Standard Leadworks Game engine plugin. Link to comment Share on other sites More sharing options...
AggrorJorn Posted April 16, 2018 Share Posted April 16, 2018 I have been using my own Input manager for several years now. From time to time a project would require some custom tweaking, so I made a new clean version which should suit your requirements. keyboard and mouse hit and down key can be queried multiple times per frame Virtual keys with primary and secondary function (W and Up for instance) Other userfull functions Here you can find the source code: 1. Download the script and put it somewhere in your scripts folder. My example uses Scripts/Input/input.lua I use main.lua to import it. Add this to your main lua: import "Scripts/Input/input.lua" Before the main loop add the following: input = Input:Create() -- I like input as a global variable, since you use it in many places input:SetVirtualKey("RocketBoost", "Tab", "R") -- Add custom virtual key input:DebugVirtualKeys() --prints all existing virtual keys to the screen In your main loop you can now do these things: if input:VirtualKeyHit("RocketBoost") then System:Print("ROCKETBOOOSTING using Tab or ALt") end if input:KeyHit("E") then System:Print("E hit") end if input:KeyHit("E") then System:Print("E hit second time") end if input:KeyDown("Q") then System:Print("Q down") end if input:MouseHit("LButton") then System:Print("Left mouse button click") end if input:MouseDown("MButton") then System:Print("Middle mouse down") end if input:VirtualKeyHit("Jump") then System:Print("jump hit") end if input:VirtualKeyDown("Forward") then System:Print("moving forward using W or Up arrow") end By default there are a couple of Virtual keys (just like you were used in Unity). You can either change the input.lua script or add/overwrite with the SetVirtualKeyCommand() obj.virtualKeys["Forward"] = { primaryKey = "W", secondaryKey = "Up" } obj.virtualKeys["Backward"] = { primaryKey = "S", secondaryKey = "Down" } obj.virtualKeys["Left"] = { primaryKey = "A", secondaryKey = "Left" } obj.virtualKeys["Right"] = { primaryKey = "D", secondaryKey = "Right" } obj.virtualKeys["Jump"] = { primaryKey = "Space" } obj.virtualKeys["Use"] = { primaryKey = "E" } obj.virtualKeys["Fire"] = { primaryKey = "Lbutton" } obj.virtualKeys["SecondaryFire"] = { primaryKey = "Rbutton" } obj.virtualKeys["SpecialFire"] = { primaryKey = "Mbutton" } Some other usefull functions for in your game loop: if input:Any() then System:Print("Any input detected. So keyboard or mouse.") end if input:AnyKey() then System:Print("Any keyboard input.") end if input:AnyMouse() then System:Print("Any mouse input detected (besides movement)") end 1 2 Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted April 17, 2018 Share Posted April 17, 2018 Little video demonstrating it: 3 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.