Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- AnimalHusbandry
- BeehivePlaceable
- BgaPlaceable
- BunkerSiloPlaceable
- BuyingStationPlaceable
- Doghouse
- FarmhousePlaceable
- GreenhousePlaceable
- HeatingPlantPlaceable
- HusbandryModuleWater
- Placeable
- SellingStationPlaceable
- SiloExtensionPlaceable
- SiloPlaceable
- SolarCollectorPlaceable
- WindTurbinePlaceable
- WoodSellStationPlaceable
- 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
WoodSellStationPlaceable
ParentPlaceableFunctions
addUpdateEventListener
DescriptionAdd listener to update listenersDefinition
addUpdateEventListener()Code
207 | function WoodSellStationPlaceable:addUpdateEventListener(listener) |
208 | if listener ~= nil then |
209 | self.updateEventListeners[listener] = listener |
210 | end |
211 | end |
delete
DescriptionDeleting triggerDefinition
delete()Code
38 | function WoodSellStationPlaceable:delete() |
39 | if self.mapHotspot ~= nil then |
40 | g_currentMission:removeMapHotspot(self.mapHotspot) |
41 | self.mapHotspot:delete() |
42 | end |
43 | |
44 | if self.woodSellTrigger ~= nil then |
45 | removeTrigger(self.woodSellTrigger) |
46 | self.woodSellTrigger = nil |
47 | end |
48 | |
49 | if self.sellTrigger ~= nil then |
50 | g_currentMission:removeActivatableObject(self) |
51 | removeTrigger(self.sellTrigger) |
52 | self.sellTrigger = nil |
53 | end |
54 | |
55 | unregisterObjectClassName(self) |
56 | WoodSellStationPlaceable:superClass().delete(self) |
57 | end |
getIsActivatable
DescriptionReturns true if wood can be soldDefinition
getIsActivatable()Return Values
boolean | isActivateable | is activateable |
277 | function WoodSellStationPlaceable:getIsActivatable() |
278 | return g_currentMission.controlPlayer |
279 | end |
load
DescriptionLoad woodsell stationDefinition
load(string xmlFilename, float x, float y, float z, float rx, float ry, float rz, boolean initRandom)Arguments
string | xmlFilename | xml file name |
float | x | x world position |
float | y | z world position |
float | z | z world position |
float | rx | rx world rotation |
float | ry | ry world rotation |
float | rz | rz world rotation |
boolean | initRandom | initialize random |
boolean | success | success |
70 | function WoodSellStationPlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom) |
71 | if not WoodSellStationPlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then |
72 | return false |
73 | end |
74 | |
75 | local xmlFile = loadXMLFile("TempXML", xmlFilename) |
76 | |
77 | self.appearsOnPDA = Utils.getNoNil(getXMLBool(xmlFile, "placeable.woodSellStation#appearsOnPDA"), false) |
78 | local rawName = Utils.getNoNil(getXMLString(xmlFile, "placeable.woodSellStation#stationName"), "WoodSellStation") |
79 | self.stationName = g_i18n:convertText(rawName) -- returns input if it cannot be resolved |
80 | |
81 | local woodSellTrigger = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.woodSellStation#triggerNode")) |
82 | if woodSellTrigger == nil then |
83 | g_logManager:xmlWarning(xmlFilename, "Missing wood trigger node in 'placeable.woodSellStation#triggerNode'!") |
84 | delete(xmlFile) |
85 | return false |
86 | end |
87 | |
88 | local colMask = getCollisionMask(woodSellTrigger) |
89 | if bitAND(SplitTypeManager.COLLISIONMASK_TRIGGER, colMask) == 0 then |
90 | g_logManager:xmlWarning(xmlFilename, "Invalid collision mask for wood trigger 'placeable.woodSellStation#triggerNode'. Bit 24 needs to be set!") |
91 | delete(xmlFile) |
92 | return false |
93 | end |
94 | |
95 | addTrigger(woodSellTrigger, "woodTriggerCallback", self) |
96 | self.woodSellTrigger = woodSellTrigger |
97 | |
98 | |
99 | local sellTrigger = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.woodSellStation#sellTrigger")) |
100 | if sellTrigger == nil then |
101 | g_logManager:xmlWarning(xmlFilename, "Missing sell trigger in 'placeable.woodSellStation#sellTrigger'!") |
102 | delete(xmlFile) |
103 | return false |
104 | end |
105 | |
106 | colMask = getCollisionMask(sellTrigger) |
107 | if bitAND(Player.COLLISIONMASK_TRIGGER, colMask) == 0 then |
108 | g_logManager:xmlWarning(xmlFilename, "Invalid collision mask for sell trigger 'placeable.woodSellStation#triggerNode'. Bit 20 needs to be set!") |
109 | delete(xmlFile) |
110 | return false |
111 | end |
112 | |
113 | if self.appearsOnPDA then |
114 | local mapPosition = self.woodSellTrigger |
115 | local mapPositionIndex = getUserAttribute(self.woodSellTrigger, "mapPositionIndex") |
116 | if mapPositionIndex ~= nil then |
117 | mapPosition = I3DUtil.indexToObject(self.woodSellTrigger, mapPositionIndex) |
118 | if mapPosition == nil then |
119 | mapPosition = self.woodSellTrigger |
120 | end |
121 | end |
122 | local filenames = nil |
123 | local imageUVs = getNormalizedUVs(MapHotspot.UV.SELLING_POINT) |
124 | local x, _, z = getWorldTranslation(mapPosition) |
125 | |
126 | local hotspotTextOffset = Utils.getNoNil(getXMLString(xmlFile, "placeable.woodSellStation#hotspotTextOffset"), "0px 0px") |
127 | |
128 | self.mapHotspot = MapHotspot:new("woodSellStation", MapHotspot.CATEGORY_TRIGGER) |
129 | self.mapHotspot:setText(self.stationName) |
130 | self.mapHotspot:setBorderedImage(nil, imageUVs, {0.9559, 0.5647, 0.0423, 1}) |
131 | self.mapHotspot:setTextOptions(nil, nil, nil, {0.9559, 0.5647, 0.0423, 1}) |
132 | self.mapHotspot:setWorldPosition(x, z) |
133 | self.mapHotspot:setRawTextOffset(hotspotTextOffset) |
134 | |
135 | g_currentMission:addMapHotspot(self.mapHotspot) |
136 | end |
137 | |
138 | addTrigger(sellTrigger, "woodSellTriggerCallback", self) |
139 | self.sellTrigger = sellTrigger |
140 | |
141 | self.activateText = g_i18n:getText("action_sellWood") |
142 | self.objectActivated = false |
143 | |
144 | self.updateEventListeners = {} |
145 | |
146 | delete(xmlFile) |
147 | |
148 | return true |
149 | end |
new
DescriptionCreating woodsell stationDefinition
new(boolean isServer, boolean isClient, table customMt)Arguments
boolean | isServer | is server |
boolean | isClient | is client |
table | customMt | custom metatable |
table | instance | Instance of object |
26 | function WoodSellStationPlaceable:new(isServer, isClient, customMt) |
27 | local self = Placeable:new(isServer, isClient, customMt or WoodSellStationPlaceable_mt) |
28 | |
29 | registerObjectClassName(self, "WoodSellStationPlaceable") |
30 | |
31 | self.woodInTrigger = {} |
32 | |
33 | return self |
34 | end |
onActivateObject
DescriptionCalled on activate objectDefinition
onActivateObject()Code
287 | function WoodSellStationPlaceable:onActivateObject() |
288 | g_currentMission:addActivatableObject(self) |
289 | self.objectActivated = true |
290 | self:sellWood(g_currentMission:getFarmId()) |
291 | end |
removeUpdateEventListener
DescriptionRemove listener from update listenersDefinition
removeUpdateEventListener()Code
215 | function WoodSellStationPlaceable:removeUpdateEventListener(listener) |
216 | if listener ~= nil then |
217 | self.updateEventListeners[listener] = nil |
218 | end |
219 | end |