remote interface call questions

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Galacticruler
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Sat Apr 16, 2016 5:18 pm
Contact:

remote interface call questions

Post by Galacticruler »

I was wondering if it was possible to do a few things using the

Code: Select all

remote.add_interface(interface_name, table_of_functions)
code. Namely make it see if two mods are installed and only fire-up if both are there, and secondly adding an entire turret only in the event that one of them is installed.
PC is best.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: remote interface call questions

Post by Choumiko »

If both mods have a remote interface it will work:

Code: Select all

if remote.interfaces.modA and remote.interfaces.modB then
but since you're talking about adding a turret i think you want this to happen in data.lua? data.lua doesn't have remote available, so you'll have to check data.raw for items/turrets added by these 2 mods. And add them as optional depenencies, so they are loaded before your mod (or do it in data-updates.lua)

Code: Select all

if data.raw["item"]["item-from-modA"] and data.raw["item"]["item-from-modB"] then

User avatar
Galacticruler
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Sat Apr 16, 2016 5:18 pm
Contact:

Re: remote interface call questions

Post by Galacticruler »

Choumiko wrote:If both mods have a remote interface it will work:

Code: Select all

if remote.interfaces.modA and remote.interfaces.modB then
but since you're talking about adding a turret i think you want this to happen in data.lua? data.lua doesn't have remote available, so you'll have to check data.raw for items/turrets added by these 2 mods. And add them as optional depenencies, so they are loaded before your mod (or do it in data-updates.lua)

Code: Select all

if data.raw["item"]["item-from-modA"] and data.raw["item"]["item-from-modB"] then
after the then on the data.raw what would I do to create the entity, item, and recipe for the new turret? as well as add it to a technology?
PC is best.

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: remote interface call questions

Post by prg »

The usual data:extend() thing.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

User avatar
Galacticruler
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Sat Apr 16, 2016 5:18 pm
Contact:

Re: remote interface call questions

Post by Galacticruler »

Choumiko wrote:

Code: Select all

if data.raw["item"]["item-from-modA"] and data.raw["item"]["item-from-modB"] then
okay, so I'm probably doing this wrong, but it keeps saying the item I'm trying to index is a nil value.
currently it looks like this:

Code: Select all

if data.raw["charge-pack"]["advanced-weaponry"] then
PC is best.

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: remote interface call questions

Post by prg »

"charge-pack" is not a valid type defined by the game. You can't just put something you made up yourself there. What is the prototype you're trying to access?
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

User avatar
Galacticruler
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Sat Apr 16, 2016 5:18 pm
Contact:

Re: remote interface call questions

Post by Galacticruler »

prg wrote:"charge-pack" is not a valid type defined by the game. You can't just put something you made up yourself there. What is the prototype you're trying to access?
Oh, that makes a bit more sense, its not an item name it the item type?
PC is best.

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: remote interface call questions

Post by prg »

It's data.raw["type"]["name"], so e.g. data.raw["item"]["small-electric-pole"] for the item in your inventory or data.raw["electric-pole"]["small-electric-pole"] for the placed entity. Just use the type and name of the prototype.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Post Reply

Return to “Modding help”