Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- AIConveyorBeltSetAngleEve...
- AIVehicleIsBlockedEvent
- AIVehicleSetStartedEvent
- AnimatedVehicleStartEvent
- AnimatedVehicleStopEvent
- BaleLoaderStateEvent
- BalerCreateBaleEvent
- BalerSetBaleTimeEvent
- BalerSetIsUnloadingBaleEv...
- BaleWrapperStateEvent
- BunkerSiloCloseEvent
- BunkerSiloOpenEvent
- ChainsawCutEvent
- ChainsawDelimbEvent
- ChainsawStateEvent
- CombineStrawEnableEvent
- CylinderedEasyControlChan...
- DrivableToggleLowerAllEve...
- FillUnitUnloadEvent
- FoldableSetFoldDirectionE...
- GreenhouseSetIsWaterTankF...
- HonkEvent
- HPWLanceStateEvent
- HPWPlaceableTurnOnEvent
- JumpEvent
- MixerWagonBaleNotAccepted...
- MowerToggleWindrowDropEve...
- PickupSetStateEvent
- PlantLimitToFieldEvent
- PlayerPermissionsEvent
- PlowLimitToFieldEvent
- PlowRotationEvent
- ReceivingHopperSetCreateB...
- ReverseDrivingSetStateEve...
- RidgeMarkerSetStateEvent
- SendLocomotiveToSplinePos...
- SetCoverStateEvent
- SetCrabSteeringEvent
- SetCruiseControlSpeedEven...
- SetCruiseControlStateEven...
- SetDischargeStateEvent
- SetFillUnitIsFillingEvent
- SetMotorTurnedOnEvent
- SetPipeStateEvent
- SetSeedIndexEvent
- SetTurnedOnEvent
- SetWorkModeEvent
- TensionBeltsEvent
- TensionBeltsRefreshEvent
- TrailerToggleTipSideEvent
- TreePlanterLoadPalletEven...
- VehicleAttachEvent
- VehicleBrokenEvent
- VehicleBundleAttachEvent
- VehicleDetachEvent
- VehicleEnterRequestEvent
- VehicleEnterResponseEvent
- VehicleLeaveEvent
- VehicleLowerImplementEven...
- VehicleSetBeaconLightEven...
- VehicleSetLightEvent
- VehicleSetTurnLightEvent
- WaterTrailerSetIsFillingE...
- WearableRepairEvent
- WoodHarvesterCutTreeEvent
- WoodHarvesterOnCutTreeEve...
- WoodHarvesterOnDelimbTree...
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
AIVehicleSetStartedEvent
DescriptionEvent for ai startParent
EventFunctions
emptyNew
DescriptionCreate instance of Event classDefinition
emptyNew()Return Values
table | self | instance of class event |
13 | function AIVehicleSetStartedEvent:emptyNew() |
14 | local self = Event:new(AIVehicleSetStartedEvent_mt) |
15 | return self |
16 | end |
new
DescriptionCreate new instance of eventDefinition
new(table object, integer reason, boolean isStarted, integer helper)Arguments
table | object | object |
integer | reason | reason |
boolean | isStarted | is started |
integer | helper | helper id |
24 | function AIVehicleSetStartedEvent:new(object, reason, isStarted, helper, startedFarmId) |
25 | local self = AIVehicleSetStartedEvent:emptyNew() |
26 | self.object = object |
27 | self.isStarted = isStarted |
28 | self.reason = reason |
29 | self.startedFarmId = startedFarmId |
30 | if helper ~= nil then |
31 | self.helperIndex = helper.index |
32 | end |
33 | return self |
34 | end |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, integer connection)Arguments
integer | streamId | streamId |
integer | connection | connection |
40 | function AIVehicleSetStartedEvent:readStream(streamId, connection) |
41 | self.object = NetworkUtil.readNodeObject(streamId) |
42 | self.isStarted = streamReadBool(streamId) |
43 | |
44 | if not self.isStarted then |
45 | self.reason = streamReadUIntN(streamId, AIVehicle.NUM_BITS_REASONS) |
46 | else |
47 | self.helperIndex = streamReadUInt8(streamId) |
48 | end |
49 | |
50 | self.startedFarmId = streamReadUIntN(streamId, FarmManager.FARM_ID_SEND_NUM_BITS) |
51 | |
52 | self:run(connection) |
53 | end |
run
DescriptionRun action on receiving sideDefinition
run(integer connection)Arguments
integer | connection | connection |
75 | function AIVehicleSetStartedEvent:run(connection) |
76 | if self.isStarted then |
77 | self.object:startAIVehicle(self.helperIndex, true, self.startedFarmId) |
78 | else |
79 | self.object:stopAIVehicle(self.reason, true) |
80 | end |
81 | if not connection:getIsServer() then |
82 | for _, v in pairs(g_server.clientConnections) do |
83 | if v ~= connection and not v:getIsLocal() then |
84 | v:sendEvent(AIVehicleSetStartedEvent:new(self.object, self.reason, self.isStarted, g_helperManager:getHelperByIndex(self.helperIndex), self.startedFarmId)) |
85 | end |
86 | end |
87 | end |
88 | end |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, integer connection)Arguments
integer | streamId | streamId |
integer | connection | connection |
59 | function AIVehicleSetStartedEvent:writeStream(streamId, connection) |
60 | NetworkUtil.writeNodeObject(streamId, self.object) |
61 | streamWriteBool(streamId, self.isStarted) |
62 | |
63 | if not self.isStarted then |
64 | streamWriteUIntN(streamId, self.reason, AIVehicle.NUM_BITS_REASONS) |
65 | else |
66 | streamWriteUInt8(streamId, self.helperIndex) |
67 | end |
68 | |
69 | streamWriteUIntN(streamId, self.startedFarmId, FarmManager.FARM_ID_SEND_NUM_BITS) |
70 | end |