Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- AIParameter
- AIParameterFillType
- AIParameterGroup
- AIParameterLoadingStation
- AIParameterLooping
- AIParameterPosition
- AIParameterPositionAngle
- AIParameterUnloadingStati...
- AIParameterVehicle
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
AIParameterPositionAngle
ParentAIParameterPositionFunctions
- getAngle
- getDirection
- getSnappingAngle
- getString
- loadFromXMLFile
- new
- readStream
- saveToXMLFile
- setAngle
- setSnappingAngle
- validate
- writeStream
getAngle
DescriptionDefinitiongetAngle()Code
85 | function AIParameterPositionAngle:getAngle() |
86 | return self.angle |
87 | end |
getDirection
DescriptionDefinitiongetDirection()Code
91 | function AIParameterPositionAngle:getDirection() |
92 | if self.angle == nil then |
93 | return nil, nil |
94 | end |
95 | |
96 | local xDir, zDir = MathUtil.getDirectionFromYRotation(self.angle) |
97 | |
98 | return xDir, zDir |
99 | end |
getSnappingAngle
DescriptionDefinitiongetSnappingAngle()Code
109 | function AIParameterPositionAngle:getSnappingAngle() |
110 | return self.snappingAngle |
111 | end |
getString
DescriptionDefinitiongetString()Code
115 | function AIParameterPositionAngle:getString() |
116 | return string.format("< %.1f , %.1f | %d° >", self.x, self.z, math.deg(self.angle)) |
117 | end |
loadFromXMLFile
DescriptionDefinitionloadFromXMLFile()Code
38 | function AIParameterPositionAngle:loadFromXMLFile(xmlFile, key) |
39 | AIParameterPositionAngle:superClass().loadFromXMLFile(self, xmlFile, key) |
40 | |
41 | self.angle = xmlFile:getFloat(key .. "#angle", self.angle) |
42 | end |
new
DescriptionDefinitionnew()Code
16 | function AIParameterPositionAngle.new(snappingAngle, customMt) |
17 | local self = AIParameterPosition.new(customMt or AIParameterPositionAngle_mt) |
18 | |
19 | self.type = AIParameterType.POSITION_ANGLE |
20 | |
21 | self.angle = nil |
22 | self.snappingAngle = math.abs(snappingAngle or math.rad(5)) |
23 | |
24 | return self |
25 | end |
readStream
DescriptionDefinitionreadStream()Code
46 | function AIParameterPositionAngle:readStream(streamId, connection) |
47 | AIParameterPositionAngle:superClass().readStream(self, streamId, connection) |
48 | |
49 | if streamReadBool(streamId) then |
50 | local angle = streamReadUIntN(streamId, 9) |
51 | self:setAngle(math.rad(angle)) |
52 | end |
53 | end |
saveToXMLFile
DescriptionDefinitionsaveToXMLFile()Code
29 | function AIParameterPositionAngle:saveToXMLFile(xmlFile, key, usedModNames) |
30 | AIParameterPositionAngle:superClass().saveToXMLFile(self, xmlFile, key, usedModNames) |
31 | if self.angle ~= nil then |
32 | xmlFile:setFloat(key .. "#angle", self.angle) |
33 | end |
34 | end |
setAngle
DescriptionDefinitionsetAngle()Code
68 | function AIParameterPositionAngle:setAngle(angleRad) |
69 | angleRad = angleRad % (2*math.pi) |
70 | |
71 | if angleRad < 0 then |
72 | angleRad = angleRad + 2*math.pi |
73 | end |
74 | |
75 | if self.snappingAngle > 0 then |
76 | local numSteps = MathUtil.round(angleRad / self.snappingAngle, 0) |
77 | angleRad = numSteps * self.snappingAngle |
78 | end |
79 | |
80 | self.angle = angleRad |
81 | end |
setSnappingAngle
DescriptionDefinitionsetSnappingAngle()Code
103 | function AIParameterPositionAngle:setSnappingAngle(angle) |
104 | self.snappingAngle = math.abs(angle) |
105 | end |
validate
DescriptionDefinitionvalidate()Code
121 | function AIParameterPositionAngle:validate(fillTypeIndex, farmId) |
122 | local isValid, errorMessage = AIParameterPositionAngle:superClass().validate(self, fillTypeIndex, farmId) |
123 | if not isValid then |
124 | return false, errorMessage |
125 | end |
126 | |
127 | if self.angle == nil then |
128 | return false, g_i18n:getText("ai_validationErrorNoAngle") |
129 | end |
130 | |
131 | return true, nil |
132 | end |
writeStream
DescriptionDefinitionwriteStream()Code
57 | function AIParameterPositionAngle:writeStream(streamId, connection) |
58 | AIParameterPositionAngle:superClass().writeStream(self, streamId, connection) |
59 | |
60 | if streamWriteBool(streamId, self.angle ~= nil) then |
61 | local angle = math.deg(self.angle) |
62 | streamWriteUIntN(streamId, angle, 9) |
63 | end |
64 | end |