How to get data?

Place to get help with not working mods / modding interface.
Post Reply
Thalassicus
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Apr 29, 2016 11:03 am
Contact:

How to get data?

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: How to get data?

Post 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 .
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: How to get data?

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Post Reply

Return to “Modding help”