Script v1.4.4.0
- Handtools
- Events
- Objects
- Placeables
- AnimatedObjectPlaceable
- BeehivePlaceable
- GreenhousePlaceable
- HayLoftPlaceable
- HeatingPlantPlaceable
- HighPressureWasherPlaceab...
- Placeable
- SolarCollectorPlaceable
- WindTurbinePlaceable
- Triggers
- Utils
- Vehicles
- Specializations
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
AnimatedObjectPlaceable
DescriptionClass for placeable shedParent
PlaceableFunctions
- new
- delete
- load
- finalizePlacement
- readStream
- writeStream
- loadFromAttributesAndNodes
- getSaveAttributesAndNodes
new
DescriptionCreating placeable shedDefinition
new(boolean isServer, boolean isClient, table customMt)Arguments
boolean | isServer | is server |
boolean | isClient | is client |
table | customMt | custom metatable |
table | instance | Instance of object |
18 | function AnimatedObjectPlaceable:new(isServer, isClient, customMt) |
19 | local mt = customMt; |
20 | if mt == nil then |
21 | mt = AnimatedObjectPlaceable_mt; |
22 | end; |
23 | |
24 | local self = Placeable:new(isServer, isClient, mt); |
25 | |
26 | registerObjectClassName(self, "AnimatedObjectPlaceable"); |
27 | |
28 | return self; |
29 | end; |
delete
DescriptionDeleting placeable hay loftDefinition
delete()Code
33 | function AnimatedObjectPlaceable:delete() |
34 | if self.animatedObjects ~= nil then |
35 | for i=1, #self.animatedObjects do |
36 | local animatedObject = self.animatedObjects[i] |
37 | animatedObject:unregister(true) |
38 | animatedObject:delete() |
39 | end |
40 | end |
41 | |
42 | unregisterObjectClassName(self); |
43 | AnimatedObjectPlaceable:superClass().delete(self); |
44 | end; |
load
DescriptionLoad hay loftDefinition
load(string xmlFilename, float x, float y, float z, float rx, float ry, float rz, boolean initRandom)Arguments
string | xmlFilename | xml file name |
float | x | x world position |
float | y | z world position |
float | z | z world position |
float | rx | rx world rotation |
float | ry | ry world rotation |
float | rz | rz world rotation |
boolean | initRandom | initialize random |
boolean | success | success |
57 | function AnimatedObjectPlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom) |
58 | if not AnimatedObjectPlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then |
59 | return false; |
60 | end; |
61 | |
62 | local xmlFile = loadXMLFile("TempXML", xmlFilename); |
63 | |
64 | self.animatedObjectNodes = {} |
65 | self.animatedObjects = {} |
66 | |
67 | local i = 0 |
68 | while true do |
69 | local key = string.format("placeable.animatedObjects.animatedObject(%d)", i) |
70 | if not hasXMLProperty(xmlFile, key) then |
71 | break |
72 | end |
73 | |
74 | local node = Utils.indexToObject(self.nodeId, getXMLString(xmlFile, key.."#index")) |
75 | if node ~= nil then |
76 | table.insert(self.animatedObjectNodes, node) |
77 | end |
78 | i = i + 1 |
79 | end |
80 | |
81 | delete(xmlFile); |
82 | |
83 | return true; |
84 | end; |
finalizePlacement
DescriptionCalled if placeable is placedDefinition
finalizePlacement()Code
88 | function AnimatedObjectPlaceable:finalizePlacement() |
89 | AnimatedObjectPlaceable:superClass().finalizePlacement(self); |
90 | |
91 | for _, node in pairs(self.animatedObjectNodes) do |
92 | local animatedObject = AnimatedObject:new(self.isServer, self.isClient) |
93 | animatedObject.baseDirectory = self.baseDirectory |
94 | animatedObject.customEnvironment = self.customEnvironment |
95 | if animatedObject:load(node) then |
96 | animatedObject:register(true) |
97 | table.insert(self.animatedObjects, animatedObject) |
98 | end |
99 | end |
100 | end |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
106 | function AnimatedObjectPlaceable:readStream(streamId, connection) |
107 | AnimatedObjectPlaceable:superClass().readStream(self, streamId, connection); |
108 | if connection:getIsServer() then |
109 | for i=1, #self.animatedObjects do |
110 | local animatedObject = self.animatedObjects[i] |
111 | local animatedObjectId = readNetworkNodeObjectId(streamId); |
112 | animatedObject:readStream(streamId, connection); |
113 | g_client:finishRegisterObject(animatedObject, animatedObjectId); |
114 | end |
115 | end |
116 | end |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
122 | function AnimatedObjectPlaceable:writeStream(streamId, connection) |
123 | AnimatedObjectPlaceable:superClass().writeStream(self, streamId, connection); |
124 | if not connection:getIsServer() then |
125 | for i=1, #self.animatedObjects do |
126 | local animatedObject = self.animatedObjects[i] |
127 | writeNetworkNodeObjectId(streamId, animatedObject.id) |
128 | animatedObject:writeStream(streamId, connection) |
129 | g_server:registerObjectInStream(connection, animatedObject) |
130 | end |
131 | end |
132 | end |
loadFromAttributesAndNodes
DescriptionLoading from attributes and nodesDefinition
loadFromAttributesAndNodes(integer xmlFile, string key, boolean resetVehicles)Arguments
integer | xmlFile | id of xml object |
string | key | key |
boolean | resetVehicles | reset vehicles |
boolean | success | success |
140 | function AnimatedObjectPlaceable:loadFromAttributesAndNodes(xmlFile, key, resetVehicles) |
141 | if not AnimatedObjectPlaceable:superClass().loadFromAttributesAndNodes(self, xmlFile, key, resetVehicles) then |
142 | return false; |
143 | end; |
144 | |
145 | for i=1, #self.animatedObjects do |
146 | local animatedObject = self.animatedObjects[i] |
147 | if hasXMLProperty(xmlFile, key..".animatedObject("..(i-1)..")") then |
148 | animatedObject:loadFromAttributesAndNodes(xmlFile, key..".animatedObject("..(i-1)..")") |
149 | end |
150 | end |
151 | |
152 | return true; |
153 | end; |
getSaveAttributesAndNodes
DescriptionGet save attributes and nodesDefinition
getSaveAttributesAndNodes(string nodeIdent)Arguments
string | nodeIdent | node ident |
string | attributes | attributes |
string | nodes | nodes |
160 | function AnimatedObjectPlaceable:getSaveAttributesAndNodes(nodeIdent) |
161 | local attributes, nodes = AnimatedObjectPlaceable:superClass().getSaveAttributesAndNodes(self, nodeIdent); |
162 | |
163 | for i=1, #self.animatedObjects do |
164 | local animatedObject = self.animatedObjects[i] |
165 | local a, _ = animatedObject:getSaveAttributesAndNodes(nodeIdent .. " ") |
166 | if i > 1 then |
167 | nodes = nodes.."\n"; |
168 | end; |
169 | nodes = nodes..nodeIdent.."<animatedObject".." "..a.. "/>" |
170 | end |
171 | |
172 | return attributes, nodes; |
173 | end; |