LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

ChainsawDelimbEvent

Description
Event for delimb
Parent
Event
Functions

emptyNew

Description
Create instance of Event class
Definition
emptyNew()
Return Values
tableselfinstance of class event
Code
14function ChainsawDelimbEvent:emptyNew()
15 local self = Event:new(ChainsawDelimbEvent_mt)
16 return self
17end

new

Description
Create new instance of event
Definition
new(table player, float x, float y, float z, float nx, float ny, float nz, float yx, float yy, float yz, boolean onDelimb)
Arguments
tableplayerplayer
floatxx
floatyy
floatzz
floatnxnx
floatnyny
floatnznz
floatyxyx
floatyyyy
floatyzyz
booleanonDelimbon delimb
Return Values
tableinstanceinstance of event
Code
33function ChainsawDelimbEvent:new(player, x,y,z, nx,ny,nz, yx,yy,yz, onDelimb)
34 local self = ChainsawDelimbEvent:emptyNew()
35 self.player = player
36 self.x, self.y, self.z = x, y, z
37 self.nx, self.ny, self.nz = nx, ny, nz
38 self.yx, self.yy, self.yz = yx, yy, yz
39 self.onDelimb = onDelimb
40 return self
41end

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
47function ChainsawDelimbEvent:readStream(streamId, connection)
48 if not connection:getIsServer() then -- server side
49 self.player = NetworkUtil.readNodeObject(streamId)
50 self.x = streamReadFloat32(streamId)
51 self.y = streamReadFloat32(streamId)
52 self.z = streamReadFloat32(streamId)
53 self.nx = streamReadFloat32(streamId)
54 self.ny = streamReadFloat32(streamId)
55 self.nz = streamReadFloat32(streamId)
56 self.yx = streamReadFloat32(streamId)
57 self.yy = streamReadFloat32(streamId)
58 self.yz = streamReadFloat32(streamId)
59 self.onDelimb = false
60 if self.player ~= nil then
61 local chainsaw = self.player.baseInformation.currentHandtool
62 if chainsaw ~= nil then
63 local ret = findAndRemoveSplitShapeAttachments(self.x,self.y,self.z, self.nx,self.ny,self.nz, self.yx,self.yy,self.yz, 0.7, chainsaw.cutSizeY, chainsaw.cutSizeZ)
64 if ret then
65 self.onDelimb = true
66 connection:sendEvent(self)
67 end
68 end
69 end
70 end
71end

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
98function ChainsawDelimbEvent:run(connection)
99 print("Error: ChainsawDelimbEvent is not allowed to be executed on a local client")
100end

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
77function ChainsawDelimbEvent:writeStream(streamId, connection)
78 if connection:getIsServer() then -- client
79 NetworkUtil.writeNodeObject(streamId, self.player)
80 streamWriteFloat32(streamId, self.x)
81 streamWriteFloat32(streamId, self.y)
82 streamWriteFloat32(streamId, self.z)
83 streamWriteFloat32(streamId, self.nx)
84 streamWriteFloat32(streamId, self.ny)
85 streamWriteFloat32(streamId, self.nz)
86 streamWriteFloat32(streamId, self.yx)
87 streamWriteFloat32(streamId, self.yy)
88 streamWriteFloat32(streamId, self.yz)
89 else
90 NetworkUtil.writeNodeObject(streamId, self.player)
91 streamWriteBool(streamId, self.onDelimb)
92 end
93end