So more of me trying to screw around with t-engine and getting lost.
Today's questions:
1) What exactly is loading_list? It seems to be able to be used to reference entities that have already been loaded from a file?
2) How do I delete an entity? In this case, I'm try to have an addon delete an ego from the list of possible egos. Is there a way I can reference a table and then remove it from the table?
Thanks!
More stupid questions: loading_list, and entity destruction
Moderator: Moderator
More stupid questions: loading_list, and entity destruction
Please help with the ToME wiki!
-
- Sher'Tul Godslayer
- Posts: 2521
- Joined: Thu Jan 23, 2003 8:13 pm
- Location: A shallow water area south of Bree
- Contact:
Re: More stupid questions: loading_list, and entity destruct
[sound F/X: source diving] That's some magic done by Entity:loadList(). If you're in a file being loaded by Entity:loadList(), loading_list will be a reference to the list of entities being loaded.ibanix wrote:1) What exactly is loading_list? It seems to be able to be used to reference entities that have already been loaded from a file?
You can do this from an 'Entity:loadList' hook. In your hooks/load.lua, add something like:ibanix wrote:2) How do I delete an entity? In this case, I'm try to have an addon delete an ego from the list of possible egos. Is there a way I can reference a table and then remove it from the table?
Code: Select all
class:bindHook('Entity:loadList', function(self, data)
-- data.file is the name of the file being loaded.
if data.file == '/data/general/objects/egos/file-that-defines-the-ego-you-want-to-remove.lua' then
-- data.res is the table into which entities are being loaded; you can manipulate
-- it to alter or remove entities.
for i, e in ipairs(data.res) do
if e.name == 'the ego you want to remove' then
table.remove(data.res, i)
break
end
end
end
end)
"Blessed are the yeeks, for they shall inherit Arda..."
Re: More stupid questions: loading_list, and entity destruct
Zizzo, once again you are the man. Thank you.
Please help with the ToME wiki!