Page 1 of 1

How to get data?

Posted: Wed Jan 10, 2018 7:06 am
by Thalassicus
How can I check the pollution required to create a biter?

This says the biter prototype doesn't have a "pollution_to_join_attack" key:

Code: Select all

local quantity = math.ceil(event.entity.prototype.pollution_to_join_attack / 1000)
This says "data" is nil:

Code: Select all

local quantity = math.ceil(data.raw["unit"][event.entity.prototype.name].pollution_to_join_attack / 1000)
I check the entity is an enemy unit elsewhere in the code.

Re: How to get data?

Posted: Wed Jan 10, 2018 1:55 pm
by eradicator
The first approach is correct, but looking at the documentation it seems that that property is simple not exposed. So try asking here: viewtopic.php?t=47087 .

Re: How to get data?

Posted: Thu Jan 11, 2018 9:36 am
by bobingabout
The reason why the second method doesn't work is because data is not exposed to runtime scripting, not even read only. you have to access variables through game (the event return is giving you a specific piece of data from the game table).

So your first method should be the correct way, but for whatever reason, the data isn't accessible. as eradicator said.