Skip to content

Instantly share code, notes, and snippets.

@Quit
Created July 13, 2015 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Quit/bde9b27217d0cc28aae0 to your computer and use it in GitHub Desktop.
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
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