Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- AnimatedMapObject
- AnimatedObject
- AnimatedObjectEvent
- Bale
- Basketball
- Bga
- BgaSellStation
- BunkerSilo
- BuyingStation
- DigitalDisplay
- DogBall
- HelpIcons
- LoadingStation
- NightIllumination
- Nightlight2
- NightlightFlicker
- PhysicsObject
- Rotator
- SellingStation
- SimParticleSystem
- Storage
- StorageSystem
- SunAdmirer
- TourIcons
- UnloadingStation
- VehicleSellingPoint
- WildlifeSpawner
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
AnimatedMapObject
DescriptionClass for animated map objectsParent
AnimatedObjectFunctions
load
DescriptionLoad animated object attributes from objectDefinition
load(integer nodeId)Arguments
integer | nodeId | id of object to load from |
boolean | success | success |
47 | function AnimatedMapObject:load(nodeId) |
48 | local xmlFilename = getUserAttribute(nodeId, "xmlFilename") |
49 | |
50 | if xmlFilename == nil then |
51 | print("Error: Missing 'xmlFilename' user attribute for AnimatedMapObject node '"..getName(nodeId).."'!") |
52 | return false |
53 | end |
54 | |
55 | local baseDir = g_currentMission.loadingMapBaseDirectory |
56 | if baseDir == "" then |
57 | baseDir = Utils.getNoNil(self.baseDirectory, baseDir) |
58 | end |
59 | xmlFilename = Utils.getFilename(xmlFilename, baseDir) |
60 | |
61 | local index = getUserAttribute(nodeId, "index") |
62 | if index == nil then |
63 | print("Error: Missing 'index' user attribute for AnimatedMapObject node '"..getName(nodeId).."'!") |
64 | return false |
65 | end |
66 | |
67 | local xmlFile = loadXMLFile("AnimatedObject", xmlFilename) |
68 | if xmlFile == 0 then |
69 | return false |
70 | end |
71 | |
72 | -- Find the index in the XML |
73 | local key |
74 | local i = 0 |
75 | while true do |
76 | local objectKey = string.format("animatedObjects.animatedObject(%d)", i) |
77 | if not hasXMLProperty(xmlFile, objectKey) then |
78 | break |
79 | end |
80 | |
81 | local configIndex = getXMLString(xmlFile, objectKey.."#index") |
82 | if configIndex == index then |
83 | key = objectKey |
84 | break |
85 | end |
86 | i = i + 1 |
87 | end |
88 | |
89 | if key == nil then |
90 | print("Error: index '"..index.."' not found in AnimatedObject xml '"..xmlFilename.."'!") |
91 | return false |
92 | end |
93 | |
94 | local result = AnimatedMapObject:superClass().load(self, nodeId, xmlFile, key, xmlFilename) |
95 | |
96 | delete(xmlFile) |
97 | |
98 | return result |
99 | end |
new
DescriptionCreating new instance of animated object classDefinition
new(boolean isServer, boolean isClient, table customMt)Arguments
boolean | isServer | is server |
boolean | isClient | is client |
table | customMt | custom metatable |
table | self | new instance of object |
32 | function AnimatedMapObject:new(isServer, isClient, customMt) |
33 | local self = AnimatedObject:new(isServer, isClient, customMt or AnimatedMapObject_mt) |
34 | return self |
35 | end |
onCreate
DescriptionCreating animated objectDefinition
onCreate(integer id)Arguments
integer | id | node id |
15 | function AnimatedMapObject:onCreate(id) |
16 | local object = AnimatedMapObject:new(g_server ~= nil, g_client ~= nil) |
17 | if object:load(id) then |
18 | g_currentMission:addOnCreateLoadedObject(object) |
19 | g_currentMission:addOnCreateLoadedObjectToSave(object) |
20 | object:register(true) |
21 | else |
22 | object:delete() |
23 | end |
24 | end |