LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

VehicleAttachRequestEvent

Description
Event for request attaching
Parent
Event
Functions

emptyNew

Description
Create instance of Event class
Definition
emptyNew()
Return Values
tableselfinstance of class event
Code
14function VehicleAttachRequestEvent.emptyNew()
15 return Event.new(VehicleAttachRequestEvent_mt)
16end

new

Description
Create new instance of event
Definition
new(table info)
Arguments
tableinfoattach info [attacherVehicle, attachable, attacherVehicleJointDescIndex, attachableJointDescIndex]
Return Values
tableinstanceinstance of event
Code
22function VehicleAttachRequestEvent.new(info)
23 local self = VehicleAttachRequestEvent.emptyNew()
24 self.attacherVehicle = info.attacherVehicle
25 self.attachable = info.attachable
26 self.attacherVehicleJointDescIndex = info.attacherVehicleJointDescIndex
27 self.attachableJointDescIndex = info.attachableJointDescIndex
28 return self
29end

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
35function VehicleAttachRequestEvent:readStream(streamId, connection)
36 self.attacherVehicle = NetworkUtil.readNodeObject(streamId)
37 self.attachable = NetworkUtil.readNodeObject(streamId)
38 self.attacherVehicleJointDescIndex = streamReadUIntN(streamId, 7)
39 self.attachableJointDescIndex = streamReadUIntN(streamId, 7)
40 self:run(connection)
41end

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
57function VehicleAttachRequestEvent:run(connection)
58 if not connection:getIsServer() then
59 if self.attacherVehicle ~= nil and self.attacherVehicle:getIsSynchronized() then
60 self.attacherVehicle:attachImplementFromInfo(self)
61 end
62 end
63end

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
47function VehicleAttachRequestEvent:writeStream(streamId, connection)
48 NetworkUtil.writeNodeObject(streamId, self.attacherVehicle)
49 NetworkUtil.writeNodeObject(streamId, self.attachable)
50 streamWriteUIntN(streamId, self.attacherVehicleJointDescIndex, 7)
51 streamWriteUIntN(streamId, self.attachableJointDescIndex, 7)
52end