What can be done with modding?

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
robhol
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Sun May 11, 2014 9:57 pm
Contact:

What can be done with modding?

Post by robhol » Tue May 13, 2014 9:48 am

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?
窮屈そうに身を屈めても今じゃ誰もがそうしてる 天井の無いECHO ROOMに誰かが僕を放り込む
君のSPEEDでもって 同じPHRASEを弾いて 冷たい時に寄り添って

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: What can be done with modding?

Post by ficolas » Tue May 13, 2014 4:07 pm

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.

robhol
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Sun May 11, 2014 9:57 pm
Contact:

Re: What can be done with modding?

Post by robhol » Tue May 13, 2014 4:23 pm

By "flow", I mean switching lanes and so on.
I don't suppose there's any documentation?
窮屈そうに身を屈めても今じゃ誰もがそうしてる 天井の無いECHO ROOMに誰かが僕を放り込む
君のSPEEDでもって 同じPHRASEを弾いて 冷たい時に寄り添って

Schmendrick
Fast Inserter
Fast Inserter
Posts: 221
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: What can be done with modding?

Post by Schmendrick » Tue May 13, 2014 10:06 pm

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
Like my mods? Check out another! Or see older, pre-0.12.0 mods.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: What can be done with modding?

Post by FreeER » Wed May 14, 2014 5:22 pm

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...
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

User avatar
Drury
Filter Inserter
Filter Inserter
Posts: 678
Joined: Tue Mar 25, 2014 8:01 pm
Contact:

Re: What can be done with modding?

Post by Drury » Sun May 18, 2014 1:57 pm

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?
Image

User avatar
ludsoe
Fast Inserter
Fast Inserter
Posts: 243
Joined: Tue Feb 11, 2014 8:16 am
Contact:

Re: What can be done with modding?

Post by ludsoe » Sun May 18, 2014 2:12 pm

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?

User avatar
Drury
Filter Inserter
Filter Inserter
Posts: 678
Joined: Tue Mar 25, 2014 8:01 pm
Contact:

Re: What can be done with modding?

Post by Drury » Sun May 18, 2014 2:22 pm

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

GotLag
Filter Inserter
Filter Inserter
Posts: 474
Joined: Sat May 03, 2014 3:32 pm
Contact:

Re: What can be done with modding?

Post by GotLag » Mon May 26, 2014 4:27 pm

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.

Sparkerish
Inserter
Inserter
Posts: 24
Joined: Sat Apr 12, 2014 6:35 pm
Contact:

Re: What can be done with modding?

Post by Sparkerish » Tue May 27, 2014 10:46 am

@ 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!
Have FUN!
WARNING Factorio

mohreb
Inserter
Inserter
Posts: 25
Joined: Mon Apr 21, 2014 8:57 am
Contact:

Re: What can be done with modding?

Post by mohreb » Fri Mar 18, 2016 8:44 pm

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?

Post Reply

Return to “Modding discussion”

Who is online

Users browsing this forum: Werbad and 2 guests