Script v1.4.4.0
Engine v7.0.0.2
- General
- Entity
- Node
- Scenegraph
- Lighting
- Camera
- Shape
- Particle System
- Physics
- Spline
- Animation
- Overlays
- Sound
- Input
- XML
- Network
- Callbacks
- Text Rendering
- Terrain Detail
- Tire Track
- Editor
- Rendering
- String
- Math
- I3D
- Fillplanes
Foundation Reference
SaplingPallet
DescriptionClass for sapling palletsFunctions
new
DescriptionCreating sapling palletDefinition
new(boolean isServer, boolean isClient, table customMt)Arguments
boolean | isServer | is server |
boolean | isClient | is client |
table | customMt | customMt |
table | instance | Instance of object |
18 | function SaplingPallet:new(isServer, isClient, customMt) |
19 | local mt = customMt; |
20 | if mt == nil then |
21 | mt = SaplingPallet_mt; |
22 | end; |
23 | |
24 | local self = FillablePallet:new(isServer, isClient, mt); |
25 | |
26 | registerObjectClassName(self, "SaplingPallet"); |
27 | |
28 | self.fillType = FillUtil.FILLTYPE_TREESAPLINGS; |
29 | self.fillLevel = 0; |
30 | self.capacity = 20; |
31 | self.synchronizeFillLevel = false; |
32 | |
33 | return self; |
34 | end; |
delete
DescriptionDeleting sapling palletDefinition
delete()Code
38 | function SaplingPallet:delete() |
39 | if self.saplingFilename ~= nil then |
40 | Utils.releaseSharedI3DFile(self.saplingFilename, nil, true); |
41 | end; |
42 | unregisterObjectClassName(self); |
43 | SaplingPallet:superClass().delete(self); |
44 | end; |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
50 | function SaplingPallet:readStream(streamId, connection) |
51 | SaplingPallet:superClass().readStream(self, streamId, connection); |
52 | local fillLevel = streamReadUInt8(streamId); |
53 | self:setFillLevel(fillLevel, false); |
54 | end; |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
60 | function SaplingPallet:writeStream(streamId, connection) |
61 | SaplingPallet:superClass().writeStream(self, streamId, connection); |
62 | streamWriteUInt8(streamId, self.fillLevel); |
63 | end; |
readUpdateStream
DescriptionCalled on client side on updateDefinition
readUpdateStream(integer streamId, integer timestamp, table connection)Arguments
integer | streamId | stream ID |
integer | timestamp | timestamp |
table | connection | connection |
70 | function SaplingPallet:readUpdateStream(streamId, timestamp, connection) |
71 | SaplingPallet:superClass().readUpdateStream(self, streamId, timestamp, connection); |
72 | if connection:getIsServer() then |
73 | if not self.synchronizeFillLevel then |
74 | if streamReadBool(streamId) then |
75 | local fillLevel = streamReadUInt8(streamId); |
76 | self:setFillLevel(fillLevel, false); |
77 | end |
78 | end; |
79 | end |
80 | end; |
writeUpdateStream
DescriptionCalled on server side on updateDefinition
writeUpdateStream(integer streamId, table connection, integer dirtyMask)Arguments
integer | streamId | stream ID |
table | connection | connection |
integer | dirtyMask | dirty mask |
87 | function SaplingPallet:writeUpdateStream(streamId, connection, dirtyMask) |
88 | SaplingPallet:superClass().writeUpdateStream(self, streamId, connection, dirtyMask); |
89 | if not connection:getIsServer() then |
90 | if not self.synchronizeFillLevel then |
91 | if streamWriteBool(streamId, bitAND(dirtyMask, self.fillablePalletDirtyFlag) ~= 0) then |
92 | streamWriteUInt8(streamId, self.fillLevel); |
93 | end |
94 | end; |
95 | end |
96 | end; |
setNodeId
DescriptionSet node idDefinition
setNodeId(integer nodeId)Arguments
integer | nodeId | node Id |
101 | function SaplingPallet:setNodeId(nodeId) |
102 | SaplingPallet:superClass().setNodeId(self, nodeId); |
103 | |
104 | self.capacity = Utils.getNoNil(tonumber(getUserAttribute(nodeId, "capacity")), self.capacity); |
105 | |
106 | self.saplingFilename = getUserAttribute(nodeId, "saplingFilename"); |
107 | if self.saplingFilename ~= nil then |
108 | if self.visibilityNodes ~= nil then |
109 | self.saplingFilename = Utils.getFilename(self.saplingFilename, self.baseDirectory) |
110 | local i3dNode = Utils.loadSharedI3DFile(self.saplingFilename); |
111 | self.capacity = getNumOfChildren(self.visibilityNodes); |
112 | if i3dNode ~= 0 and self.capacity > 0 then |
113 | for i=0, self.capacity-1 do |
114 | local node = clone(i3dNode, false, false, false); |
115 | link(getChildAt(self.visibilityNodes, i), node); |
116 | if getUserAttribute(nodeId, "useRandomRot") then |
117 | setRotation(node, 0, math.random(0, 2*math.pi), 0); |
118 | end; |
119 | end; |
120 | self:setFillLevel(Utils.getNoNil(tonumber(getUserAttribute(nodeId, "startFillLevel")), 0), false); |
121 | end; |
122 | else |
123 | print("Warning: fillNodeFillename requires use of visibilityNodes"); |
124 | end; |
125 | end; |
126 | |
127 | local treeType = getUserAttribute(nodeId, "treeType"); |
128 | if treeType ~= nil then |
129 | local tree = TreePlantUtil.treeTypes[treeType]; |
130 | if tree == nil then |
131 | print("Warning: Invalid treeType '"..treeType.."'."); |
132 | tree = next(TreePlantUtil.treeTypes); |
133 | end; |
134 | self.treeType = tree.index; |
135 | else |
136 | self.treeType = next(TreePlantUtil.treeTypes).index; |
137 | print("Warning: Missing treetype!"); |
138 | end; |
139 | end; |