REFUEL VEHICLE OPTION

Discussion in 'Content Creation' started by over_the_reckoning, Feb 23, 2024.

  1. over_the_reckoning

    over_the_reckoning
    Expand Collapse

    Joined:
    Aug 7, 2020
    Messages:
    19
    Pardon me...
    Can You help me about creating a script in a LUA Trigger in order to refuel vehicle at passage thru the station ?? Thanks a lot.

    upload_2024-2-23_11-56-18.png


    Each time i want to refuel I use the console prompt and the following command line:

    energyStorage.getStorage('mainTank'):setRemainingRatio(1)

    or
    energyStorage.reset()

    But there's another option in East Coast... You drive to the fuel pump and a popup appears with two choices, refuel or cancel.
    Now I have to use this function in a LUA Trigger put beside the pump...
    I've tried to do that but failed to make a working script.

    (In the photo, the gas station at the end of the tunnel in "Endless Tunnel" map.)



    upload_2024-2-23_11-56-18.png
     
    #1 over_the_reckoning, Feb 23, 2024
    Last edited: Feb 23, 2024
  2. SineMatic

    SineMatic
    Expand Collapse

    Joined:
    Nov 17, 2022
    Messages:
    62
    The following code refuels all energy storages of the vehicle entering the Lua Trigger:

    Code:
    local function refuel(data)
        if data.event == 'enter' then
            be:getObjectByID(data.subjectID):queueLuaCommand('for i, storage in pairs(energyStorage.getStorages()) do storage.storedEnergy = storage.energyCapacity * clamp(1, 0, 1) end')
        end
    end
    
    refuel
     
    • Like Like x 1
  3. over_the_reckoning

    over_the_reckoning
    Expand Collapse

    Joined:
    Aug 7, 2020
    Messages:
    19
    Interesting... thanks so much, I'll insert this script later and see if it works.
     
  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