Hey leute ich bin grade an einen kleinen Projekt wofür ich einen mapmanager mit edf gescriptet habe.
Nun habe ich mal eine map gemacht mein Problem ist er gibt mir nur ein mal spawnpoint_dm(0) wieder anstatt komplett alle.
Hier ein stück code
Lua
function Mapmanager:Startmap(res)
MapElement = {}
if (Mapmanager:isMap(res))then
local typ
local resname = getResourceName(res)
local mapxml = xmlLoadFile(':'..resname..'/' .. 'meta.xml')
if (not(mapxml)) then
Mapmanager:Log(resname..' konnte nicht gestartet werden die meta.xml wurde nicht gefunden!', 'debug', nil)
return false
end
-- Settings Development --
local infonode = xmlFindChild(mapxml, 'info', 0)
local info = infonode and xmlNodeGetAttributes (infonode) or {}
local filename = xmlNodeGetAttribute(xmlFindChild(mapxml, 'map', 0), 'src')
local mapnode = xmlLoadFile(':' .. getResourceName(res) .. '/' .. filename)
local def = xmlNodeGetAttribute(mapnode, "edf:definitions")
if (xmlFindChild(mapnode, 'spawnpoint_dm', 0)) then
typ = 'dm'
elseif(xmlFindChild(mapnode, 'spawnpoint_gungame', 0)) then
typ = 'gungame'
elseif(xmlFindChild(mapnode, 'spawnpoint_minigun', 0)) then
typ = 'minigun'
elseif(xmlFindChild(mapnode, 'spawnpoint_team_red', 0) or xmlFindChild(mapnode, 'spawnpoint_team_blue', 0)) then
typ = 'tdm'
end
local spawnpoints = xmlNodeGetAttributes(xmlFindChild(mapnode, 'spawnpoint_'..tostring(typ), 0))
for k, v in pairs(spawnpoints) do
outputChatBox(k)
end
if (string.find(def, 'glc')) then
xmlUnloadFile(mapxml)
xmlUnloadFile(mapnode)
if (not(mapnode)) then
Mapmanager:Log(resname..' konnte nicht gestartet werden die <glc/> tag wurde nicht gefunden!', 'debug', nil)
return false
end
end
-- setmetatable({map = res, mapname = resname, typ = typ, mapinfo = info, mapdef = def, spawnpoint = spawnpoints}, MapElement) -- rawget not like --
table.insert(MapElement, {map = res, mapname = resname, typ = typ, mapinfo = info, mapdef = def, spawnpoint = spawnpoints})
end
return table.getn(MapElement)
end
Alles anzeigen
Lua
-- MAP --
<map edf:definitions="glc">
<spawnpoint_dm id="spawnpoint_dm (1)" interior="0" skin="121" dimension="0" posX="2462.5" posY="-1660.9" posZ="13.3" rotX="0" rotY="0" rotZ="0"></spawnpoint_dm>
<spawnpoint_dm id="spawnpoint_dm (2)" interior="0" skin="121" dimension="0" posX="2469.7" posY="-1662.8" posZ="13.3" rotX="0" rotY="0" rotZ="0"></spawnpoint_dm>
<spawnpoint_dm id="spawnpoint_dm (3)" interior="0" skin="121" dimension="0" posX="2470.8" posY="-1656" posZ="13.3" rotX="0" rotY="0" rotZ="0"></spawnpoint_dm>
</map>
@Edit: Wollte erst kein while benutzen weil ich nur schlechte erfahrung hatte damit aber Lux meinte ich solls mal mit versuchen hier Lösung