Search found 21 matches

by oldskoolmatt
Thu May 05, 2022 10:34 pm
Forum: Modding interface requests
Topic: Add [layer_group] to [LuaTilePrototype]
Replies: 0
Views: 610

Add [layer_group] to [LuaTilePrototype]

Having the "layer_group" available for read in control stage would make way easier to determine what kind of tile is being looked at, is it water? ground? zero?
As for "layer" it returns an uint that could make things messy with modded tiles, so i think the "layer_group" would make a nice addition
by oldskoolmatt
Thu Jan 20, 2022 2:29 pm
Forum: Modding help
Topic: Read fluid in assembling machine input/output slot [control.lua][SOLVED]
Replies: 6
Views: 1852

Re: Read fluid in assembling machine input/output slot [control.lua]

This is not serviceable in this exact case (on_tick script), it will definitely crash at some point

Indeed, i did try early on but i did write it wrong, the correct syntax is as follow

local fluid = entity.fluidbox[1]
fluid_input = MY_FUNCTION(fluid.name, fluid.amount)


probably need to add ...
by oldskoolmatt
Thu Jan 20, 2022 1:33 pm
Forum: Modding help
Topic: Read fluid in assembling machine input/output slot [control.lua][SOLVED]
Replies: 6
Views: 1852

Re: Read fluid in assembling machine input/output slot [control.lua]


If you want the input/output fluid of an assembly machine I'm pretty sure you should use the fluid boxes and not the inventory.

https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.fluidbox


Indeed, i did try early on but i did write it wrong, the correct syntax is as follow

local ...
by oldskoolmatt
Thu Jan 20, 2022 1:30 pm
Forum: Modding help
Topic: Read fluid in assembling machine input/output slot [control.lua][SOLVED]
Replies: 6
Views: 1852

Re: Read fluid in assembling machine input/output slot [control.lua]


Do you really need the count? Otherwise, surface.find_entities_filtered will always return a table (which may be empty), so the wrapper around the for-loop shouldn't be necessary.


The script keeps scanning for entities (on_tick) and apparently COUNT is much more UPS friendly than FIND.
Runnning ...
by oldskoolmatt
Thu Jan 20, 2022 11:53 am
Forum: Modding help
Topic: Read fluid in assembling machine input/output slot [control.lua][SOLVED]
Replies: 6
Views: 1852

Read fluid in assembling machine input/output slot [control.lua][SOLVED]

Pretty straight forward, it was fairly easy to read contents for items using this bit of code, yet, i can't get it to work with fluids, what am i missing?

local count = player.surface.count_entities_filtered{area=DEFINED_AREA, type="assembling-machine"}
if count >= 1 then
for _, entity in pairs ...
by oldskoolmatt
Fri Oct 01, 2021 6:54 am
Forum: Modding help
Topic: Check if X armor is equipped [control.lua][SOLVED]
Replies: 3
Views: 1313

Re: Check if X armor is equipped [control.lua]

SOLUTION:
To check if the slot is empty or not, valid_for_read must be used

Code: Select all

local armor = player.get_inventory(defines.inventory.character_armor)[1]

if armor.valid_for_read and armor.name == "ARMOR_NAME" then
    -- EXECUTE CODE --
end
by oldskoolmatt
Fri Oct 01, 2021 2:27 am
Forum: Modding help
Topic: Check if X armor is equipped [control.lua][SOLVED]
Replies: 3
Views: 1313

Re: Check if X armor is equipped [control.lua]



playerarmor = player.get_inventory(defines.inventory.character_armor)[1]
if playerarmor and playerarmor.name == "Nameofsomearmor" then
dostuff
end



Jesus i did just the same without indexing [1]...

EDIT:
[1] refers to the slot iself so is never nil, [1].name returns the name of the ...
by oldskoolmatt
Fri Oct 01, 2021 1:55 am
Forum: Modding help
Topic: Check if X armor is equipped [control.lua][SOLVED]
Replies: 3
Views: 1313

Check if X armor is equipped [control.lua][SOLVED]

This is probably a dumb question, but, i can't find the right docs to address the armor slot in control stage.

This is what i'm trying to achieve

Code: Select all

if ARMOR_SLOT contains X_ARMOR then
   -- execute code--
by oldskoolmatt
Sun Sep 26, 2021 10:29 pm
Forum: Modding help
Topic: insert_fluid with fluid_box filter check for created entity [control.lua][SOLVED]
Replies: 6
Views: 1886

Re: insert_fluid with fluid_box filter check for created entity [control.lua]


if event.created_entity.type == "boiler" and event.created_entity.prototype.fluidbox_prototypes[1].filter.name == "water" then
event.created_entity.insert_fluid({name = "water", amount = 10})
end


WORKED LIKE A CHARM! Thanks for taking the time to help me solve this, i definitely learned ...
by oldskoolmatt
Sat Sep 25, 2021 2:12 am
Forum: Modding help
Topic: insert_fluid with fluid_box filter check for created entity [control.lua][SOLVED]
Replies: 6
Views: 1886

Re: insert_fluid with fluid_box filter check for created entity [control.lua]


https://lua-api.factorio.com/latest/LuaFluidBox.html
[...]
Are you trying it on boilers that are empty? From checking it myself, the fluidboxes are nil unless there is currently something in it.


