LUADOC - Farming Simulator 19

TourIcons

Description
Tour icons are part of the (optional) guided tour at the career game's start
Functions

activateNextIcon

Description
Activate next icon
Definition
activateNextIcon()
Code
419function TourIcons:activateNextIcon()
420 -- make all previous icons invisible (also handles cases where player managed to skip icons)
421 for i = 1, self.currentTourIconNumber do
422 local tourIcon = self.tourIcons[i]
423 if getVisibility(tourIcon.tourIconId) then
424 setVisibility(tourIcon.tourIconId, false)
425 setCollisionMask(tourIcon.tourIconTriggerId, 0)
426 end
427 end
428
429 if self.tourIcons[self.currentTourIconNumber + 1] ~= nil then
430 self:makeIconVisible(self.tourIcons[self.currentTourIconNumber + 1].tourIconId)
431 else
432 -- end of tour!
433 if self.mapHotspot ~= nil then
434 g_currentMission:removeMapHotspot(self.mapHotspot)
435 self.mapHotspot:delete()
436 self.mapHotspot = nil
437 end
438 -- re-display non-tour help icons
439 if g_gameSettings:getValue("showHelpIcons") then
440 if g_currentMission.helpIconsBase ~= nil then
441 g_currentMission.helpIconsBase:showHelpIcons(true, true)
442 end
443 end
444
445 self.visible = false
446 g_messageCenter:publish(MessageType.MISSION_TOUR_FINISHED)
447
448 -- clean up scene objects:
449 self:delete()
450 end
451
452 local title = g_i18n:getText("ui_tour")
453 local text = ""
454 local controls = {}
455
456 if self.currentTourIconNumber == 1 then
457
458 text = g_i18n:getText("tour_text_part01_lookAndWalk")
459 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.TOGGLE_MAP_SIZE, nil, g_i18n:getText("action_toggleMapView")))
460
461 local useGamepadButtons = g_inputBinding:getInputHelpMode() == GS_INPUT_HELP_MODE_GAMEPAD
462 if useGamepadButtons then
463 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.AXIS_MOVE_FORWARD_PLAYER, InputAction.AXIS_MOVE_SIDE_PLAYER, g_i18n:getText("action_movePlayer")))
464 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.AXIS_LOOK_UPDOWN_PLAYER, InputAction.AXIS_LOOK_LEFTRIGHT_PLAYER, g_i18n:getText("action_lookPlayer")))
465 else
466 -- special case on PC
467 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.AXIS_MOVE_FORWARD_PLAYER, InputAction.AXIS_MOVE_SIDE_PLAYER, g_i18n:getText("action_movePlayer")))
468
469 -- to show a mouse icon, instead of 'arrow keys' on keyboard
470 -- local lookAroundSymbol = g_inputDisplayManager.controllerSymbols["mouse_MOUSE_BUTTON_NONE"] -- TODO: fix direct access, too error prone
471 -- if lookAroundSymbol ~= nil then
472 -- table.insert(controls, {overlays = {lookAroundSymbol.overlay}, text = g_i18n:getText("action_lookPlayer")} )
473 -- end
474 end
475
476 elseif self.currentTourIconNumber == 2 then -- # harvesting
477
478 text = g_i18n:getText("tour_text_part01_enterCombine")
479 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.ENTER, nil, g_i18n:getText("input_ENTER")))
480
481 elseif self.currentTourIconNumber == 3 then
482
483 text = g_i18n:getText("tour_text_part01_attachHeader")
484 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.ATTACH, nil, g_i18n:getText("input_ATTACH")))
485
486 elseif self.currentTourIconNumber == 4 then
487
488 text = g_i18n:getText("tour_text_part01_turnOnCombine")
489 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.SWITCH_IMPLEMENT, nil, g_i18n:getText("action_switchImplement")))
490 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.IMPLEMENT_EXTRA2, nil, g_i18n:getText("action_unfold")))
491 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.IMPLEMENT_EXTRA, nil, g_i18n:getText("action_turnOn")))
492
493 elseif self.currentTourIconNumber == 5 then
494
495 text = g_i18n:getText("tour_text_part01_startHarvesting")
496 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.AXIS_ACCELERATE_VEHICLE, InputAction.AXIS_BRAKE_VEHICLE, g_i18n:getText("action_accelerate")))
497 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.AXIS_MOVE_SIDE_VEHICLE, nil, g_i18n:getText("action_steer")))
498
499 elseif self.currentTourIconNumber == 6 then
500
501 text = g_i18n:getText("tour_text_part01_startHelperHarvesting")
502 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.TOGGLE_AI, nil, g_i18n:getText("input_TOGGLE_AI")))
503
504 elseif self.currentTourIconNumber == 7 then
505
506 text = g_i18n:getText("tour_text_part01_finished")
507 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.ENTER, nil, g_i18n:getText("action_exitVehicle")))
508
509 elseif self.currentTourIconNumber == 8 then -- # cultivating
510
511 text = g_i18n:getText("tour_text_part02_enterTractor01")
512 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.ENTER, nil, g_i18n:getText("input_ENTER")))
513 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.ATTACH, nil, g_i18n:getText("input_ATTACH")))
514
515 elseif self.currentTourIconNumber == 9 then
516
517 text = g_i18n:getText("tour_text_part02_startCultivating")
518 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.LOWER_IMPLEMENT, nil, g_i18n:getText("input_LOWER_IMPLEMENT")))
519
520 elseif self.currentTourIconNumber == 10 then
521
522 text = g_i18n:getText("tour_text_part02_enoughCultivating")
523 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.TOGGLE_AI, nil, g_i18n:getText("input_TOGGLE_AI")))
524
525 elseif self.currentTourIconNumber == 11 then
526
527 text = g_i18n:getText("tour_text_part02_finished")
528 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.SWITCH_VEHICLE, nil, g_i18n:getText("input_SWITCH_VEHICLE")))
529 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.SWITCH_VEHICLE_BACK, nil, g_i18n:getText("input_SWITCH_VEHICLE_BACK")))
530
531 elseif self.currentTourIconNumber == 12 then -- # sowing
532
533 text = g_i18n:getText("tour_text_part03_enterTractor01")
534 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.ENTER, nil, g_i18n:getText("input_ENTER")))
535 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.ATTACH, nil, g_i18n:getText("input_ATTACH")))
536
537 elseif self.currentTourIconNumber == 13 then
538
539 text = g_i18n:getText("tour_text_part03_startSowing")
540 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.IMPLEMENT_EXTRA3, nil, g_i18n:getText("action_chooseSeed")))
541 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.LOWER_IMPLEMENT, nil, g_i18n:getText("input_LOWER_IMPLEMENT")))
542 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.IMPLEMENT_EXTRA, nil, g_i18n:getText("action_turnOn")))
543
544 elseif self.currentTourIconNumber == 14 then
545
546 text = g_i18n:getText("tour_text_part03_finished")
547 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.SWITCH_VEHICLE, nil, g_i18n:getText("input_SWITCH_VEHICLE")))
548 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.SWITCH_VEHICLE_BACK, nil, g_i18n:getText("input_SWITCH_VEHICLE_BACK")))
549
550 elseif self.currentTourIconNumber == 15 then -- # trailer / tipping and selling
551
552 text = g_i18n:getText("tour_text_part04_enterTractor01")
553 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.ENTER, nil, g_i18n:getText("input_ENTER")))
554 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.ATTACH, nil, g_i18n:getText("input_ATTACH")))
555
556 elseif self.currentTourIconNumber == 16 then
557
558 text = g_i18n:getText("tour_text_part04_alignToHarvester")
559
560 elseif self.currentTourIconNumber == 17 then
561
562 text = g_i18n:getText("tour_text_part04_unloadWheat")
563
564 elseif self.currentTourIconNumber == 18 then
565
566 text = g_i18n:getText("tour_text_part04_pricesInfo")
567 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.MENU, nil, g_i18n:getText("input_MENU")))
568
569 elseif self.currentTourIconNumber == 19 then
570
571 text = g_i18n:getText("tour_text_part04_sellWheat")
572 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.TOGGLE_TIPSTATE, nil, g_i18n:getText("input_TOGGLE_TIPSTATE")))
573
574 elseif self.currentTourIconNumber == 20 then
575
576 text = g_i18n:getText("tour_text_part04_doneSelling")
577
578 elseif self.currentTourIconNumber == 21 then -- # shop
579
580 text = g_i18n:getText("tour_text_part05_visitShop")
581 table.insert(controls, g_inputDisplayManager:getControllerSymbolOverlays(InputAction.TOGGLE_STORE, nil, g_i18n:getText("input_TOGGLE_STORE")))
582
583 elseif self.currentTourIconNumber == 22 then
584
585 text = g_i18n:getText("tour_text_end")
586
587 end
588
589 if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle.setCruiseControlState ~= nil then
590 g_currentMission.controlledVehicle:setCruiseControlState(Drivable.CRUISECONTROL_STATE_OFF)
591 end
592
593 if g_gui:getIsGuiVisible() then
594 self.queuedMessage = {title, text, -1, controls}
595 else
596 g_currentMission.hud.ingameMap:toggleSize(IngameMap.STATE_MINIMAP, true)
597 g_currentMission.hud:showInGameMessage(title, text, -1, controls)
598 end
599
600 self.currentTourIconNumber = self.currentTourIconNumber + 1
601
602 self.permanentMessageDelay = 250
603end

