Jump to content

Need help about toggle key to display some status ...


Recommended Posts

Greeting Modder.

I just finish some content of my mod and found problem I can't solve by myself.

My mod can eat gems to rise his level and problem is I can't write codes that press a key to display status. (Screenshot to explain what I wan to do)

[ Form Mod : [DST] Musha ]

Spoiler

BMV-LXpN5241Ms8BhIOkMC_h-5yGOAjEKkYrN1w6

the simple explain what I want is I press key L on keyboard and then my level show up like that screenshot

I try to read other mod code, copy them or try to write but still got error......

Could someone guide me please ? It's would be pleasure, Thank you so much

Here it is my mod : 



Edit : forgot to attach my mod Orz 

Edited by K41zel2
Link to comment
Share on other sites

current, I can type and say a word.

in "scripts/components" codes are

Spoiler

local ThePlayer = GLOBAL.ThePlayer
local TheInput = GLOBAL.TheInput
local TheNet = GLOBAL.TheNet
local SpawnPrefab = GLOBAL.SpawnPrefab

local KEY_X = GLOBAL.KEY_X
AddModRPCHandler(modname, "X", function(player)
    if not player:HasTag("playerghost") then
        player.components.talker:Say("....")
    end
end)

local kaizer_handlers = {}
AddPlayerPostInit(function(inst)
    inst:DoTaskInTime(0, function()
    if inst == GLOBAL.ThePlayer then
        if inst.prefab == "kaizer" then
            kaizer_handlers[0] = TheInput:AddKeyDownHandler(KEY_X, function()
            local screen = GLOBAL.TheFrontEnd:GetActiveScreen()
            local IsHUDActive = screen and screen.name == "HUD"
                if inst:IsValid() and IsHUDActive then
                SendModRPCToServer(MOD_RPC[modname]["X"])
                end
            end)
            else
            kaizer_handlers[0] = nil
            end 
        end
        end)
end)

So now a problem is can I use inst or data in "prefabs/character.lua" and how ?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...