Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- AnimatedMapObject
- AnimatedObject
- Bale
- Basketball
- BgaSellStation
- BunkerSilo
- BuyingStation
- DigitalDisplay
- DogBall
- HelpIcons
- InlineBale
- InlineBaleSingle
- LoadingStation
- MountableObject
- NightIllumination
- Nightlight2
- NightlightFlicker
- PackedBale
- PhysicsObject
- ProductionPoint
- Rotator
- SellingStation
- SimParticleSystem
- Storage
- SunAdmirer
- TourIconsMobile
- UnloadingStation
- VehicleSellingPoint
- WildlifeSpawner
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
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 |
54 | function AnimatedMapObject:load(nodeId) |
55 | local xmlFilename = getUserAttribute(nodeId, "xmlFilename") |
56 | if xmlFilename == nil then |
57 | Logging.error("Missing 'xmlFilename' user attribute for AnimatedMapObject node '%s'!", getName(nodeId)) |
58 | return false |
59 | end |
60 | |
61 | local baseDir = g_currentMission.loadingMapBaseDirectory |
62 | if baseDir == "" then |
63 | baseDir = Utils.getNoNil(self.baseDirectory, baseDir) |
64 | end |
65 | xmlFilename = Utils.getFilename(xmlFilename, baseDir) |
66 | |
67 | local index = getUserAttribute(nodeId, "index") |
68 | if index == nil then |
69 | Logging.error("Missing 'index' user attribute for AnimatedMapObject node '%s'!", getName(nodeId)) |
70 | return false |
71 | end |
72 | |
73 | local xmlFile = XMLFile.load("AnimatedObject", xmlFilename, AnimatedMapObject.xmlSchema) |
74 | if xmlFile == nil then |
75 | return false |
76 | end |
77 | |
78 | -- Find the index in the XML |
79 | local key |
80 | xmlFile:iterate("animatedObjects.animatedObject", function(_, objectKey) |
81 | local configIndex = xmlFile:getString(objectKey.."#index") |
82 | if configIndex == index then |
83 | key = objectKey |
84 | return true |
85 | end |
86 | end) |
87 | |
88 | if key == nil then |
89 | Logging.error("index '%s' not found in AnimatedObject xml '%s'!", index, xmlFilename) |
90 | return false |
91 | end |
92 | |
93 | local result = AnimatedMapObject:superClass().load(self, nodeId, xmlFile, key, xmlFilename) |
94 | |
95 | xmlFile:delete() |
96 | |
97 | return result |
98 | 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 |
40 | function AnimatedMapObject.new(isServer, isClient, customMt) |
41 | return AnimatedObject.new(isServer, isClient, customMt or AnimatedMapObject_mt) |
42 | end |
onCreate
DescriptionCreating animated objectDefinition
onCreate(integer id)Arguments
integer | id | node id |
24 | function AnimatedMapObject:onCreate(id) |
25 | local object = AnimatedMapObject.new(g_server ~= nil, g_client ~= nil) |
26 | if object:load(id) then |
27 | g_currentMission.onCreateObjectSystem:add(object, true) |
28 | object:register(true) |
29 | else |
30 | object:delete() |
31 | end |
32 | end |