-
-
Save Quit/bde9b27217d0cc28aae0 to your computer and use it in GitHub Desktop.
Overriding the trapping grounds component to add a critter, multiple mods safe variant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MyMod:_on_init() | |
local component = radiant.mods.require('stonehearth.components.trapping_grounds_component.trapping_ground_component') | |
local old_initialize = component.initialize | |
function component:initialize(...) | |
local ret = { old_initialize(self, ...) } | |
self._spawnable_critters = self._spawnable_critters or { 'stonehearth:rabbit', 'stonehearth:racoon', 'stonehearth:red_fox', 'stonehearth:squirrel' } | |
table.insert(self._spawnable_critters, 'my_mod:some_critter') | |
return unpack(ret) | |
end | |
function component:_choose_spawned_critter_type() | |
return self._spawnable_critters[rng:get_int(1, #self._spawnable_critters)] | |
end | |
end | |
radiant.events.listen(radiant, 'radiant:required_loaded', MyMod, MyMod._on_init) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment