JadeKnightblazer Posted February 12, 2015 Share Posted February 12, 2015 (edited) Looking for a way to create a custom keybind, and have this keybind do something like, check the players current weapon (if they have one) or any other character thing. So far I can link my keybind to widget player, but.... that player info does not include .components.inventory or equippables, ect. Seems to only have a name =/ Overall, if you have a good way to make a Keybind and a tut to follow for it, please help me out. Or even knowledge on how to direct the keybind to work with the player, with all their linked components. Edited February 12, 2015 by JadeKnightblazer Link to comment https://forums.kleientertainment.com/forums/topic/50854-custom-keybind-for-checking-characters-equippment/ Share on other sites More sharing options...
rezecib Posted February 12, 2015 Share Posted February 12, 2015 @JadeKnightblazer, Without knowing more about exactly what you want the keybind to do, it's hard to say. But my guess is that you'll need to do some networking-- there isn't really a good way to do this yet (it's one of the things on the list to improve for mod support, I believe), but I think the best method right now is to hijack the RPC system with a custom action (as RPCs are the only way to do client->server communication, and the server is what has the components). I don't know much about how to do this, but it has been discussed in some other threads a while back. However, a fair bit of information you can still get locally. Although the local character doesn't have inst.compnents.inventory, it does have inst.replica.inventory, for example. Link to comment https://forums.kleientertainment.com/forums/topic/50854-custom-keybind-for-checking-characters-equippment/#findComment-612237 Share on other sites More sharing options...
JadeKnightblazer Posted February 12, 2015 Author Share Posted February 12, 2015 I'll try the replica.inventory here is what I am doing atm... modMain:local KEY_CTRL = GLOBAL.KEY_CTRLlocal TheInput = GLOBAL.TheInput--Key Bind stufflocal RELICKEY = GetModConfigData("RELICKEY")--Relic Toggle Keylocal controls = nillocal keydown = falselocal clientOwner = nil--Custom Relic Keylocal function ShowCastRelic() if keydown then return end keydown = true --controls.relickey:CastRelic() if clientOwner.prefab == "winston" then --if clientOwner.components.inventory.equipslots[EQUIPSLOTS.BODY] == nil then --local relicItem = clientOwner.components.inventory.equipslots[EQUIPSLOTS.HEAD] --if relicItem.prefab == "skitemmealtickettest" then clientOwner.components.talker:Say(clientOwner.prefab.." is equipped!") --end --end end endlocal function HideCastRelic() keydown = false endlocal function AddRelicToggleKey(self) clientOwner = self.owner controls = self -- this just makes controls available in the rest of the modmain's functions --controls.relickey = controls:AddChild(RelicKey(self.owner)) GLOBAL.TheInput:AddKeyDownHandler(RELICKEY, ShowCastRelic) GLOBAL.TheInput:AddKeyUpHandler(RELICKEY, HideCastRelic) local OldOnUpdate = controls.OnUpdate local function OnUpdate(...) OldOnUpdate(...) if keydown then --self.relickey:CastRelic() end end controls.OnUpdate = OnUpdateendAddClassPostConstruct( "widgets/controls", AddRelicToggleKey )So far... I have a customizable Hotkey, using the Config. Then you can press the RelicKey to command the clientOwner to check its prefab, which will say a message. The --'s are just stuff that does not work atm. Link to comment https://forums.kleientertainment.com/forums/topic/50854-custom-keybind-for-checking-characters-equippment/#findComment-612242 Share on other sites More sharing options...
JadeKnightblazer Posted February 12, 2015 Author Share Posted February 12, 2015 Do you know what functions .replica.inventory has? Can't seem to find a use for it. Unless you ment inventory_replica Link to comment https://forums.kleientertainment.com/forums/topic/50854-custom-keybind-for-checking-characters-equippment/#findComment-612250 Share on other sites More sharing options...
rezecib Posted February 12, 2015 Share Posted February 12, 2015 Do you know what functions .replica.inventory has? Can't seem to find a use for it. Unless you ment inventory_replica inventory_replica is the file that has the code for the inventory replica, which is attached to the player table at replica.inventory. The same is true for all other replicable components. Link to comment https://forums.kleientertainment.com/forums/topic/50854-custom-keybind-for-checking-characters-equippment/#findComment-612267 Share on other sites More sharing options...
JadeKnightblazer Posted February 12, 2015 Author Share Posted February 12, 2015 Seems EQUIPSLOTS is a nil value /unknown. clientOwner.replica.inventory.equipslots[EQUIPSLOTS.BODY] ~= nil Link to comment https://forums.kleientertainment.com/forums/topic/50854-custom-keybind-for-checking-characters-equippment/#findComment-612289 Share on other sites More sharing options...
rezecib Posted February 12, 2015 Share Posted February 12, 2015 @JadeKnightblazer, Because it's in your modmain, you need to call it from the GLOBAL space: GLOBAL.EQUIPSLOTS.BODY. This goes for anything defined globally, except for the specific things that are added to the mod environment (you can look at what's added in mods.lua, it's the part that has math, table, pairs, etc). Link to comment https://forums.kleientertainment.com/forums/topic/50854-custom-keybind-for-checking-characters-equippment/#findComment-612292 Share on other sites More sharing options...
JadeKnightblazer Posted February 12, 2015 Author Share Posted February 12, 2015 Thanks, given that a try!!!! Sorry placing code in the modMain.lua is very strange to me. Link to comment https://forums.kleientertainment.com/forums/topic/50854-custom-keybind-for-checking-characters-equippment/#findComment-612295 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now