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
Basketball
DescriptionClass for basketballsParent
PhysicsObjectFunctions
createNode
DescriptionLoad node from i3d fileDefinition
createNode(string i3dFilename)Arguments
string | i3dFilename | i3d file name |
86 | function Basketball:createNode(i3dFilename) |
87 | self.i3dFilename = i3dFilename |
88 | self.customEnvironment, self.baseDirectory = Utils.getModNameAndBaseDirectory(i3dFilename) |
89 | local basketballRoot = g_i3DManager:loadSharedI3DFile(i3dFilename) |
90 | |
91 | local basketballId = getChildAt(basketballRoot, 0) |
92 | link(getRootNode(), basketballId) |
93 | delete(basketballRoot) |
94 | |
95 | self:setNodeId(basketballId) |
96 | end |
delete
DescriptionDeleting basketball objectDefinition
delete()Code
50 | function Basketball:delete() |
51 | if self.i3dFilename ~= nil then |
52 | g_i3DManager:releaseSharedI3DFile(self.i3dFilename, nil, true) |
53 | end |
54 | unregisterObjectClassName(self) |
55 | Basketball:superClass().delete(self) |
56 | end |
load
DescriptionLoad BasketballDefinition
load(string i3dFilename, float x, float y, float z, float rx, float ry, float rz)Arguments
string | i3dFilename | i3d 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 |
107 | function Basketball:load(i3dFilename, x,y,z, rx,ry,rz) |
108 | self.i3dFilename = i3dFilename |
109 | self.customEnvironment, self.baseDirectory = Utils.getModNameAndBaseDirectory(i3dFilename) |
110 | self:createNode(i3dFilename) |
111 | setTranslation(self.nodeId, x, y, z) |
112 | setRotation(self.nodeId, rx, ry, rz) |
113 | |
114 | return true |
115 | end |
new
DescriptionCreating basketball objectDefinition
new(boolean isServer, boolean isClient, table customMt)Arguments
boolean | isServer | is server |
boolean | isClient | is client |
table | customMt | customMt |
table | instance | Instance of object |
34 | function Basketball:new(isServer, isClient, customMt) |
35 | local mt = customMt |
36 | if mt == nil then |
37 | mt = Basketball_mt |
38 | end |
39 | |
40 | local self = PhysicsObject:new(isServer, isClient, mt) |
41 | |
42 | self.forcedClipDistance = 150 |
43 | registerObjectClassName(self, "Basketball") |
44 | |
45 | return self |
46 | end |
onCreate
DescriptionCreating basketballDefinition
onCreate(integer id)Arguments
integer | id | node id |
13 | function Basketball:onCreate(id) |
14 | local basketball = Basketball:new(g_server ~= nil, g_client ~= nil) |
15 | local x, y, z = getWorldTranslation(id) |
16 | local rx, ry, rz = getWorldRotation(id) |
17 | local filename = Utils.getNoNil(getUserAttribute(id, "filename"), "$data/objects/basketball/basketball.i3d") |
18 | filename = Utils.getFilename(filename, g_currentMission.loadingMapBaseDirectory); |
19 | |
20 | if basketball:load(filename, x, y, z, rx, ry, rz) then |
21 | g_currentMission:addOnCreateLoadedObject(basketball) |
22 | basketball:register(true) |
23 | else |
24 | basketball:delete() |
25 | end |
26 | end |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
62 | function Basketball:readStream(streamId, connection) |
63 | if connection:getIsServer() then |
64 | local i3dFilename = NetworkUtil.convertFromNetworkFilename(streamReadString(streamId)) |
65 | if self.nodeId == 0 then |
66 | self:createNode(i3dFilename) |
67 | end |
68 | Basketball:superClass().readStream(self, streamId, connection) |
69 | end |
70 | end |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
76 | function Basketball:writeStream(streamId, connection) |
77 | if not connection:getIsServer() then |
78 | streamWriteString(streamId, NetworkUtil.convertToNetworkFilename(self.i3dFilename)) |
79 | Basketball:superClass().writeStream(self, streamId, connection) |
80 | end |
81 | end |