Facebook
From Paltry Horse, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 50
  1. -- Soul Filcher's Vehicle Tweaker Core: an API for tweaking existing vehicles without redefining them entirely.
  2. -- Modified from DarkSlayerEX's Item Tweaker
  3. --Initializes the tables needed for the code to run
  4. if not VehicleTweaker then  VehicleTweaker = {} end
  5. if not TweakVehicle then  TweakVehicle = {} end
  6. if not TweakVehicleData then  TweakVehicleData = {} end
  7.  
  8. --Prep code to make the changes to all vehicles in the TweakVehicleData table.
  9. function VehicleTweaker.tweakVehicles()
  10.         local vehicle;
  11.         for k,v in pairs(TweakVehicleData) do
  12.                 for t,y in pairs(v) do
  13.                         vehicle = ScriptManager.instance:getVehicle(k);        
  14.                         if vehicle ~= nil then
  15.                                 local module, name = k:match"([^.]*).(.*)"
  16.                                 vehicle:Load(name, "{"..t.."="..y..",".."}");
  17.                                 print(k..": "..t..", "..y);
  18.                         end
  19.                 end
  20.         end
  21. end
  22.  
  23. function TweakVehicle(vehicleName, vehicleProperty, propertyValue)
  24.         if not TweakVehicleData[vehicleName] then
  25.                 TweakVehicleData[vehicleName] = {};
  26.         end
  27.         TweakVehicleData[vehicleName][vehicleProperty] = propertyValue;
  28. end
  29.  
  30. Events.OnGameBoot.Add(VehicleTweaker.tweakVehicles)
  31.  
  32.  
  33. --[[
  34. -------------------------------------------------
  35. --------------------IMPORTANT--------------------
  36. -------------------------------------------------
  37.  
  38. You can make compatibility patches, allowing tweaks to only be applied under the proper circumstances.
  39. Example:
  40.  
  41.  
  42.                 TweakVehicleData["MyMod.MyVehicle"] = { ["mechanicType"] = "3" };
  43.                
  44.                 if getActivatedMods():contains("PaintItBlack") then
  45.                         TweakVehicleData["MyMod.MyVehicle"] = { ["forcedColor"] = "0.0 0.0 0.0" };
  46.                 end
  47.                
  48.  
  49. ]]
  50.  
  51. -- EXTEND VEHICLE TWEAKER API by Aiteron
  52.  
  53. if not TweakVehicleAreaData then  TweakVehicleAreaData = {} end
  54.  
  55. function tweakVehiclesAreas()
  56.     local vehicle;
  57.     for k,v in pairs(TweakVehicleAreaData) do
  58.         for t,y in pairs(v) do
  59.             vehicle = ScriptManager.instance:getVehicle(k);    
  60.             if vehicle ~= nil then
  61.                 local module, name = k:match"([^.]*).(.*)"
  62.                 vehicle:Load(name, "{".. t .."\n{\n"..y..",".."\n}\n");
  63.                 print(k..": "..t..", "..y);
  64.             end
  65.         end
  66.     end
  67. end
  68.  
  69. function TweakVehicleArea(vehicleName, vehicleProperty, propertyValue)
  70.     if not TweakVehicleAreaData[vehicleName] then
  71.         TweakVehicleAreaData[vehicleName] = {};
  72.     end
  73.     TweakVehicleAreaData[vehicleName][vehicleProperty] = propertyValue;
  74. end
  75.  
  76. Events.OnGameBoot.Add(tweakVehiclesAreas)