Page 1 of 1
AP request: LuaEnity::Mine(entity)
Posted: Fri Oct 28, 2016 12:13 am
by Mylon
Let us call the function to act as if one entity just mined another, including the transfer of inventory, transfer of mining products, etc.
Re: AP request: LuaEnity::Mine(entity)
Posted: Fri Oct 28, 2016 2:58 am
by aubergine18
Re: AP request: LuaEnity::Mine(entity)
Posted: Sun Oct 30, 2016 9:48 pm
by Mylon
The API to simulate mining exists, but it's a lot more effort than it's worth. I've already partially recreated it but I've run into some bugs with my implementation.
items on ground are not mined. So mined products, pickup products, and inventory all must be handled separately. Sounds have to be called manually.
Trees, when destroy()'d, don't leave stumps.
![Sad :(](./images/smilies/icon_e_sad.gif)
Re: AP request: LuaEnity::Mine(entity)
Posted: Mon Oct 31, 2016 2:51 am
by Nexela
Mylon wrote:
Trees, when destroy()'d, don't leave stumps.
![Sad :(](./images/smilies/icon_e_sad.gif)
Have you tried die()? if that doesn't work then do what the code probably does "destroy the item at x,y, place stump at x,y)
Re: AP request: LuaEnity::Mine(entity)
Posted: Mon Oct 31, 2016 4:40 am
by aubergine18
I must admit, I also had to abandon one of my mods because item-on-ground can't be mined. I thought about having it place as entity, but then it's not possible to pick up with F key. I was hoping to create a situation where picking up would retrieve the existing item, but mining would yield a different item.
Could you elaborate a bit more on what you are trying to achieve?
Re: AP request: LuaEnity::Mine(entity)
Posted: Mon Oct 31, 2016 5:48 pm
by Mylon
aubergine18 wrote:
Could you elaborate a bit more on what you are trying to achieve?
This:
https://mods.factorio.com/mods/Mylon/Bluebuild
Auto-demo would be trivial if I could do player.mine(target). Instead I have to get the mined_item, the item inventory, if type = "item-entity" I need to get the item too. Then damage the tool if hardness > 0 (like for trees), play sound, spawn a tree stump, etc.
Also, it seems player.insert(target.get_inventory()) doesn't work if the player's inventory is full, causing items to be deleted! Again, player.mine(target) checks this for me.