Page 1 of 1

[Request]Access to entity properties from control code

Posted: Tue Feb 03, 2015 12:56 pm
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.

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

Posted: Tue Feb 03, 2015 9:39 pm
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.

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

Posted: Tue Feb 03, 2015 11:04 pm
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.)

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

Posted: Wed Feb 04, 2015 7:43 pm
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 :)

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

Posted: Sun Apr 19, 2015 7:49 am
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