1
- local SCRIPTING_EXTENSIONS
1
+ local SCRIPTING_EXTENSION_CODE
2
2
3
3
local DESTROYED_ELEMENT_DIMENSION = getWorkingDimension () + 1
4
4
function toAttribute (value )
@@ -197,7 +197,7 @@ function dumpMeta ( xml, extraNodes, resource, filename, test )
197
197
198
198
-- Add the map editor scripting extension scripts to meta
199
199
local scriptName = " newMapEditorScriptingExtension_s.lua"
200
- local scriptContent = SCRIPTING_EXTENSIONS [ " server " ]
200
+ local scriptContent = SCRIPTING_EXTENSION_CODE
201
201
local foundScriptInMeta = false
202
202
for i , child in ipairs (xmlNodeGetChildren (xml )) do
203
203
if (xmlNodeGetAttribute (child , " src" ) == scriptName ) then
@@ -220,31 +220,6 @@ function dumpMeta ( xml, extraNodes, resource, filename, test )
220
220
xmlNodeSetAttribute (scriptNode , " type" , " server" )
221
221
end
222
222
223
- scriptName = " newMapEditorScriptingExtension_c.lua"
224
- scriptContent = SCRIPTING_EXTENSIONS [" client" ]
225
- foundScriptInMeta = false
226
- for i , child in ipairs (xmlNodeGetChildren (xml )) do
227
- if (xmlNodeGetAttribute (child , " src" ) == scriptName ) then
228
- foundScriptInMeta = true
229
- break
230
- end
231
- end
232
- -- If for some reason the file fails to create, we won't add it to meta.xml
233
- scriptExtFile = fileCreate (" :" .. getResourceName (resource ).. " /" .. scriptName )
234
- scriptExtFileSuccess = false
235
- if scriptExtFile then
236
- if fileWrite (scriptExtFile , scriptContent ) then
237
- scriptExtFileSuccess = true
238
- end
239
- fileClose (scriptExtFile )
240
- end
241
- if scriptExtFileSuccess and (not foundScriptInMeta ) then
242
- local scriptNode = xmlCreateChild (xml , " script" )
243
- xmlNodeSetAttribute (scriptNode , " src" , scriptName )
244
- xmlNodeSetAttribute (scriptNode , " type" , " client" )
245
- xmlNodeSetAttribute (scriptNode , " validate" , " false" )
246
- end
247
-
248
223
return xmlSaveFile (xml )
249
224
end
250
225
@@ -260,32 +235,7 @@ function getMapElementData ( element )
260
235
return elementData
261
236
end
262
237
263
- SCRIPTING_EXTENSIONS = {
264
- [" client" ] = [[ -- FILE: newMapEditorScriptingExtension_c.lua
265
- -- PURPOSE: Prevent the map editor feature set being limited by what MTA can load from a map file by adding a script file to maps
266
- -- VERSION: 11/October/2024
267
- -- IMPORTANT: Check the resource 'editor_main' at https://github.com/mtasa-resources/ for updates
268
-
269
- local resourceName = getResourceName(resource)
270
- local updatedLodDistances = {}
271
-
272
- local function setLODsClient(lodTbl)
273
- for model in pairs(lodTbl) do
274
- updatedLodDistances[model] = true
275
- engineSetModelLODDistance(model, 300)
276
- end
277
- end
278
- addEvent(resourceName..":setLODsClient", true)
279
- addEventHandler(resourceName..":setLODsClient", resourceRoot, setLODsClient)
280
-
281
- local function handleClientResourceStop()
282
- for model in pairs(updatedLodDistances) do
283
- engineResetModelLODDistance(model)
284
- end
285
- end
286
- addEventHandler("onClientResourceStop", resourceRoot, handleClientResourceStop, false)]] ,
287
-
288
- [" server" ] = [[ -- FILE: newMapEditorScriptingExtension_s.lua
238
+ SCRIPTING_EXTENSION_CODE = [[ -- FILE: newMapEditorScriptingExtension_s.lua
289
239
-- PURPOSE: Prevent the map editor feature set being limited by what MTA can load from a map file by adding a script file to maps
290
240
-- VERSION: 11/October/2024
291
241
-- IMPORTANT: Check the resource 'editor_main' at https://github.com/mtasa-resources/ for updates
@@ -294,6 +244,7 @@ local resourceName = getResourceName(resource)
294
244
local usedLODModels = {}
295
245
local LOD_MAP_NEW = {}
296
246
247
+ -- Makes removeWorldObject map entries and LODs work
297
248
local function onResourceStartOrStop(startedResource)
298
249
local startEvent = eventName == "onResourceStart"
299
250
local removeObjects = getElementsByType("removeWorldObject", source)
350
301
addEventHandler("onResourceStart", resourceRoot, onResourceStartOrStop, false)
351
302
addEventHandler("onResourceStop", resourceRoot, onResourceStartOrStop, false)
352
303
353
- local function onPlayerResourceStart(res)
354
- if res ~= resource then return end
355
- triggerClientEvent(source, resourceName..":setLODsClient", resourceRoot, usedLODModels)
356
- end
357
- addEventHandler("onPlayerResourceStart", root, onPlayerResourceStart)
358
-
359
304
-- MTA LOD Table [object] = [lodmodel]]
360
- }
361
305
362
- SCRIPTING_EXTENSIONS [ " server " ] = SCRIPTING_EXTENSIONS [ " server " ] .. " \n " .. getLodsLuaTableString ()
306
+ SCRIPTING_EXTENSION_CODE = SCRIPTING_EXTENSION_CODE .. " \n " .. getLodsLuaTableString ()
0 commit comments