LUADOC - Farming Simulator 17

Printable Version

Script v1.4.4.0

Engine v7.0.0.2

Foundation Reference

SowingMachineSetSeedIndex

Description
Set seed index event
Functions

emptyNew

Description
Create instance of Event class
Definition
emptyNew()
Return Values
tableselfinstance of class event
Code
15function SowingMachineSetSeedIndex:emptyNew()
16 local self = Event:new(SowingMachineSetSeedIndex_mt);
17 return self;
18end;

new

Description
Create new instance of event
Definition
new(table object, integer seedIndex)
Arguments
tableobjectobject
integerseedIndexindex of seed
Code
24function SowingMachineSetSeedIndex:new(object, seedIndex)
25 local self = SowingMachineSetSeedIndex:emptyNew()
26 self.object = object;
27 self.seedIndex = seedIndex;
28 return self;
29end;

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
35function SowingMachineSetSeedIndex:readStream(streamId, connection)
36 self.object = readNetworkNodeObject(streamId);
37 self.seedIndex = streamReadUInt8(streamId);
38 self:run(connection);
39end;

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
45function SowingMachineSetSeedIndex:writeStream(streamId, connection)
46 writeNetworkNodeObject(streamId, self.object);
47 streamWriteUInt8(streamId, self.seedIndex);
48end;

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
53function SowingMachineSetSeedIndex:run(connection)
54 if not connection:getIsServer() then
55 g_server:broadcastEvent(self, false, connection, self.object);
56 end;
57 self.object:setSeedIndex(self.seedIndex, true);
58end;

sendEvent

Description
Broadcast event from server to all clients, if called on client call function on server and broadcast it to all clients
Definition
sendEvent(table object, integer seedIndex, boolean noEventSend)
Arguments
tableobjectobject
integerseedIndexindex of seed
booleannoEventSendno event send
Code
65function SowingMachineSetSeedIndex.sendEvent(object, seedIndex, noEventSend)
66 if noEventSend == nil or noEventSend == false then
67 if g_server ~= nil then
68 g_server:broadcastEvent(SowingMachineSetSeedIndex:new(object, seedIndex), nil, nil, object);
69 else
70 g_client:getServerConnection():sendEvent(SowingMachineSetSeedIndex:new(object, seedIndex));
71 end;
72 end;
73end;