Page 1 of 1

What can be done with modding?

Posted: Tue May 13, 2014 9:48 am
by robhol
So, I'm a little bit confused, and I figured I'd try to find out what, exactly, can and can't be done using Lua.

I've been poking around in the base 'mod' , but it all seems more like simple data definitions than any real logic.

Are there any rules of thumb, etc. in the absence of an actual reference? For example:

Can you draw your own GUIs? Direct shapes, text etc.?
Can you change the flow of items on belts and so on?

Re: What can be done with modding?

Posted: Tue May 13, 2014 4:07 pm
by ficolas
Lots of things can be done with lua script, lots, and if a interface is needed for what you want to do, there may be a "workarround" for it.
A example is the turret car in my mod, turret cars cant really be done, but what I did is create a turret that doesnt collide and a car, and with the lua script every tick the turret is moved on top of the car.
Is a quite messy way, but it works.

I guess that if you have only seen base mod, you have only seen prototype definitions, because the base mod doesnt use lua script, devs can use c++ :-)

To learn more about what can be done with lua script (not only definitions) you should look other mods code, im not going to recommend my mod this time, because the code is longer, I recomend looking at FreEr's mods, because they are smaller mods that do more specific stuff, in my code you may get lost because I jump from a thing to a different one.

Now the specific questions:
Yes, you can draw custom guis, and im not sure what you mean by changing the flow of items on a belt, the speed can be changed in the definitions, they can also be made bigger in the definition and you can turn them with the lua script.

Re: What can be done with modding?

Posted: Tue May 13, 2014 4:23 pm
by robhol
By "flow", I mean switching lanes and so on.
I don't suppose there's any documentation?

Re: What can be done with modding?

Posted: Tue May 13, 2014 10:06 pm
by Schmendrick
I'm still relatively new, but this is my answer to what I think you're asking. Someone else please chime in (especially if I'm dead wrong about anything :p ).

There are basically two areas for modding. The first is essentially object (item, entity, tech, etc) definition and occurs when Factorio loads. This is relatively static, and most mods I've seen have pretty passive lua for this section (declarations of new data). It involves modifying existing game elements or adding new ones in relatively simple, number-tweaking sorts of ways. It's where one would add new stuff: new resources, new recipes, new techs, new machines. The second area is control.lua (and any dependencies) which is run during actual gameplay, and typically contains any "real" code (branching, etc) to define the behavior of objects or game events (such as if a machine does something in a fundamentally different way than existing machines. Wind power, underground mining, etc.). In either case, both can be kind of restricted in terms of what certain types of items are hardcoded to handle, but if you look at people's mods you will see some interesting workarounds; regarding that, it's sort of trial and error at this point. (But since the game is still alpha and lots of things are still subject to change, this is kind of to be expected.)

As far as documentation, the modding wiki article and those linked in it are good places to start (and, unfortunately, end, at least as far as I know).

https://forums.factorio.com/wiki/inde ... g_Tutorial

Re: What can be done with modding?

Posted: Wed May 14, 2014 5:22 pm
by FreeER
Both answers before me are pretty great, and not just because they mentioned my stuff :lol:
The base files mostly contain the 'declarations' of items that will be available to the players (but not the actual implementations, since that's done in C++). If the devs needed an entity to do something they've done it in C++ (thus there is very very little lua code done by the base mod).

The 'real' modding is done with control.lua and to find out what is directly possible you'll need to have a look at the wiki (as already suggested), specifically at the Lua/Events which define (essentially) when you can take action and Lua/Objects which (essentially) define what actions you can take. For anything complex you are pretty much going to be employing workarounds because the C++ code is quite specific and the lua is pretty much bound to it right now (of course we all hope that it becomes more flexible over time but it is an alpha and the devs are working more on the game than the modding right now).

As previously suggested look at what other modders have done, and how they've managed it, to get more ideas of what is actually possible and the workarounds used to make it possible.
For any specific questions feel free to ask of course :D
robhol wrote:By "flow", I mean switching lanes and so on.
I don't suppose there's any documentation?
First, if you haven't noticed already... the wiki IS the doc (for good or bad...), as for switching lanes, as of right now you could attempt to use lua to find the item entities on the belts (game.findentitiesfiltered{type="item-entity", area=...}) and then teleport them to where they 'should' be...but lua is significantly slower than C++ and it probably wouldn't work efficiently for such cases...

Re: What can be done with modding?

Posted: Sun May 18, 2014 1:57 pm
by Drury
I'd like to abuse this thread to ask one simple question:

Is it possible to make a secondary power network via modding and why not?

Re: What can be done with modding?

Posted: Sun May 18, 2014 2:12 pm
by ludsoe
Drury wrote:I'd like to abuse this thread to ask one simple question:

Is it possible to make a secondary power network via modding and why not?
Please explain what you mean by secondary power network?

Re: What can be done with modding?

Posted: Sun May 18, 2014 2:22 pm
by Drury
Sure.

A bit similar to circuit network. It occupies electricity poles but it's not a part of the primary network. It's separate, it has it's own generators and it's own consumers.

Re: What can be done with modding?

Posted: Mon May 26, 2014 4:27 pm
by GotLag
robhol wrote:Can you change the flow of items on belts and so on?
I've managed to block parts of belts by changing collision boxes in prototype definitions (https://forums.factorio.com/forum/vie ... =14&t=3657) but I've not found a way to change lane within a single entity.

Re: What can be done with modding?

Posted: Tue May 27, 2014 10:46 am
by Sparkerish
@ Drury
By this are you wanting a second (Isolated) power network or a network-within-a-network?
For the first power grids must NOT be connected (2 grids that have no wires between them are 2 different networks).
For the 2nd DyTech has implemented this (primary, secondary, & tertiary) Power produced in order all primary supplemented by secondary supplemented by tertiary. currently only the tertiary accumulators work, hopefully fixed soon.
If you were wanting dual overlapping power grids (example: Solar A feeds only rader A while Steam plant B feeds only turret B using same power poles) ...Not available, doubt it can be done using same poles (but poles can be placed side by side, remove wires from one line, then manually connect 2nd line poles so they don't "touch" 1st line - or space poles far enough apart) this is useful for programing smart networks but could be applied to power creating parallel grids.

IRL a "Power Grid" is either on or off. Power is there or not. Sections can be shut down during low power (IRL=Rolling brown/blackouts, Factorio=Accumulator bridging 2 grids).
:shock: OH yeah I was typing a reply...got lost reading about accumulators etc. :lol:

Hope this helped... Still not quite sure what you are/were asking about :? But hopefully you do!

Re: What can be done with modding?

Posted: Fri Mar 18, 2016 8:44 pm
by mohreb
Hi, i would liket to ask also if something can be done or not.
Can you define objects/items "on the fly" via mods? (a bit like blueprints, where you the object is a composition of objects, and that is also viewed on the picture?