mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add minetest.register_lbm() to run code on block load only
This commit is contained in:
parent
88fbe7ca1e
commit
d494733839
12 changed files with 493 additions and 25 deletions
|
@ -419,7 +419,7 @@ public:
|
|||
inline virtual const ContentFeatures& get(const MapNode &n) const;
|
||||
virtual bool getId(const std::string &name, content_t &result) const;
|
||||
virtual content_t getId(const std::string &name) const;
|
||||
virtual void getIds(const std::string &name, std::set<content_t> &result) const;
|
||||
virtual bool getIds(const std::string &name, std::set<content_t> &result) const;
|
||||
virtual const ContentFeatures& get(const std::string &name) const;
|
||||
content_t allocateId();
|
||||
virtual content_t set(const std::string &name, const ContentFeatures &def);
|
||||
|
@ -603,22 +603,23 @@ content_t CNodeDefManager::getId(const std::string &name) const
|
|||
}
|
||||
|
||||
|
||||
void CNodeDefManager::getIds(const std::string &name,
|
||||
bool CNodeDefManager::getIds(const std::string &name,
|
||||
std::set<content_t> &result) const
|
||||
{
|
||||
//TimeTaker t("getIds", NULL, PRECISION_MICRO);
|
||||
if (name.substr(0,6) != "group:") {
|
||||
content_t id = CONTENT_IGNORE;
|
||||
if(getId(name, id))
|
||||
bool exists = getId(name, id);
|
||||
if (exists)
|
||||
result.insert(id);
|
||||
return;
|
||||
return exists;
|
||||
}
|
||||
std::string group = name.substr(6);
|
||||
|
||||
std::map<std::string, GroupItems>::const_iterator
|
||||
i = m_group_to_items.find(group);
|
||||
if (i == m_group_to_items.end())
|
||||
return;
|
||||
return true;
|
||||
|
||||
const GroupItems &items = i->second;
|
||||
for (GroupItems::const_iterator j = items.begin();
|
||||
|
@ -627,6 +628,7 @@ void CNodeDefManager::getIds(const std::string &name,
|
|||
result.insert((*j).first);
|
||||
}
|
||||
//printf("getIds: %dus\n", t.stop());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue