hey help plz lua code

Discussion in 'Programming' started by Johny2, May 17, 2024.

  1. Johny2

    Johny2
    Expand Collapse

    Joined:
    Aug 10, 2022
    Messages:
    10
    plz help me i need help with the mod i want to have a key that will scramble the power and torque at a amount in a car so i have the keys set up but it doesn't do anything and i have a little lua code but i have no clue how to code lua so if i can get help with that that wound be great and here is the lua code thx
    Code:
    local M = {}
    local maxPossiblePressure
    
    local function init()
        electrics.values.Scramble = 0
    end
    
    local function updateGFX(dt)
        if electrics.values.Scramble == 50  then
            local efficiency = 40
            gui.message("Scramble", 0, "^Scramble\\.")
        elseif electrics.values.Scramble == 0 then
            gui.message("unscramble", 0, "^Scramble\\.")
            local efficiency = 10
        end
     
    end
    
        --print(electrics.values.Scramble)
    -- public interface
    M.updateGFX      = updateGFX
    M.onInit      = init
    M.onReset     = init
    return M
     
    #1 Johny2, May 17, 2024
    Last edited: May 18, 2024
  2. NuclearKnight

    NuclearKnight
    Expand Collapse

    Joined:
    Nov 30, 2013
    Messages:
    78
    Unless the torque/power stuff works in a way I don't know about, it's probably not a good idea to put that logic in that function, as it runs once per graphics update and would be checking against those values constantly.

    If it is going to be activated by a keybind, need to make it like an event that only triggers when you call it, not every frame
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice