API:GetCultivationInfo
From RoR Wiki
UI Lua API · Crafting functions
Version: WAR 1.4.8
Returns the state of one of the player's cultivation plots.
plot = GetCultivationInfo(plotNumber)
Arguments
- plotNumber
number– Plot number, starting at 1. It is rounded down.
Returns
- plot
table– Plot table, see below.
| Key | Type | Meaning |
|---|---|---|
StageNum |
number |
Growth stage, 0–5. 255 for an empty plot. |
TotalTimer |
number |
Seconds left until the plant is done. 0 for an empty plot. |
StageTimer |
number |
Seconds left in the current stage. 0 for an empty plot. |
Locked |
boolean |
– |
Seed |
table |
Item data table of the planted seed. A blank item table for an empty plot. |
Additives |
table |
Three item data tables with the keys 2, 3 and 4, one per additive type. The stock UI indexes it with GameData.CultivationTypes.SOIL, WATERCAN and NUTRIENT. Blank item tables for an empty plot.
|
PlantName |
wstring |
Name of the plant. In stages 4 and 5 this is the name the client received for the grown plant; in earlier stages it is the seed's name. L"" for an empty plot.
|
PlantCount |
number |
In stages 4 and 5, the number received for the grown plant; in earlier stages 1. 0 for an empty plot. |
Details
- Timers are stored by the client in milliseconds and returned in whole seconds.
- The data is what the client last received for the plot. The stock UI asks the server for fresh data with UpdateCraftingStatus
(3, 4, plotNumber). - The client does not range-check
plotNumber. Use the plot numbers the stock UI uses (1 toCultivationWindow.NUM_OF_PLOTS). - If there is no player object or the Lua state is not available, nothing is returned.
- Exactly one argument must be passed.
Errors
None besides the generic Invalid Parameters message when the argument is missing or not a number.
Example
From default/ea_cultivationwindow/source/cultivationwindow.lua:
local plotData = GetCultivationInfo( plotNum )
CultivationWindow.plot[plotNum] = plotData
local stageInfo = CultivationWindow.stageInfo[plotData.StageNum]
...
elseif plotData.StageNum == 255
then
stageInfo = CultivationWindow.stageInfo[GameData.CultivationStage.EMPTY]
Checking the additives, from the same file:
WindowSetShowing( windowName.."SinglePlotNutrientIcon", plotData.Additives[GameData.CultivationTypes.NUTRIENT].id ~= 0 ) WindowSetShowing( windowName.."SinglePlotWaterIcon", plotData.Additives[GameData.CultivationTypes.WATERCAN].id ~= 0 ) WindowSetShowing( windowName.."SinglePlotSoilIcon", plotData.Additives[GameData.CultivationTypes.SOIL].id ~= 0 )
