Sign in to follow this  

Recommended Posts

Rockou_    4

So there was a mod on the workshop that got deleted, and it doesnt exist anymore and i really liked that mod(debug/testing map- believe me or not i dont really care if you think im using it to cheat) it changes the player vision to the moggle vision

it uses a simple code but i lost it, id like to know what i did wrong with the following file. if i change something it crashes and if it doesnt it doesnt do anything
Managed to change the nightvision color but if the local night vision absolutely needs the moggle filter i can make a new colour tube set with the moggle filter

Currently it crashes cause of a inst error?
[00:00:44]: [string "../mods/Nightvision/modmain.lua"]:15: attempt to index local 'inst' (a nil value)
LUA ERROR stack traceback:
    ../mods/Nightvision/modmain.lua:15 in (field) fn (Lua) <10-26>
    scripts/events.lua:46 in (method) HandleEvent (Lua) <42-49>
    scripts/input.lua:189 in (method) OnRawKey (Lua) <184-191>
    scripts/input.lua:396 in () ? (Lua) <395-397>

Thanks in advance

Managed to do it myself :

local _G = GLOBAL

local function GetKeyFromConfig(config)
    local key = GetModConfigData(config)
    return key and (type(key) == "number" and key or _G[key])

local function InGame()
    return ThePlayer and ThePlayer.HUD and not ThePlayer.HUD:HasInputFocus()

_G.TheInput:AddKeyUpHandler(GetKeyFromConfig("nv"), function ()
        nvk = not nvk
        if nvk == true then
        _G.ThePlayer.components.talker:Say("Night Vision enabled")
        _G.ThePlayer.components.talker:Say("Night Vision disabled")



night vision

Edited by Rockou_

Share this post

Link to post
Share on other sites
Ultroman    704

You are having trouble, because you think you are getting the inst and self parameters passed to the function you are hooking up to the key-handler, but the key-handlers do not provide any parameters.

Edited by Ultroman

Share this post

Link to post
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
Sign in to follow this