LUADOC - Farming Simulator 17

Printable Version

BeehivePlaceable

Description
Class for placeable beehives
Parent
Placeable
Functions

new

Description
Creating placeable beehive
Definition
new(boolean isServer, boolean isClient, table customMt)
Arguments
booleanisServeris server
booleanisClientis client
tablecustomMtcustom metatable
Return Values
tableinstanceInstance of object
Code
18function BeehivePlaceable:new(isServer, isClient, customMt)
19 local mt = customMt;
20 if mt == nil then
21 mt = BeehivePlaceable_mt;
22 end;
23
24 local self = Placeable:new(isServer, isClient, mt);
25
26 registerObjectClassName(self, "BeehivePlaceable");
27
28 return self;
29end;

delete

Description
Deleting placeable beehive
Definition
delete()
Code
33function BeehivePlaceable:delete()
34 unregisterObjectClassName(self);
35 g_currentMission.environment:removeHourChangeListener(self);
36 if self.particleSystem ~= nil then
37 ParticleUtil.deleteParticleSystem(self.particleSystem);
38 end;
39 BeehivePlaceable:superClass().delete(self);
40end;

deleteFinal

Description
Deleting placeable beehive final
Definition
deleteFinal()
Code
44function BeehivePlaceable:deleteFinal()
45 BeehivePlaceable:superClass().deleteFinal(self);
46end;

load

Description
Load beehive
Definition
load(string xmlFilename, float x, float y, float z, float rx, float ry, float rz, boolean initRandom)
Arguments
stringxmlFilenamexml file name
floatxx world position
floatyz world position
floatzz world position
floatrxrx world rotation
floatryry world rotation
floatrzrz world rotation
booleaninitRandominitialize random
Return Values
booleansuccesssuccess
Code
59function BeehivePlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom)
60 if not BeehivePlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then
61 return false;
62 end;
63
64 local xmlFile = loadXMLFile("TempXML", xmlFilename);
65
66 self.particleSystem = {};
67 ParticleUtil.loadParticleSystem(xmlFile, self.particleSystem, "placeable.particleSystem", self.nodeId, true, nil, self.baseDirectory);
68
69 delete(xmlFile);
70
71 return true;
72end;

finalizePlacement

Description
Called if placeable is placed
Definition
finalizePlacement()
Code
76function BeehivePlaceable:finalizePlacement()
77 BeehivePlaceable:superClass().finalizePlacement(self);
78end

hourChanged

Description
Called if hour changed
Definition
hourChanged()
Code
82function BeehivePlaceable:hourChanged()
83 if self.isServer then
84 g_currentMission:addSharedMoney(self.incomePerHour, "propertyIncome");
85 g_currentMission:addMoneyChange(self.incomePerHour, EconomyManager.MONEY_TYPE_PROPERTY_INCOME);
86 end;
87end;