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
Functions
Section titled “Functions”amount
Section titled “amount”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.") endend| Parameter | Type | Default |
|---|---|---|
resource | string | |
map | MapType | string | |
x | integer | |
y | integer |
Returns integer?.
harvest.has(resource) -> booleanWhether data/harvest.toml has a resource of that id, such as 'fish'.
| Parameter | Type | Default |
|---|---|---|
resource | string |
Returns boolean.
harvest.take(resource, map, x, y) -> booleanTakes 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 trueend| Parameter | Type | Default |
|---|---|---|
resource | string | |
map | MapType | string | |
x | integer | |
y | integer |
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.") endend| Parameter | Type | Default |
|---|---|---|
resource | string | |
map | MapType | string | |
x | integer | |
y | integer |
Returns string?.
Made with ❤️ by Tom