That's exactly what i am trying to do, and yes, in the prototype the filter is defined as follow ...
by oldskoolmatt
Tue Sep 21, 2021 9:11 am
Forum: Modding help
Topic: insert_fluid with fluid_box filter check for created entity [control.lua][SOLVED]
Replies: 6
Views: 1886

Re: insert_fluid with fluid_box filter check for created entity [control.lua]


https://lua-api.factorio.com/latest/LuaFluidBox.html

I don't see a 'filter' property on there at all - it's get_filter[index] to read a filter at the given index. The return is a FluidBoxFilter where 'name' would be what you'd check is == 'water'


I'm actually having a hard time in figuring out ...
by oldskoolmatt
Tue Sep 21, 2021 12:25 am
Forum: Modding help
Topic: insert_fluid with fluid_box filter check for created entity [control.lua][SOLVED]
Replies: 6
Views: 1886

insert_fluid with fluid_box filter check for created entity [control.lua][SOLVED]

What i am trying to achieve is to check if the fluid_box.filter [data.lua] value is water, then insert 10 water

if event.created_entity.type == "boiler" and event.created_entity.fluid_box.filter == "water" then
event.created_entity.insert_fluid({name = "water", amount = 10})
end

script.on_event ...
by oldskoolmatt
Sat Mar 27, 2021 8:55 pm
Forum: Modding help
Topic: Store entity placeholder into blueprint [SOLVED]
Replies: 6
Views: 1850

Re: Store entity placeholder into blueprint


Then you did something wrong. What happens if you use a known good item like "rail" in placeable_by?


FOUND THE CULPRIT!!!

WANTED-ENTITY:

[...]
name = "WANTED-ENTITY"
flags = {"placeable-player", "placeable-off-grid"}
minable = {mining_time = 0.1, result = "ENTITY"} --drops the above "ITEM ...
by oldskoolmatt
Sat Mar 27, 2021 8:47 pm
Forum: Modding help
Topic: Store entity placeholder into blueprint [SOLVED]
Replies: 6
Views: 1850

Re: Store entity placeholder into blueprint


You are doing the same thing the game does for curved rails. Note how the WANTED_ENTITY, curved-rail, appears in the preview but not in the Components box.

But you don't really want this, do you? You want each entity to appear as its own component.


Thing is that the entity doesn't appear at ...
by oldskoolmatt
Sat Mar 27, 2021 8:26 pm
Forum: Modding help
Topic: Store entity placeholder into blueprint [SOLVED]
Replies: 6
Views: 1850

Re: Store entity placeholder into blueprint


https://wiki.factorio.com/Prototype/Entity#placeable_by is supposed to tell the game what to use in a blueprint for the given entity, so it might work for this. Haven't tried it myself though.

I was aware of this, but it doesn't seem to work, i tried any combination of "placeable_by" that's why ...
by oldskoolmatt
Sat Mar 27, 2021 5:58 pm
Forum: Modding help
Topic: Store entity placeholder into blueprint [SOLVED]
Replies: 6
Views: 1850

Store entity placeholder into blueprint [SOLVED]

Hello everyone, this blueprint thing is really bugging me out, i have an entity-placeholder which on creation gets destroyed by the script in control.lua, and is replaced with another entity, though the script works, the script-generated entity is not blueprintable.
Is there a way to have the ...
by oldskoolmatt
Sun Nov 15, 2020 4:11 pm
Forum: Modding help
Topic: Replace a specific recipe result
Replies: 10
Views: 2304

Re: [MODDING HELP] replace a specific recipe result



Now i'm stuck with the last of problems which is merely cosmetic, though the code works pretty well, the recipes are now ugly AF, they show both 2x iron plate and 4x iron plate rather than six altogether as i originally thought, any way of merging the output without going onto data-final-fixes ...
by oldskoolmatt
Sun Nov 15, 2020 3:56 pm
Forum: Modding help
Topic: Replace a specific recipe result
Replies: 10
Views: 2304

Re: [MODDING HELP] replace a specific recipe result




Should be fairly straightforward.

Not quite. This will work for a recipe that you have just defined. But don't take for granted that it will work when other mods have had a chance to mess with it!

The problem is, recipe.results is expected to be a table of ProductPrototype . recipe.results ...
by oldskoolmatt
Sun Nov 15, 2020 1:30 pm
Forum: Modding help
Topic: Replace a specific recipe result
Replies: 10
Views: 2304

Re: [MODDING HELP] replace a specific recipe result


Should be fairly straightforward.

local function process(recipe)
if recipe.result == "processing-unit" then
recipe.result = nil
recipe.results = {type="item", name="processing-unit", amount=recipe.result_count or 1}
recipe.result_count = nil
end
if recipe.results then
for i,result in ...
by oldskoolmatt
Sun Nov 15, 2020 11:08 am
Forum: Modding help
Topic: Replace a specific recipe result
Replies: 10
Views: 2304

Replace a specific recipe result

Hello lads, basically what i need to do is this:
type = "recipe",
name = "MY_RANDOM_RECIPE",
--------[...]--------
results =
{
{type = "item", name = "iron-plate", amount = 2},
{type = "item", name = "copper-plate", amount = 2},
{type = "item", name = "processing-unit", amount = 2}
},
main ...

Go to advanced search