[Request]Access to entity properties from control code

Post Reply
User avatar
morphman
Burner Inserter
Burner Inserter
Posts: 7
Joined: Thu Jan 22, 2015 10:11 am
Contact:

[Request]Access to entity properties from control code

Post by morphman »

I would think it would make modding very much easier if there was a method to get a hold of the properties set in files like entity.lua from control code, like control.lua.

In the past few days I've been doing things where I wish I could just write a line like

Code: Select all

area = event.createdentity.getproperty(collision_box)
game.findentities{area}
The above is just an example, that would most probably look for entities on another layer that occupies the same space as what a player just placed down.

This would make it easier to write more advanced mods, when you can access things like how many animation steps an entity has, what fuel source it can use, what crafting type it uses or how hard it is to mine. This would be even more useful when we are able to make our own entity types in the future.

If there is a way to do this right now, I have not found it, but I still think a method for entities would make this a lot easier.

Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

Re: [Request]Access to entity properties from control code

Post by Rahjital »

I'm not sure if you know about this, but you can use the game.entityprototypes table to access properties of entity prototypes from control.lua.

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

Re: [Request]Access to entity properties from control code

Post by FreeER »

Rahjital wrote:I'm not sure if you know about this, but you can use the game.entityprototypes table to access properties of entity prototypes from control.lua.
Not everything is there though (try game.player.print(game.entityprototypes['stone-furnace'].help()) ), but yes it's good to know; if you have an entity reference you can also use entity.prototype to get the same thing :)
you can also require your data files into your control.lua, but other than that it's a desired feature that's simply not particularly high on the devs todo list for the game right now (there are some hacks you can do with encoding the values into the names of new prototypes that can be easily hidden like gui styles or recipes etc.)

User avatar
morphman
Burner Inserter
Burner Inserter
Posts: 7
Joined: Thu Jan 22, 2015 10:11 am
Contact:

Re: [Request]Access to entity properties from control code

Post by morphman »

Rahjital wrote:I'm not sure if you know about this, but you can use the game.entityprototypes table to access properties of entity prototypes from control.lua.
That is a good one, I did not know about it, but as FreeER said, it doesn't give you access to all properties.
FreeER wrote:it's a desired feature that's simply not particularly high on the devs todo list for the game right now
Oh, that's ok. I'm in this for the long haul, I don't mind if it takes a few months, or maybe even a year. Just thought I'd request it because I didn't see anybody else request it :)

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

Re: [Request]Access to entity properties from control code

Post by Rseding91 »

For anyone else coming across this, these will be in the 0.12 version:
Added several new options to LuaEntityPrototype: mineableproperties, itemstoplacethis, collisionbox, selectionbox, order, group, subgroup, healingpertick, emissionspertick, corpses, selectableingame, weight, resistances, fastreplaceablegroup, loot, repairspeedmodifier
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Implemented mod requests”