Jump to content

Advanced Scripting Help


GeneralGred

Recommended Posts

Yes, I completely forgot the variable list, sorry. Here are the relevant variables for the script above:

short initialized
float last_tick
float time_passed
float current_thirst
float current_hunger
float current_sleep
float old_thirst
float old_hunger
float old_sleep

Except for the boolean initialized var, they're all floats as they deal with values returned from or modified by GameDaysPassed.

Edited by Ladez
Link to comment
Share on other sites

So with some modifications and some luck I have successfully turned your script into a script for dynamic fuel consumption! I can't thank both of you enough, I never thought this script could work without some fault but at last it works! In case your curious here is the refined script for my generator:

 

float LastTick
float FuelLevel
float StoredFuelLevel

 

;Power Systems
if (FuelLevel < 0)
set FuelLevel to 0
endif

if (GMGeneratorPanelTier1Ref.GetDisabled == 0)
if (GMGeneratorPanelTier1Ref.Running == 1)
set PowerTier to 1
if (FuelLevel >= 1) && (FuelConsumption != 1)
set LastTick to GameDaysPassed
Set FuelConsumption to 1
elseif (FuelLevel <= 0)
set GMGeneratorPanelTier1Ref.Running to 0
endif
elseif (GMGeneratorPanelTier1Ref.Running == 0)
set PowerTier to 0
set FuelConsumption to 0
endif
endif

if (GMGeneratorPanelTier2Ref.GetDisabled == 0)
if (GMGeneratorPanelTier2Ref.Running == 1)
set PowerTier to 2
if (FuelLevel >= 1) && (FuelConsumption != 1)
set LastTick to GameDaysPassed
Set FuelConsumption to 1
elseif (FuelLevel <= 0)
set GMGeneratorPanelTier1Ref.Running to 0
endif
elseif (GMGeneratorPanelTier1Ref.Running == 0)
set PowerTier to 0
set FuelConsumption to 0
endif
endif

if (FuelConsumption == 1)
set StoredFuelLevel to FuelLevel
set GeneratorRuntime to GameDaysPassed - LastTick
set FuelLevel to FuelLevel - GeneratorRuntime * 1440
set LastTick to GameDaysPassed
endif

Edited by General Gred
Link to comment
Share on other sites

@ GeneralGred: glad you got this working. It's a very cool concept in that most places outside the strip kinda needed an explanation for where they get power from. I really like little touches of realism like that. Sorry I ended up with less time to try to help with it than I initially anticipated, but I'm very glad you managed to get this working.

 

@ ladez: I had no idea gameDaysPassed could work like that. I may see if I can use that in place of the timer I was using for vertibird travel scripting. That's a handy little trick.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...