Skip to content

Instantly share code, notes, and snippets.

@Quit
Last active August 29, 2015 13:56
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/bb8371d8380b15002450 to your computer and use it in GitHub Desktop.
Save Quit/bb8371d8380b15002450 to your computer and use it in GitHub Desktop.
local MOD = class()
local entity_name = 'my_mod:apple_tree'
function MOD:get_tree_type(event)
if event.elevation > MIN_ALTITUDE and event.elevation < MAX_ALTITUDE then
table.insert(event.proposals, entity_name)
end
end
function MOD:get_tree_name(event)
if event.type == entity_name then
table.insert(event.proposals, { name = entity_name, priority = math.huge }) -- or use random/event.size to determine a proper size
end
end
function MOD:__init()
radiant.events.listen(stonehearth.world_generation, 'rp:get_tree_type', self, self.get_tree_type)
radiant.events.listen(stonehearth.world_generation, 'rp:get_tree_name', self, self.get_tree_name)
end
return MOD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment