Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- AbstractManager
- AsyncManager
- AutoSaveManager
- BaleTypeManager
- BrandColorManager
- ConnectionHoseManager
- DeferredLoadingManager
- DepthOfFieldManager
- FillTypeManager
- FruitTypeManager
- GameplayHintManager
- GroundTypeManager
- HelpLineManager
- MapManager
- PlaceableTypeManager
- SleepManager
- SplitTypeManager
- SprayTypeManager
- TensionBeltManager
- ToolTypeManager
- TreePlantManager
- 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
GameplayHintManager
DescriptionThis class handles all basic functionality for map loading gamehintsParent
AbstractManagerFunctions
getRandomGameplayHint
DescriptionGets random gamplay hintsDefinition
getRandomGameplayHint(integer numHints)Arguments
integer | numHints | number of hints |
table | gameplayHintGroup | a random gameplay hint group |
68 | function GameplayHintManager:getRandomGameplayHint(numberOfHints) |
69 | local hints = {} |
70 | local addedHints = {} |
71 | |
72 | -- Prevent infinite lookup loop by checking the number of hints |
73 | if #self.gameplayHints <= numberOfHints then |
74 | return self.gameplayHints |
75 | end |
76 | |
77 | local numHints = #self.gameplayHints |
78 | while #hints < numberOfHints do |
79 | local hintId = math.random(1, numHints) |
80 | if addedHints[hintId] == nil then |
81 | table.insert(hints, self.gameplayHints[hintId]) |
82 | addedHints[hintId] = hintId |
83 | end |
84 | end |
85 | |
86 | return hints |
87 | end |
initDataStructures
DescriptionInitialize data structuresDefinition
initDataStructures()Code
24 | function GameplayHintManager:initDataStructures() |
25 | self.gameplayHints = {} |
26 | self.isLoaded = false |
27 | end |
loadMapData
DescriptionLoad data on map loadDefinition
loadMapData()Return Values
boolean | true | if loading was successful else false |
32 | function GameplayHintManager:loadMapData(xmlFile, missionInfo) |
33 | GameplayHintManager:superClass().loadMapData(self) |
34 | |
35 | local filename = Utils.getFilename(getXMLString(xmlFile, "map.gameplayHints#filename"), g_currentMission.baseDirectory) |
36 | if filename == nil or filename == "" then |
37 | print("Error: Could not load gameplayHint config file '"..tostring(filename).."'!") |
38 | return false |
39 | end |
40 | |
41 | local gameplayHintXmlFile = loadXMLFile("gameplayHints", filename) |
42 | local i = 0 |
43 | while true do |
44 | local key = string.format("gameplayHints.gameplayHint(%d)", i) |
45 | if not hasXMLProperty(gameplayHintXmlFile, key) then |
46 | break |
47 | end |
48 | |
49 | local text = getXMLString(gameplayHintXmlFile, key) |
50 | if text:sub(1,6) == "$l10n_" then |
51 | text = g_i18n:getText(text:sub(7), missionInfo.customEnvironment) |
52 | end |
53 | table.insert(self.gameplayHints, text) |
54 | |
55 | i = i + 1 |
56 | end |
57 | delete(gameplayHintXmlFile) |
58 | |
59 | self.isLoaded = true |
60 | |
61 | return true |
62 | end |
new
DescriptionCreating managerDefinition
new()Return Values
table | instance | instance of object |
16 | function GameplayHintManager:new(customMt) |
17 | local self = AbstractManager:new(customMt or GameplayHintManager_mt) |
18 | |
19 | return self |
20 | end |