Skip to content

Commit

Permalink
Merge pull request #1 from ascense/lightlyweathered
Browse files Browse the repository at this point in the history
Add sample mod 'Lightly Weathered'
  • Loading branch information
Ryhon0 authored Oct 9, 2024
2 parents 109cab3 + 9106883 commit 4fcf904
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sample_mods/LightlyWeathered/mod.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[mod]
name="Lightly Weathered"
id="lightly-weathered"
version="1.0.0"

[autoload]
0="res://mods/LightlyWeathered/Main.gd"
11 changes: 11 additions & 0 deletions sample_mods/LightlyWeathered/mods/LightlyWeathered/Main.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends Node

func _ready():
overrideScript("res://mods/LightlyWeathered/Transition.gd")
queue_free()

func overrideScript(overrideScriptPath : String):
var script : Script = load(overrideScriptPath)
script.reload()
var parentScript = script.get_base_script()
script.take_over_path(parentScript.resource_path)
60 changes: 60 additions & 0 deletions sample_mods/LightlyWeathered/mods/LightlyWeathered/Transition.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
extends "res://Scripts/Transition.gd"

var preferences: Preferences

func Interact():
if not deactivated and not tutorialExit:
ProgressWeather()

super()

if not deactivated and not tutorialExit:
SetMusic()

func ProgressWeather():
if shelterExit:
if randf() < 0.15:
gameData.season = (gameData.season % 2) + 1

if randf() < 0.5:
if randf() < 0.75:
gameData.TOD = (randi() % 2) + 1
else:
gameData.TOD = (randi() % 4) + 1

else:
if (gameData.TOD == 2 && randf() < 0.33) or (gameData.TOD != 2 && randf() < 0.5):
gameData.TOD = (gameData.TOD % 4) + 1

if randf() < 0.15:
gameData.aurora = true
else:
gameData.aurora = false

if randf() < 0.5:
if randf() < 0.75:
gameData.weather = 1
else:
gameData.weather = (randi() % 4) + 1

preferences = Preferences.Load()
preferences.season = gameData.season
preferences.TOD = gameData.TOD
preferences.weather = gameData.weather
preferences.aurora = gameData.aurora
preferences.Save()

func SetMusic():
if gameData.shelter:
gameData.musicPreset = 1
elif gameData.permadeath:
gameData.musicPreset = 4
elif gameData.currentMap == "Minefield":
gameData.musicPreset = 3
else:
gameData.musicPreset = 2

preferences = Preferences.Load()
if preferences.musicPreset != gameData.musicPreset:
preferences.musicPreset = gameData.musicPreset
preferences.Save()

0 comments on commit 4fcf904

Please sign in to comment.