Lack of control: Inaccessible methods

Place to get help with not working mods / modding interface.
Post Reply
ninjadindon
Burner Inserter
Burner Inserter
Posts: 6
Joined: Thu Apr 30, 2015 10:55 am
Contact:

Lack of control: Inaccessible methods

Post by ninjadindon »

Hi guys!
I'm a semi experienced lua programmer (mostly thanks to garrysmod) but I have some trouble with finding/understanding and adding already existing methods to another type,

For example, i wanted to code a Locomotive/wagon with the tank turret on it (and play it mad max style), unfotunately the easy "data["car"]["tank"].guns = {stuff}" obviously doesn't apply for trains and i can't figure out how to port it

I also expect to make RTS units and factories as lot of people suggest around here, defenders "time living" cannot be set to infinite and no selection/placement orders can be issued, so we'll have to do it ourselves
(modifying follow.player= true is going to be a mess in multiplayer)
At last "autoplace" and "result units" are a pain to make proper enemies

Rseding91
Factorio Staff
Factorio Staff
Posts: 13239
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Lack of control: Inaccessible methods

Post by Rseding91 »

Factorio is primarally written and run in C++. Entities have prototypes defining pre-existing C++ properties for the given entity/class in the C++ backend.

When you're referring to "data["car"]["tank"].guns = {stuff}" all that's doing is setting the tank instance of the car prototype guns properties to "{stuff}" - which already exists in the C++ backend. That means you can't take one entities (classes) properties and port them to a different entity - if the C++ class does not support them it will simply ignore them.

A good example of this is storage chests:

Basic storage chests have inventory sizes and health. You can't add rotation to the entity because it was not coded on the C++ side to support rotation or drawing the chest in any rotated way.
If you want to get ahold of me I'm almost always on Discord.

ninjadindon
Burner Inserter
Burner Inserter
Posts: 6
Joined: Thu Apr 30, 2015 10:55 am
Contact:

Re: Lack of control: Inaccessible methods

Post by ninjadindon »

I understand that, but i was hoping to know if we could access these c++ backends and create a new class in lua, but i think it's unpossible, I'll have to wait for the dev's to release a proper sdk (give them time, it's only beta..)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13239
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Lack of control: Inaccessible methods

Post by Rseding91 »

ninjadindon wrote:I understand that, but i was hoping to know if we could access these c++ backends and create a new class in lua, but i think it's unpossible, I'll have to wait for the dev's to release a proper sdk (give them time, it's only beta..)
I don't think you understand how modding with an API works. You're referring to modifying the game engine (essentially just writing your own version of the game) - that's now not a mod API works. A mod API (such as what Factorio has now and is not likely to ever change) provides hooks that you can use to modify specific parts of the existing game.
If you want to get ahold of me I'm almost always on Discord.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Lack of control: Inaccessible methods

Post by DaveMcW »

Some games (i.e. Civ5) open-source a few C++ API libraries. But that is hard to do without planning it from the start.

And compiling your mod for all the platforms Factorio supports would be a major pain.

ninjadindon
Burner Inserter
Burner Inserter
Posts: 6
Joined: Thu Apr 30, 2015 10:55 am
Contact:

Re: Lack of control: Inaccessible methods

Post by ninjadindon »

I don't explain my self properly, all in all, I just want some more things to be written in lua than in C++, therefore we could use more already written content for modding,
I'm currently working on an auto-aiming code to recreate car's guns, but it's sad not to be able to use this part of c++ code that is right in front of us

SirRichie
Fast Inserter
Fast Inserter
Posts: 244
Joined: Wed Feb 25, 2015 4:50 pm
Contact:

Re: Lack of control: Inaccessible methods

Post by SirRichie »

If you would like more things to be exposed in the modding API, then the recommended way to do this is by requesting this feature in the feature requests forum. This forum is about getting things to work within the given framework - which is probably the reason for the misunderstanding.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13239
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Lack of control: Inaccessible methods

Post by Rseding91 »

SirRichie wrote:If you would like more things to be exposed in the modding API, then the recommended way to do this is by requesting this feature in the feature requests forum. This forum is about getting things to work within the given framework - which is probably the reason for the misunderstanding.
Specifically the "Mod Interface Requests" section :)

(Note: I'm not the one who decides if an interface request gets added to the game so don't take what I say as more than opinion)
If you want to get ahold of me I'm almost always on Discord.

Koub
Global Moderator
Global Moderator
Posts: 7227
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Lack of control: Inaccessible methods

Post by Koub »

@OP ! Could you please expose clearly the API you want to see added in your first post ? I'll then mofe the whole topic in the adequate subforum (Modding API Request).
Koub - Please consider English is not my native language.

Post Reply

Return to “Modding help”