Skip to content

Commit

Permalink
Store registered plant on namespace
Browse files Browse the repository at this point in the history
Handy for when modders want to use these definitions to extend or add to the mod
  • Loading branch information
bas080 authored and rubenwardy committed Oct 11, 2016
1 parent 6fdfd25 commit 78311a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions game_api.txt
Expand Up @@ -183,6 +183,9 @@ The farming API allows you to easily register plants and hoes.
`farming.register_plant(name, Plant definition)`
* Register a new growing plant, see [#Plant definition]

`farming.registered_plants[name] = definition`
* Table of registered plants, indexed by plant name

### Hoe Definition


Expand Down
4 changes: 4 additions & 0 deletions mods/farming/api.lua
@@ -1,6 +1,8 @@

-- Wear out hoes, place soil
-- TODO Ignore group:flower
farming.registered_plants = {}

This comment has been minimized.

Copy link
@bas080

bas080 Oct 13, 2016

Author Contributor

It indeed does not

This comment has been minimized.

Copy link
@sofar

sofar Oct 13, 2016

Contributor

The declaration of farming.registered_plants should just move to above the comments here. This can be done on merge by @paramat, really.

This comment has been minimized.

Copy link
@sofar

sofar Oct 13, 2016

Contributor

Ah, didn't see it was already merged.

farming.hoe_on_use = function(itemstack, user, pointed_thing, uses)
local pt = pointed_thing
-- check if pointing at a node
Expand Down Expand Up @@ -263,6 +265,8 @@ farming.register_plant = function(name, def)
def.fertility = {}
end

farming.registered_plants[pname] = def

-- Register seed
local lbm_nodes = {mname .. ":seed_" .. pname}
local g = {seed = 1, snappy = 3, attached_node = 1}
Expand Down

0 comments on commit 78311a2

Please sign in to comment.