- // This usually is the CONTENT_ value
- virtual u16 typeId() const = 0;
- virtual NodeMetadata* clone() = 0;
- virtual void serializeBody(std::ostream &os) = 0;
- virtual std::string infoText() {return "";}
- virtual Inventory* getInventory() {return NULL;}
- // This is called always after the inventory is modified, before
- // the changes are copied elsewhere
- virtual void inventoryModified(){}
- // A step in time. Returns true if metadata changed.
- virtual bool step(float dtime) {return false;}
- virtual bool nodeRemovalDisabled(){return false;}
- // Used to make custom inventory menus.
- // See format in guiInventoryMenu.cpp.
- virtual std::string getInventoryDrawSpecString(){return "";}
-
-protected:
- static void registerType(u16 id, Factory f);
+ void clear();
+
+ // Generic key/value store
+ std::string getString(const std::string &name) const
+ {
+ std::map<std::string, std::string>::const_iterator i;
+ i = m_stringvars.find(name);
+ if(i == m_stringvars.end())
+ return "";
+ return resolveString(i->second);
+ }
+ void setString(const std::string &name, const std::string &var)
+ {
+ if(var.empty())
+ m_stringvars.erase(name);
+ else
+ m_stringvars[name] = var;
+ }
+ // support variable names in values
+ std::string resolveString(const std::string &str) const
+ {
+ if(str.substr(0,2) == "${" && str[str.length()-1] == '}')
+ return resolveString(getString(str.substr(2,str.length()-3)));
+ return str;
+ }
+ std::map<std::string, std::string> getStrings() const
+ {
+ return m_stringvars;
+ }
+
+ // The inventory
+ Inventory* getInventory()
+ {
+ return m_inventory;
+ }
+