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
- 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
- getMaterialCustomShaderFilename
- getMaterialCustomShaderVariation
- getMaterialDiffuseMapFilename
- getMaterialDiffuseMapHasAlpha
- getMaterialEmissiveMapFilename
- getMaterialEmissiveMapHasAlpha
- getMaterialGlossMapFilename
- getMaterialHasRefractionMap
- getMaterialIsAlphaBlended
- getMaterialIsAlphaTested
- getMaterialNormalMapFilename
- getMaterialNormalMapFormat
- getMaterialReflectionMapScaling
- setMaterialCustomMapFromFile
- setMaterialCustomShaderVariation
- setMaterialDiffuseMapFromFile
- setMaterialGlossMapFromFile
- setMaterialNormalMapFromFile
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
MotorGearShiftEvent
DescriptionEvent for sending shifting inputs from client to serverParent
EventFunctions
emptyNew
DescriptionCreate instance of Event classDefinition
emptyNew()Return Values
table | self | instance of class event |
23 | function MotorGearShiftEvent.emptyNew() |
24 | local self = Event.new(MotorGearShiftEvent_mt) |
25 | return self |
26 | end |
new
DescriptionCreate new instance of eventDefinition
new(table vehicle, boolean turnedOn)Arguments
table | vehicle | vehicle |
boolean | turnedOn | is turned on |
32 | function MotorGearShiftEvent.new(vehicle, shiftType, shiftValue) |
33 | local self = MotorGearShiftEvent.emptyNew() |
34 | self.vehicle = vehicle |
35 | self.shiftType = shiftType |
36 | self.shiftValue = shiftValue |
37 | return self |
38 | end |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, integer connection)Arguments
integer | streamId | streamId |
integer | connection | connection |
44 | function MotorGearShiftEvent:readStream(streamId, connection) |
45 | self.vehicle = NetworkUtil.readNodeObject(streamId) |
46 | self.shiftType = streamReadUIntN(streamId, 4) |
47 | |
48 | if self.shiftType == MotorGearShiftEvent.TYPE_SELECT_GEAR or self.shiftType == MotorGearShiftEvent.TYPE_SELECT_GROUP then |
49 | self.shiftValue = streamReadUIntN(streamId, 3) |
50 | end |
51 | |
52 | self:run(connection) |
53 | end |
run
DescriptionRun action on receiving sideDefinition
run(integer connection)Arguments
integer | connection | connection |
71 | function MotorGearShiftEvent:run(connection) |
72 | if self.vehicle ~= nil and self.vehicle:getIsSynchronized() then |
73 | local spec = self.vehicle.spec_motorized |
74 | if spec ~= nil and spec.isMotorStarted then |
75 | if self.shiftType == MotorGearShiftEvent.TYPE_SHIFT_UP then |
76 | spec.motor:shiftGear(true) |
77 | elseif self.shiftType == MotorGearShiftEvent.TYPE_SHIFT_DOWN then |
78 | spec.motor:shiftGear(false) |
79 | elseif self.shiftType == MotorGearShiftEvent.TYPE_SELECT_GEAR then |
80 | spec.motor:selectGear(self.shiftValue, self.shiftValue ~= 0) |
81 | elseif self.shiftType == MotorGearShiftEvent.TYPE_SHIFT_GROUP_UP then |
82 | spec.motor:shiftGroup(true) |
83 | elseif self.shiftType == MotorGearShiftEvent.TYPE_SHIFT_GROUP_DOWN then |
84 | spec.motor:shiftGroup(false) |
85 | elseif self.shiftType == MotorGearShiftEvent.TYPE_SELECT_GROUP then |
86 | spec.motor:selectGroup(self.shiftValue, self.shiftValue ~= 0) |
87 | elseif self.shiftType == MotorGearShiftEvent.TYPE_DIRECTION_CHANGE then |
88 | spec.motor:changeDirection() |
89 | elseif self.shiftType == MotorGearShiftEvent.TYPE_DIRECTION_CHANGE_POS then |
90 | spec.motor:changeDirection(1) |
91 | elseif self.shiftType == MotorGearShiftEvent.TYPE_DIRECTION_CHANGE_NEG then |
92 | spec.motor:changeDirection(-1) |
93 | end |
94 | end |
95 | end |
96 | end |
sendEvent
DescriptionBroadcast event from server to all clients, if called on client call function on server and broadcast it to all clientsDefinition
sendEvent(table vehicle, integer shiftType, integer shiftValue)Arguments
table | vehicle | vehicle |
integer | shiftType | type of shifting event |
integer | shiftValue | additional value for shifting event |
103 | function MotorGearShiftEvent.sendEvent(vehicle, shiftType, shiftValue) |
104 | if g_client ~= nil then |
105 | g_client:getServerConnection():sendEvent(MotorGearShiftEvent.new(vehicle, shiftType, shiftValue)) |
106 | end |
107 | end |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, integer connection)Arguments
integer | streamId | streamId |
integer | connection | connection |
59 | function MotorGearShiftEvent:writeStream(streamId, connection) |
60 | NetworkUtil.writeNodeObject(streamId, self.vehicle) |
61 | streamWriteUIntN(streamId, self.shiftType, 4) |
62 | |
63 | if self.shiftType == MotorGearShiftEvent.TYPE_SELECT_GEAR or self.shiftType == MotorGearShiftEvent.TYPE_SELECT_GROUP then |
64 | streamWriteUIntN(streamId, self.shiftValue, 3) |
65 | end |
66 | end |