Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- 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
- JointConstructor:setActors
- JointConstructor:setJointTransforms
- addDifferential
- addForce
- addImpulse
- addTorque
- addTorqueImpulse
- addVehicleLink
- computeWheelShapeTireForces
- createCCT
- createWheelShape
- getAngularDamping
- getAngularVelocity
- getCCTCollisionFlags
- getCenterOfMass
- getCollisionMask
- getDensity
- getLinearDamping
- getLinearVelocity
- getMass
- getMotorRotationSpeed
- getRigidBodyType
- getVelocityAtLocalPos
- getVelocityAtWorldPos
- getVolume
- getWheelShapeAxleSpeed
- getWheelShapeContactForce
- getWheelShapeContactNormal
- getWheelShapeContactObject
- getWheelShapeContactPoint
- getWheelShapePosition
- getWheelShapeSlip
- moveCCT
- overlapBox
- overlapSphere
- raycastAll
- raycastClosest
- removeCCT
- setAngularDamping
- setAngularVelocity
- setCenterOfMass
- setCollisionMask
- setFrictionVelocity
- setJointDrive
- setLinearDamping
- setLinearVelocity
- setMass
- setRigidBodyType
- setSolverIterationCount
- setWheelShapeForcePoint
- setWheelShapeProps
- setWheelShapeTireFriction
- simulatePhysics
- simulatePhysicsTimeScale
- updateDifferential
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
GuiDataSource
DescriptionData source for UI elements. Holds dynamic data and allows configuration of accessors.Functions
addChangeListener
DescriptionAdd a listener with a member function which is called when this data source changes.Definition
addChangeListener()Code
37 | function GuiDataSource:addChangeListener(target, callback) |
38 | self.changeListeners[target] = callback or NO_CALLBACK |
39 | end |
getCount
DescriptionGet the number of data items.Definition
getCount()Code
58 | function GuiDataSource:getCount() |
59 | return #self.data |
60 | end |
getItem
DescriptionGet a data item at a given index.Definition
getItem()Code
64 | function GuiDataSource:getItem(index) |
65 | return self.data[index] |
66 | end |
iterateRange
DescriptionIterate a data range within the given indices. This is an iterator factory compatible with the default Lua for loop. E.g. "for _, item in source:iterateRange(1, 10) do" will loop over data items 1 to 10.Definition
iterateRange()Code
84 | function GuiDataSource:iterateRange(startIndex, endIndex) |
85 | local iterator = function(data, iter) |
86 | local item = data[iter] |
87 | if iter <= endIndex and item ~= nil then |
88 | return iter + 1, item |
89 | else |
90 | return nil, nil |
91 | end |
92 | end |
93 | |
94 | return iterator, self.data, startIndex |
95 | end |
new
DescriptionCreate a new GuiDataSource instance.Definition
new()Code
19 | function GuiDataSource:new(subclass_mt) |
20 | local self = setmetatable({}, subclass_mt or GuiDataSource_mt) |
21 | |
22 | self.data = NO_DATA |
23 | self.changeListeners = {} -- {<listener table> = <listener function>} |
24 | |
25 | return self |
26 | end |
notifyChange
DescriptionNotify this data source that its data has been changed externally. This will call the change callback if it has been set.Definition
notifyChange()Code
50 | function GuiDataSource:notifyChange() |
51 | for target, callback in pairs(self.changeListeners) do |
52 | callback(target) |
53 | end |
54 | end |
removeChangeListener
DescriptionRemove a previously added change listener from the notification table.Definition
removeChangeListener()Code
43 | function GuiDataSource:removeChangeListener(target) |
44 | self.changeListeners[target] = nil |
45 | end |
setData
DescriptionSet the data source data array.Definition
setData()Code
30 | function GuiDataSource:setData(data) |
31 | self.data = data or NO_DATA |
32 | self:notifyChange() |
33 | end |
setItem
DescriptionSet a data item at a given index. If the index is out bounds of the data, this will have no effect.Definition
setItem()Code
71 | function GuiDataSource:setItem(index, value, needsNotification) |
72 | if index > 0 and index <= #self.data then |
73 | self.data[index] = value |
74 | if needsNotification then |
75 | self:notifyChange() |
76 | end |
77 | end |
78 | end |