Skip to content

harvest

What is gathered from the world and runs out by area, such as the fish of the sea.

Source: src/Moongate.Server.Ultima/Modules/HarvestModule.cs

harvest.amount(resource, map, x, y) -> integer?

How much of the resource is left in the area of the cell x, y of the map; an area is full the first time it is asked for and again some time after the first take. Nil for an unknown resource or a cell below zero.

A fisher that tells a player how the fishing is where it stands:

function old_fisher.on_speech(serial, speaker, text)
local here = npc.location(serial)
local left = harvest.amount("fish", here.map, here.x, here.y) or 0
if left == 0 then
npc.say(serial, "Nothing bites here today.")
else
npc.say(serial, "The water is alive, friend.")
end
end
ParameterTypeDefault
resourcestring
mapMapType | string
xinteger
yinteger

Returns integer?.

harvest.has(resource) -> boolean

Whether data/harvest.toml has a resource of that id, such as 'fish'.

ParameterTypeDefault
resourcestring

Returns boolean.

harvest.take(resource, map, x, y) -> boolean

Takes one of the resource from the area of the cell x, y of the map; false when the area has none left, for an unknown resource or a cell below zero.

A well that gives a bucket of water three times, then runs dry until it fills again. It needs a resource well in data/harvest.toml, with an area of 1 so each well has its own water:

function well.on_use(serial, user)
local here = item.location(serial)
if harvest.take("well", here.map, here.x, here.y) then
item.give(user, "bucket_of_water")
else
mobile.message(user, "The well is dry.")
end
return true
end
ParameterTypeDefault
resourcestring
mapMapType | string
xinteger
yinteger

Returns boolean.

harvest.vein(resource, map, x, y) -> string?

The vein of the area of the cell x, y of the map: the kind of the resource the area is of, such as 'oak' among the wood, one of the [[resource.vein]] of data/harvest.toml, drawn by weight each time the area fills. Nil for a resource without veins, an unknown resource or a cell below zero.

A woodsman that tells a player what wood grows where it stands:

function woodsman.on_speech(serial, speaker, text)
local here = npc.location(serial)
local wood = harvest.vein("wood", here.map, here.x, here.y)
if wood and wood ~= "plain" then
npc.say(serial, "Good " .. wood .. " around here, if you know your axe.")
else
npc.say(serial, "Plain wood, nothing more.")
end
end
ParameterTypeDefault
resourcestring
mapMapType | string
xinteger
yinteger

Returns string?.

Made with ❤️ by Tom

Buy me a coffee