1- local SCRIPTING_EXTENSIONS
1+ local SCRIPTING_EXTENSION_CODE
22
33local DESTROYED_ELEMENT_DIMENSION = getWorkingDimension () + 1
44function toAttribute (value )
@@ -197,7 +197,7 @@ function dumpMeta ( xml, extraNodes, resource, filename, test )
197197
198198 -- Add the map editor scripting extension scripts to meta
199199 local scriptName = " newMapEditorScriptingExtension_s.lua"
200- local scriptContent = SCRIPTING_EXTENSIONS [ " server " ]
200+ local scriptContent = SCRIPTING_EXTENSION_CODE
201201 local foundScriptInMeta = false
202202 for i , child in ipairs (xmlNodeGetChildren (xml )) do
203203 if (xmlNodeGetAttribute (child , " src" ) == scriptName ) then
@@ -220,31 +220,6 @@ function dumpMeta ( xml, extraNodes, resource, filename, test )
220220 xmlNodeSetAttribute (scriptNode , " type" , " server" )
221221 end
222222
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-
248223 return xmlSaveFile (xml )
249224end
250225
@@ -260,32 +235,7 @@ function getMapElementData ( element )
260235 return elementData
261236end
262237
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
289239-- 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
290240-- VERSION: 11/October/2024
291241-- IMPORTANT: Check the resource 'editor_main' at https://github.com/mtasa-resources/ for updates
@@ -294,6 +244,7 @@ local resourceName = getResourceName(resource)
294244local usedLODModels = {}
295245local LOD_MAP_NEW = {}
296246
247+ -- Makes removeWorldObject map entries and LODs work
297248local function onResourceStartOrStop(startedResource)
298249 local startEvent = eventName == "onResourceStart"
299250 local removeObjects = getElementsByType("removeWorldObject", source)
350301addEventHandler("onResourceStart", resourceRoot, onResourceStartOrStop, false)
351302addEventHandler("onResourceStop", resourceRoot, onResourceStartOrStop, false)
352303
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-
359304-- MTA LOD Table [object] = [lodmodel]]
360- }
361305
362- SCRIPTING_EXTENSIONS [ " server " ] = SCRIPTING_EXTENSIONS [ " server " ] .. " \n " .. getLodsLuaTableString ()
306+ SCRIPTING_EXTENSION_CODE = SCRIPTING_EXTENSION_CODE .. " \n " .. getLodsLuaTableString ()
0 commit comments