delete

Description
Deleting tour icons
Definition
delete()
Code
59function TourIcons:delete()
60 for _, tourIcon in pairs(self.tourIcons) do
61 removeTrigger(tourIcon.tourIconTriggerId)
62 end
63
64 if self.me ~= 0 then
65 delete(self.me)
66 self.me = 0
67 end
68end

makeIconVisible

Description
Make tour icon visable
Definition
makeIconVisible(integer tourIconId)
Arguments
integertourIconIdid of tour icon
Code
370function TourIcons:makeIconVisible(tourIconId)
371 -- make next icon visible
372 setVisibility(tourIconId, true)
373 local x, _, z = getWorldTranslation(tourIconId)
374
375 if self.mapHotspot == nil then
376 self.mapHotspot = MapHotspot:new("guide", MapHotspot.CATEGORY_TOUR)
377 self.mapHotspot:setImage(nil, getNormalizedUVs(MapHotspot.UV.HIGHLIGHT_MARKER), {0.2705, 0.6514, 0.0802, 1})
378 self.mapHotspot:setPersistent(true)
379 self.mapHotspot:setRenderLast(true)
380 self.mapHotspot:setBlinking(true)
381
382 g_currentMission:addMapHotspot(self.mapHotspot)
383 end
384
385 self.mapHotspot:setWorldPosition(x, z)
386
387
388 -- Find 'hidden' icon used internally only
389 local x,y,z = getWorldTranslation(tourIconId)
390 local h = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, x,y,z)
391 if y > h then
392 g_currentMission:setMapTargetHotspot(self.mapHotspot)
393 self.mapHotspot.enabled = true
394 else
395 g_currentMission:setMapTargetHotspot(nil)
396 self.mapHotspot.enabled = false
397 end
398end

new

Description
Creating tour icons
Definition
new(integer id)
Arguments
integeridnode id
Return Values
tableinstanceInstance of object
Code
23function TourIcons:new(id)
24 local self = {}
25 setmetatable(self, TourIcons_mt)
26
27 self.me = id
28 local num = getNumOfChildren(self.me)
29
30 self.tourIcons = {}
31 for i = 0, num - 1 do
32 local tourIconTriggerId = getChildAt(self.me, i)
33 local tourIconId = getChildAt(tourIconTriggerId, 0)
34 addTrigger(tourIconTriggerId, "triggerCallback", self)
35 setVisibility(tourIconId, false)
36 local tourIcon = {tourIconTriggerId = tourIconTriggerId, tourIconId = tourIconId}
37 table.insert(self.tourIcons, tourIcon)
38 end
39
40 self.visible = false
41 self.mapHotspot = nil
42 self.currentTourIconNumber = 1
43 self.alpha = 0.25
44 self.alphaDirection = 1
45 self.startTourDialog = false
46 self.startTourDialogDelay = 0
47 self.permanentMessageDelay = 0
48 self.isPaused = false
49 self.pauseTime = 0
50 self.soldStuffAtGrainElevator = false
51
52 _, self.permanentTextSize = getNormalizedScreenValues(0, 28)
53
54 return self
55end

onCreate

Description
Creating tour icons
Definition
onCreate(integer id)
Arguments
integeridnode id
Code
13function TourIcons:onCreate(id)
14 local tourIcons = TourIcons:new(id)
15 table.insert(g_currentMission.updateables, tourIcons)
16 g_currentMission.tourIconsBase = tourIcons
17end

reactToDialog

