mirror of
https://github.com/Mestima/wanda.git
synced 2025-05-03 13:40:15 +00:00
added keybinds support
This commit is contained in:
parent
cda33a69c2
commit
573828a6aa
@ -23,6 +23,12 @@ priority = 0
|
|||||||
|
|
||||||
server_filter_tags = {"Wanda's bag"}
|
server_filter_tags = {"Wanda's bag"}
|
||||||
|
|
||||||
|
local keys = {
|
||||||
|
"None",
|
||||||
|
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
|
||||||
|
"LSHIFT","LALT","LCTRL","TAB","BACKSPACE","PERIOD","SLASH","TILDE"
|
||||||
|
}
|
||||||
|
|
||||||
configuration_options = {
|
configuration_options = {
|
||||||
{
|
{
|
||||||
name = "lang",
|
name = "lang",
|
||||||
@ -55,5 +61,45 @@ configuration_options = {
|
|||||||
{ description = "you can't", data = false }
|
{ description = "you can't", data = false }
|
||||||
},
|
},
|
||||||
default = true
|
default = true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "key_binds",
|
||||||
|
label = "Enable Keybinds",
|
||||||
|
hover = "Enable Wanda's Keybinds or not",
|
||||||
|
options = {
|
||||||
|
{ description = "enable", data = true },
|
||||||
|
{ description = "disable", data = false }
|
||||||
|
},
|
||||||
|
default = true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "ageless_key",
|
||||||
|
label = "Ageless watch Keybind",
|
||||||
|
hover = "Use available Ageless Watch with...",
|
||||||
|
options = {},
|
||||||
|
default = "X"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "backstep_key",
|
||||||
|
label = "Backstep watch Keybind",
|
||||||
|
hover = "Use available Backstep Watch with...",
|
||||||
|
options = {},
|
||||||
|
default = "Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "backtrek_key",
|
||||||
|
label = "Backtrek watch Keybind",
|
||||||
|
hover = "Use available Backtrek Watch with...",
|
||||||
|
options = {},
|
||||||
|
default = "C"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function filltable(tbl)
|
||||||
|
for i=1, #keys do
|
||||||
|
tbl[i] = {description = keys[i], data = keys[i]}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
filltable(configuration_options[5].options)
|
||||||
|
filltable(configuration_options[6].options)
|
||||||
|
filltable(configuration_options[7].options)
|
||||||
|
125
data/modmain.lua
125
data/modmain.lua
@ -1,14 +1,123 @@
|
|||||||
GLOBAL.setmetatable(env,{__index=function(t,k) return GLOBAL.rawget(GLOBAL,k) end})
|
GLOBAL.setmetatable(env,{__index=function(t,k) return GLOBAL.rawget(GLOBAL,k) end})
|
||||||
|
local G = GLOBAL
|
||||||
|
|
||||||
local function GetConfig(name, default)
|
local agelesskey = GetModConfigData("ageless_key")
|
||||||
local opt = GetModConfigData(name)
|
local backstepkey = GetModConfigData("backstep_key")
|
||||||
if (not opt) then
|
local backtrekkey = GetModConfigData("backtrek_key")
|
||||||
opt = default
|
local keybinds = GetModConfigData("key_binds")
|
||||||
|
|
||||||
|
local function IsInGameplay()
|
||||||
|
return G.ThePlayer ~= nil and G.TheFrontEnd:GetActiveScreen().name == "HUD"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GetWatch(watchType)
|
||||||
|
if keybinds ~= true then return end
|
||||||
|
local items = G.ThePlayer.replica.inventory:GetItems()
|
||||||
|
local backpack = G.ThePlayer.replica.inventory:GetEquippedItem(G.EQUIPSLOTS.BODY)
|
||||||
|
local watchbag = nil
|
||||||
|
for k, v in pairs(items) do
|
||||||
|
if v.prefab == "pocketwatchpack" then
|
||||||
|
watchbag = v
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if (type(opt) == "table") then
|
local watchbagitems = watchbag and watchbag.replica.container and watchbag.replica.container:GetItems() or nil
|
||||||
opt = opt.option_data
|
local packitems = backpack and backpack.replica.container and backpack.replica.container:GetItems() or nil
|
||||||
|
local watch = nil
|
||||||
|
for k, v in pairs(items) do
|
||||||
|
if v.prefab == watchType and v:HasTag("pocketwatch_inactive") then
|
||||||
|
watch = v
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if watch ~= nil or (packitems == nil and watchbagitems == nil) then return watch end
|
||||||
|
if (packitems ~= nil) then
|
||||||
|
for k, v in pairs(packitems) do
|
||||||
|
if v.prefab == watchType and v:HasTag("pocketwatch_inactive") then
|
||||||
|
watch = v
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if watch ~= nil or watchbagitems == nil then return watch end
|
||||||
|
for k, v in pairs(watchbagitems) do
|
||||||
|
if v.prefab == watchType and v:HasTag("pocketwatch_inactive") then
|
||||||
|
watch = v
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return watch
|
||||||
|
end
|
||||||
|
|
||||||
|
if agelesskey ~= "None" then
|
||||||
|
if keybinds == true then
|
||||||
|
local keybind = G["KEY_"..agelesskey]
|
||||||
|
G.TheInput:AddKeyDownHandler(keybind, function()
|
||||||
|
if not IsInGameplay() then return end
|
||||||
|
local pocketwatch = GetWatch("pocketwatch_heal")
|
||||||
|
if pocketwatch == nil or not G.ThePlayer:HasTag("pocketwatchcaster") then return end
|
||||||
|
act = G.ACTIONS.CAST_POCKETWATCH
|
||||||
|
local buffact = G.BufferedAction(G.ThePlayer, target, act, pocketwatch)
|
||||||
|
if not G.TheWorld.ismastersim then
|
||||||
|
local function cb()
|
||||||
|
G.SendRPCToServer(G.RPC.ControllerUseItemOnSelfFromInvTile, act.code, pocketwatch, target)
|
||||||
|
end
|
||||||
|
if G.ThePlayer.components.locomotor then
|
||||||
|
buffact.preview_cb = cb
|
||||||
|
else
|
||||||
|
cb()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
G.ThePlayer.components.playercontroller:DoAction(buffact)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if backstepkey ~= "None" then
|
||||||
|
if keybinds == true then
|
||||||
|
local keybind2 = G["KEY_"..backstepkey]
|
||||||
|
G.TheInput:AddKeyDownHandler(keybind2, function()
|
||||||
|
if not IsInGameplay() then return end
|
||||||
|
local pocketwatch = GetWatch("pocketwatch_warp")
|
||||||
|
if pocketwatch == nil or not G.ThePlayer:HasTag("pocketwatchcaster") then return end
|
||||||
|
act = G.ACTIONS.CAST_POCKETWATCH
|
||||||
|
local buffact = G.BufferedAction(G.ThePlayer, target, act, pocketwatch)
|
||||||
|
if not G.TheWorld.ismastersim then
|
||||||
|
local function cb()
|
||||||
|
G.SendRPCToServer(G.RPC.ControllerUseItemOnSelfFromInvTile, act.code, pocketwatch, target)
|
||||||
|
end
|
||||||
|
if G.ThePlayer.components.locomotor then
|
||||||
|
buffact.preview_cb = cb
|
||||||
|
else
|
||||||
|
cb()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
G.ThePlayer.components.playercontroller:DoAction(buffact)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if backtrekkey ~= "None" then
|
||||||
|
if keybinds == true then
|
||||||
|
local keybind3 = G["KEY_"..backtrekkey]
|
||||||
|
G.TheInput:AddKeyDownHandler(keybind3, function()
|
||||||
|
if not IsInGameplay() then return end
|
||||||
|
local pocketwatch = GetWatch("pocketwatch_recall")
|
||||||
|
if pocketwatch == nil or not G.ThePlayer:HasTag("pocketwatchcaster") then return end
|
||||||
|
act = G.ACTIONS.CAST_POCKETWATCH
|
||||||
|
local buffact = G.BufferedAction(G.ThePlayer, target, act, pocketwatch)
|
||||||
|
if not G.TheWorld.ismastersim then
|
||||||
|
local function cb()
|
||||||
|
G.SendRPCToServer(G.RPC.ControllerUseItemOnSelfFromInvTile, act.code, pocketwatch, target)
|
||||||
|
end
|
||||||
|
if G.ThePlayer.components.locomotor then
|
||||||
|
buffact.preview_cb = cb
|
||||||
|
else
|
||||||
|
cb()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
G.ThePlayer.components.playercontroller:DoAction(buffact)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
return opt
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local lang = {
|
local lang = {
|
||||||
@ -34,7 +143,7 @@ local lang = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local language = GetConfig("lang", "eng")
|
local language = GetModConfigData("lang")
|
||||||
|
|
||||||
PrefabFiles = { "pocketwatchpack" }
|
PrefabFiles = { "pocketwatchpack" }
|
||||||
Assets = {
|
Assets = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user