-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.15 entity type additions #22
Comments
Oh wow, that's awesome! I would appreciate those things a lot! That first option would help a lot regarding collected factory buildings (see my reply to your other comment). I guess there's a bunch of choices for implementation details with pros and cons though. I suppose you've thought about this already, but here's my thoughts about this:
Regarding the cross-surface teleporters: I'd personally prefer the second option, because it's easier and cleaner to Lua-code the first option using the second than vice versa. Here's how I would attempt to implement it: I'd add internal features to transport lines, fluid boxes and electric poles that allow you to add virtual connections from one transport line to another, or between two fluid boxes (allowing to select between balancing and one-way connections), or between electric poles (maybe also allowing to specify the transfer direction, if that even makes sense with electric networks). These features could then be exposed in the API, and the API methods could return a Lua object acting as a handle to the connection, providing a disconnect() method for the modder. |
At the moment I made an "item-with-tags" item type that includes the label functionality. It works similar to the item-with-entity-data type in that it can stack unless the tags differ then the game won't stack them.
There already exists LuaItemStack::set_stack which can take other LuaItemStacks and will clone them fully. I extended most places that take the simple variant to also take the LuaItemStack variant so in 0.15 you can do something like: entity.insert(entity2.get_inventory(...)[2]) and it will clone the item in slot 2 of entity 2 and insert it into entity 1. I also added the ability to read LuaItemStacks from transport lines with some conditions: changing the transport line will invalidate any references to the transport line items. That includes the belt moving the items or inserters taking/adding items so really it's only useable in the immediate instance you get the reference - but it still works.
This is a problem we have in the core game as well. There's currently no good way to say "when this entity is mined the result item should include X data about the entity" - everything we do now is what I'd call "hacks that work". I'll have to put more thought into this one.
The way it would have to work would be completely external from the entities so it wouldn't impact normal entity performance. Probably something stored in the force data that does the teleporting between given entities. I'll need to put more thought into this one as well before I do anything. |
I spent some time today and got a working system that should fix the mined-entity problem: eventing the result items from mining any given entity allowing anyone listening to the event to modify the items as they see fit and then when the event finishes the items are transferred into the player. |
Neat! Does this work for robots too? |
Yes |
I wanted to know what kind of entities would work best to facilitate what your mod does through the base game instead of having to do the majority of the logic through the Lua API.
Specifically I was thinking of adding something like these into 0.15:
There are a few ways I could do the last 3 items (they're pretty much all the same concept):
Both methods have an advantage but maybe there's something else that would work even better that you might have in mind.
The text was updated successfully, but these errors were encountered: