1. Welcome to the official Starbound Mod repository, Guest! Not sure how to install your mods? Check out the installation guide or check out the modding help thread for more guides.
    Outdated Mods have been moved to their own category! If you update your mod please let a moderator know so we can move it back to the active section.
    Dismiss Notice
  2. Hey Guest! Our new game Wargroove has released! Check out the forums or wiki for more information!
    Dismiss Notice

Vanilla Mechs : Energy Use Example mod 2016-08-18

Vehicle Modder Resource - make your vehicles use energy!

  1. LoPhatKao
    Requires 'Vanilla Mechs' for "mod" to work

    Example mod for making vehicles use energy from players, like old tech.consumeTechEnergy().
    Follow instructions in "readme - energy.txt"


    hi there, welcome to the readme for the vanilla mechs energy patch example
    if you're reading this, yay! you obviously want to add energy use to your vehicle :D

    until CF adds a way for vehicles to use energy directly, this workaround is probably going to be it
    i hope they do :D even tho that would render this obsolete

    required:
    text editor of choice
    a working vehicle ;)
    a brain :D

    procedure:
    -- follow directions closely - don't edit stuff you don't need to! it'll break your vehicle!

    part 1 : copy/rename the status effect
    copy the /stats folder to your vehicle mod directory --> /mods/<yourmodname>/stats
    open /stats/effects/vmech_energyuse/vmech_energyuse.statuseffect in text editor
    change "name" from "vmech_energyuse" to '<uniquename>_energyuse'
    save and close the .statuseffect file -- Remember what you changed "name" to! need for part 2
    rename 'vmech_energyuse.statuseffect' to '<uniquename>_energyuse.statuseffect'
    go back to /stats/effects/, rename 'vmech_energyuse' folder to '<uniquename>_energyuse'
    done part 1!

    part 2 : adding status effect to .vehicle file
    open your /vehicles/<path_to_vehicle>/<vehiclename>.vehicle' file
    find the section "loungePositions"
    take note of the seatname that needs to use energy - ie: "seat" - you will need it for part 3!
    if there is not a 'statusEffects' section in the seat, you need to create it - WATCH YOUR COMMAS
    -- "statusEffects" : ["<uniquename>_energyuse"]
    or just add it to list that exists
    done part 2!

    part 3 : editing the <vehicle>.lua (the 'worst' part - ohnoes!)
    - all relevant sections can be found by searching for 'vmech_energyuse' in supplied mech.lua
    - unarmored players only have 100 energy - choose your usage numbers carefully

    ----init()
    copy/paste the energy use section - 2 variables and 2 functions
    rename "seat" where indicated with seatname from part 2, add more seats if needed

    ----update()
    required: self.energyToUse[<seatname>] initialize line(s) near beginning, before controlHeld checks
    required: the k,v pairs loop at end of update, to use energy for each seat that used energy this frame

    check for ""self.energyLocked[<seatname>] and vehicle.controlHeld(<seatname>,~~)"" to block actions when player is out of energy
    to set energy use; self.energyToUse[<seatname>] = self.energyToUse[<seatname>] + n , where n = amount of energy to use
    Mod Pack Permissions:
    Anyone can use this mod in their mod compilation without the author's consent.
    Mod Assets Permissions:
    Anyone can alter/redistribute the mod's assets without the author's consent.