CropSensorStateEvent
CropSensorStateEvent
Description
Event for setting the crop sensor active state
Parent
Functions
emptyNew
Description
Create instance of Event class
Definition
emptyNew()
Return Values
| any | self | instance of class event |
|---|
Code
function CropSensorStateEvent.emptyNew()
local self = Event.new( CropSensorStateEvent _mt)
return self
end
new
Description
Create new instance of event
Definition
new(table object, boolean state)
Arguments
| table | object | object |
|---|---|---|
| boolean | state | state |
Code
function CropSensorStateEvent.new(object, state)
local self = CropSensorStateEvent.emptyNew()
self.object = object
self.state = state
return self
end
readStream
Description
Called on client side on join
Definition
readStream(integer streamId, Connection connection)
Arguments
| integer | streamId | streamId |
|---|---|---|
| Connection | connection | connection |
Code
function CropSensorStateEvent:readStream(streamId, connection)
self.object = NetworkUtil.readNodeObject(streamId)
self.state = streamReadBool(streamId)
self:run(connection)
end
run
Description
Run action on receiving side
Definition
run(Connection connection)
Arguments
| Connection | connection | connection |
|---|
Code
function CropSensorStateEvent:run(connection)
if not connection:getIsServer() then
g_server:broadcastEvent( self , false , connection, self.object)
end
if self.object ~ = nil and self.object:getIsSynchronized() then
self.object:setCropSensorActive( self.state, true )
end
end
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, boolean state, boolean noEventSend)
Arguments
| table | object | object |
|---|---|---|
| boolean | state | state |
| boolean | noEventSend | no event send |
Code
function CropSensorStateEvent.sendEvent(object, state, noEventSend)
if noEventSend = = nil or noEventSend = = false then
if g_server ~ = nil then
g_server:broadcastEvent( CropSensorStateEvent.new(object, state), nil , nil , object)
else
g_client:getServerConnection():sendEvent( CropSensorStateEvent.new(object, state))
end
end
end
writeStream
Description
Called on server side on join
Definition
writeStream(integer streamId, Connection connection)
Arguments
| integer | streamId | streamId |
|---|---|---|
| Connection | connection | connection |
Code
function CropSensorStateEvent:writeStream(streamId, connection)
NetworkUtil.writeNodeObject(streamId, self.object)
streamWriteBool(streamId, self.state)
end