Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
if _G.rawget(_G,"Insight") and _G.Insight~=nil then
Otherwise it will most likely crash if the mod runs withoug Insight enabled?!
I was writing an example in response to your question, and realized that there's no good way to do it at the moment since descriptors' Describe can return a bunch of nils or tables. I'll have to think about what can be done.
That being said, here's the example. This sort of thing is probably the best option at the moment.
(edited after your first response)
small question:
The code checks for "v.name", while your example code in the first post does not return a "name". Is this added automatically by your mod? Or should we always add a name to the returned values?
And maybe also add "alt_description" to your example.
It's another one of those issues in the example where modding the describe functions is difficult. If a descriptor returns a table without a name field, it gets automatically added in later. I specify the name ahead of time if the Describe returns multiple tables, since it's a requirement in that case. When there isn't a name, you just hope it's the first return.
In your case, since you're modifying edible, it already has the name so you should be okay.
I would change this:
If it's not a table, that means it's probably false, which means it likely hit an error during loading. You'd just be suppressing the error at that point, which is not recommended. Better to see why it's erroring.
I edited the code above to check for "false" and only set edible a new table if is no table yet. Unless you need no other "non-table" values, this should be fine now I guess.
descriptors is a metatable. When you index it to check for a descriptor, it first tries to load it if it hasn't been loaded yet. The descriptor should never be nil. It will always be a table or false.
The callback is called with the component and table of data returned from the descriptor's Describe.