Description
React to tour dialog
Definition
reactToDialog(boolean yes)
Arguments
booleanyesanswer to dialog
Code
79function TourIcons:reactToDialog(yes)
80 if yes then
81 self.visible = true
82 self:activateNextIcon()
83 -- hide all non-tour question marks
84 if g_currentMission.helpIconsBase ~= nil then
85 g_currentMission.helpIconsBase:showHelpIcons(false, true)
86 end
87
88 g_messageCenter:publish(MessageType.MISSION_TOUR_STARTED)
89 else
90 self.visible = false
91 g_currentMission.hud:showInGameMessage("", g_i18n:getText("tour_text_abort"), -1)
92
93 self:delete()
94 end
95end

showTourDialog

Description
Show tour yes/no dialog
Definition
showTourDialog()
Code
72function TourIcons:showTourDialog()
73 g_gui:showYesNoDialog({text=g_i18n:getText("tour_text_start"), title="", callback=self.reactToDialog, target=self})
74end

triggerCallback

Description
Trigger callback
Definition
triggerCallback(integer triggerId, integer otherId, boolean onEnter, boolean onLeave, boolean onStay)
Arguments
integertriggerIdid of trigger
integerotherIdid of actor
booleanonEnteron enter
booleanonLeaveon leave
booleanonStayon stay
Code
407function TourIcons:triggerCallback(triggerId, otherId, onEnter, onLeave, onStay)
408 if onEnter then
409 if self.tourIcons[self.currentTourIconNumber] ~= nil then
410 if self.tourIcons[self.currentTourIconNumber].tourIconTriggerId == triggerId and getVisibility(self.tourIcons[self.currentTourIconNumber].tourIconId) then
411 self:activateNextIcon()
412 end
413 end
414 end
415end

update

Description
Update
Definition
update(float dt)
Arguments
floatdttime since last call in ms
Code
100function TourIcons:update(dt)
101 if not g_currentMission.missionInfo.isValid and g_server ~= nil and self.initDone == nil and g_currentMission:getIsTourSupported() then
102 self.initDone = true
103
104 -- prepare fields
105 local field = g_fieldManager:getFieldByIndex(24)
106 local fruitDesc = g_fruitTypeManager:getFruitTypeByIndex(FruitType.WHEAT)
107 for i = 1,table.getn(field.maxFieldStatusPartitions) do
108 g_fieldManager:setFieldPartitionStatus(field, field.maxFieldStatusPartitions, i, fruitDesc.index, FieldManager.FIELDSTATE_GROWING, fruitDesc.maxHarvestingGrowthState, 3, true, g_currentMission.plowCounterMaxValue, 0, g_currentMission.limeCounterMaxValue)
109 end
110
111 local field = g_fieldManager:getFieldByIndex(25)
112 local fruitDesc = g_fruitTypeManager:getFruitTypeByIndex(FruitType.CANOLA)
113 for i = 1,table.getn(field.maxFieldStatusPartitions) do
114 g_fieldManager:setFieldPartitionStatus(field, field.maxFieldStatusPartitions, i, fruitDesc.index, FieldManager.FIELDSTATE_HARVESTED, 0, 0, false, g_currentMission.plowCounterMaxValue, 0, g_currentMission.limeCounterMaxValue)
115 end
116
117 local field = g_fieldManager:getFieldByIndex(26)
118 for i = 1,table.getn(field.maxFieldStatusPartitions) do
119 g_fieldManager:setFieldPartitionStatus(field, field.maxFieldStatusPartitions, i, nil, FieldManager.FIELDSTATE_CULTIVATED, 0, 0, false, g_currentMission.plowCounterMaxValue, 0, g_currentMission.limeCounterMaxValue)
120 end
121
122 local field = g_fieldManager:getFieldByIndex(19)
123 for i = 1,table.getn(field.maxFieldStatusPartitions) do
124 g_fieldManager:setFieldPartitionStatus(field, field.maxFieldStatusPartitions, i, nil, FieldManager.FIELDSTATE_CULTIVATED, 0, 0, false, g_currentMission.plowCounterMaxValue, 0, g_currentMission.limeCounterMaxValue)
125 end
126 end
127
128 if self.startTourDialog then
129 self.startTourDialogDelay = self.startTourDialogDelay - dt
130 local showDialog = true
131 if g_currentMission.cameraFlightManager ~= nil then
132 showDialog = g_currentMission.cameraFlightManager.careerStartFlightPlayed
133 end
134 if showDialog then
135 if self.startTourDialogDelay < 0 then
136 self.startTourDialog = false
137 self:showTourDialog()
138 end
139 end
140 end
141
142 -- Delay messages always when UI is visible
143 if g_gui:getIsGuiVisible() then
144 return
145 elseif self.queuedMessage ~= nil then
146 -- Show queued message and try again next frame
147 g_currentMission.hud.ingameMap:toggleSize(IngameMap.STATE_MINIMAP, true)
148 g_currentMission.hud:showInGameMessage(unpack(self.queuedMessage))
149 self.queuedMessage = nil
150 return
151 end
152
153 if self.isPaused then
154 if self.pauseTime > 0 then
155 self.pauseTime = self.pauseTime - dt
156 else
157 self.pauseTime = 0
158 self.isPaused = false
159 self:activateNextIcon()
160 end
161 end
162
163 if self.visible and not self.isPaused then
164 -- show current permanent message on screen if no ingame message or any other GUI screen is displayed
165 if not g_currentMission.hud:isInGameMessageVisible() and not g_gui:getIsGuiVisible() then
166
167 if false then --g_i18n:hasText("tour_permanentText" .. self.currentTourIconNumber - 1) then
168
169 if self.permanentMessageDelay > 0 then
170 self.permanentMessageDelay = self.permanentMessageDelay - dt
171 self.alpha = 0.25
172 self.alphaDirection = 1
173 else
174
175 setTextColor(1, 1, 1, self.alpha)
176 setTextBold(true)
177 setTextAlignment(RenderText.ALIGN_CENTER)
178 setTextWrapWidth(0.35)
179 if GS_IS_CONSOLE_VERSION then
180 setTextWrapWidth(0.295)
181 end
182 renderText(0.5, 0.93, self.permanentTextSize, g_i18n:getText("tour_permanentText" .. self.currentTourIconNumber - 1))
183 setTextWrapWidth(0)
184 setTextAlignment(RenderText.ALIGN_LEFT)
185 setTextBold(false)
186 setTextColor(1, 1, 1, 1)
187
188 self.alpha = self.alpha + self.alphaDirection * (dt / 600)
189 if self.alpha > 1 or self.alpha < 0.25 then
190 self.alphaDirection = self.alphaDirection * -1
191 self.alpha = MathUtil.clamp(self.alpha, 0.25, 1)
192 end
193 end
194
195 end
196 end
197
198 -- handle special cases
199
200 --# harvesting
201
202 -- icon #3 activates as soon as the player enters the tour's combine harvester
203 if self.currentTourIconNumber <= 3 then
204 if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourCombine"] then
205 self.currentTourIconNumber = 3
206 -- self:activateNextIcon()
207 self.pauseTime = 1000
208 self.isPaused = true
209 end
210
211 -- wait for player to attach the cutter
212 elseif self.currentTourIconNumber == 4 then
213 if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourCombine"] then
214 if g_currentMission.tourVehicles["tourCombine"].spec_combine.numAttachedCutters > 0 then
215 -- self:activateNextIcon()
216 self.pauseTime = 1000
217 self.isPaused = true
218 end
219 end
220
221 -- wait for player to activate the cutter
222 elseif self.currentTourIconNumber == 5 then
223 if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourCombine"] then
224 if g_currentMission.controlledVehicle:getIsTurnedOn() then
225 -- self:activateNextIcon()
226 self.pauseTime = 1000
227 self.isPaused = true
228 end
229 end
230
231 -- wait for player to activate the helper
232 elseif self.currentTourIconNumber == 7 then
233 if g_currentMission.tourVehicles["tourCombine"]:getIsTurnedOn() and g_currentMission.tourVehicles["tourCombine"]:getIsAIActive() then
234 -- self:activateNextIcon()
235 self.pauseTime = 1000
236 self.isPaused = true
237 end
238
239 --# cultivating
240
241 -- wait for player to enter tractor1 and attach cultivator
242 elseif self.currentTourIconNumber <= 9 then
243 if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor1"] then
244 if self.currentTourIconNumber == 8 then
245 self:activateNextIcon()
246 end
247
248 if g_currentMission.tourVehicles["tourCultivator"]:getRootVehicle() == g_currentMission.tourVehicles["tourTractor1"]
249 and g_currentMission.tourVehicles["tourWeight1"]:getRootVehicle() == g_currentMission.tourVehicles["tourTractor1"] then
250 -- self:activateNextIcon()
251 self.pauseTime = 1000
252 self.isPaused = true
253 end
254 end
255 elseif self.currentTourIconNumber == 11 then
256 -- self:activateNextIcon()
257 self.pauseTime = 1000
258 self.isPaused = true
259
260 --# sowing
261
262 -- wait for player to enter tractor2 and attach sowingMachine
263 elseif self.currentTourIconNumber <= 13 then
264 if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor2"] then
265 if self.currentTourIconNumber == 12 then
266 self:activateNextIcon()
267 end
268
269 if g_currentMission.tourVehicles["tourSowingMachine"]:getRootVehicle() == g_currentMission.tourVehicles["tourTractor2"]
270 and g_currentMission.tourVehicles["tourWeight2"]:getRootVehicle() == g_currentMission.tourVehicles["tourTractor2"] then
271 -- self:activateNextIcon()
272 self.pauseTime = 1000
273 self.isPaused = true
274 end
275 end
276
277 --# overloading / tipping
278
279 -- wait for player to enter tractor3 and attach trailer
280 elseif self.currentTourIconNumber <= 16 then
281 if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor3"] then
282 if self.currentTourIconNumber < 16 then
283 self:activateNextIcon()
284 end
285
286 if g_currentMission.tourVehicles["tourTrailer"]:getRootVehicle() == g_currentMission.tourVehicles["tourTractor3"] then
287 -- self:activateNextIcon()
288 self.pauseTime = 1000
289 self.isPaused = true
290 end
291 end
292 elseif self.currentTourIconNumber == 17 then
293 if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor3"] then
294 if g_currentMission.tourVehicles["tourTrailer"]:getRootVehicle() == g_currentMission.tourVehicles["tourTractor3"] then
295
296 local tractor = g_currentMission.tourVehicles["tourTractor3"]
297 local trailer = g_currentMission.tourVehicles["tourTrailer"]
298 local combine = g_currentMission.tourVehicles["tourCombine"]
299
300 local x,y,z = localToWorld(combine.components[1].node, 6,0,0)
301 self.mapHotspot:setWorldPosition(x, z)
302
303 local xv,yv,zv = getWorldTranslation(tractor.components[1].node)
304 local dist = MathUtil.vector3Length(x-xv, y-yv, z-zv)
305 if dist < 10 then
306 g_currentMission:setMapTargetHotspot(nil)
307 else
308 g_currentMission:setMapTargetHotspot(self.mapHotspot)
309 end
310
311 local fillUnitIndex = 1
312 local dischargeNode = combine:getCurrentDischargeNode()
313 if trailer:getFillUnitFillLevel(fillUnitIndex) > 0 and dischargeNode ~= nil and dischargeNode.dischargeObject == trailer then
314 -- self:activateNextIcon()
315 self.pauseTime = 1000
316 self.isPaused = true
317 end
318 end
319 else
320 -- If the harvester is full or stopped, and a player goes into the harvester to open the pipe, the trailer vehicle
321 -- is not controlled so above code does not trigger. This cascades and breaks the tour.
322 if g_currentMission.tourVehicles["tourTrailer"]:getFillUnitFillLevel(1) > 400 then
323 self.pauseTime = 1000
324 self.isPaused = true
325 end
326 end
327 elseif self.currentTourIconNumber == 19 then
328 -- self:activateNextIcon()
329 self.pauseTime = 3000
330 self.isPaused = true
331 elseif self.currentTourIconNumber <= 20 then
332 if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle == g_currentMission.tourVehicles["tourTractor3"] then
333 if self.currentTourIconNumber == 19 then
334 self:activateNextIcon()
335 end
336
337 if g_currentMission.tourVehicles["tourTrailer"]:getRootVehicle() == g_currentMission.tourVehicles["tourTractor3"] then
338 local trailer = g_currentMission.tourVehicles["tourTrailer"]
339
340 local unloadingStation
341 for _, station in pairs(g_currentMission.storageSystem:getUnloadingStations()) do
342 if station.owningPlaceable ~= nil and station.owningPlaceable.mapBoundId == "sellingStationRestaurant" then
343 unloadingStation = station
344 break
345 end
346 end
347
348 local dischargeNode = trailer:getCurrentDischargeNode()
349
350 if dischargeNode ~= nil and dischargeNode.currentDischargeObject ~= nil and dischargeNode.currentDischargeObject:getTarget() == unloadingStation then
351 -- self:activateNextIcon()
352 self.pauseTime = 3000
353 self.isPaused = true
354 end
355 end
356 end
357 --# shop
358 elseif self.currentTourIconNumber == 22 then
359 -- self:activateNextIcon()
360 self.pauseTime = 1000
361 self.isPaused = true
362 end
363
364 end
365end