Administrators Lpsd Posted December 10, 2016 Administrators Share Posted December 10, 2016 I'm currently trying to put both objects, and spawnpoints, both in separate lists. Here's what I have so far: local curSpawns = getElementsByType ( "spawnpoint" ) for i,spawnData in ipairs(curSpawns) do local spawn_name = getElementData( spawnData, "id") local row = guiGridListAddRow( spawnList ) guiGridListSetItemText( spawnList, row, spawnColumn, i .. ": " .. spawn_name, false, true ) end local curObj = getElementsByType ( "object" ) for i,objData in ipairs(curObj) do local obj_name = getElementData( objData, "id") local row = guiGridListAddRow( objList ) guiGridListSetItemText( objList, row, objColumn, i .. ": " .. obj_name, false, true ) end However, the spawnpoints are appearing inside the objects list. Here's the result: Are spawnpoints handled as an 'object' type as well as 'spawnpoint'? Link to comment
LoPollo Posted December 10, 2016 Share Posted December 10, 2016 Mmmm they should be elements, which are NOT objects... also your code IS correct. Still it's easy to workaround i guess, get element type and check if it's actually an object: getElementType 1 Link to comment
Administrators Lpsd Posted December 10, 2016 Author Administrators Share Posted December 10, 2016 27 minutes ago, LoPollo said: Mmmm they should be elements, which are NOT objects... also your code IS correct. Still it's easy to workaround i guess, get element type and check if it's actually an object: getElementType Sounds like it should work, but doesn't. Maybe my logic is wrong here: local curObj = getElementsByType ( "object" ) for i,objData in ipairs(curObj) do if getElementType( objData ) == "spawnpoint" then --donothing else local obj_name = getElementData( objData, "id") local row = guiGridListAddRow( objList ) guiGridListSetItemText( objList, row, objColumn, i .. ": " .. obj_name, false, true ) end end Link to comment
LoPollo Posted December 10, 2016 Share Posted December 10, 2016 Strange... but note, just in case there are other elements than spawnpoints that are considered "objects", it's better to check if the element is an object instead if it's a spawnpoint. I'm worried about a possible cause of this: maybe even getElementType returns object when processing spawnpoints? Since you are pratically already doing this with the names... maybe an idea could be using the data assigned? local curObj = getElementsByType ( "object" ) for i,objData in ipairs(curObj) do if string.find(getElementData( objData, "id"),"object") == 1 then --if the word "object" is the first word i.e. starts at first character local obj_name = getElementData( objData, "id") local row = guiGridListAddRow( objList ) guiGridListSetItemText( objList, row, objColumn, i .. ": " .. obj_name, false, true ) else --nope end end Link to comment
Administrators Lpsd Posted December 10, 2016 Author Administrators Share Posted December 10, 2016 10 minutes ago, LoPollo said: Strange... but note, just in case there are other elements than spawnpoints that are considered "objects", it's better to check if the element is an object instead if it's a spawnpoint. I'm worried about a possible cause of this: maybe even getElementType returns object when processing spawnpoints? Since you are pratically already doing this with the names... maybe an idea could be using the data assigned? local curObj = getElementsByType ( "object" ) for i,objData in ipairs(curObj) do if string.find(getElementData( objData, "id"),"object") == 1 then --if the word "object" is the first word i.e. starts at first character local obj_name = getElementData( objData, "id") local row = guiGridListAddRow( objList ) guiGridListSetItemText( objList, row, objColumn, i .. ": " .. obj_name, false, true ) else --nope end end I guess I thought, that because the spawnpoint was being treated like an object through "getElementsByType", checking whether the element was an object wouldn't have any effect. and yeah I guess that's the only way to do it in this situation. Much appreciated 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now