Basically, I have a slight understanding of how to use Lua, but only the most basic. I've worked with Java, C#, and Visual Basic a bit, so I can figure much of it out from context. That being said, I have no idea of how to go about creating a part of a mod I'm building. I intend to have a set of liquid pumps in this mod where they could be placed in a liquid, be turned on and off via wiring, and have small 3 slot inventories. Upon being activating one, it would drain any liquid touching it into its inventory, much like when you collect liquid with your beam tool. Now, here's the lame part. I haven't the slightest idea of how to build that script. So, I was hoping that someone might be willing to build me a template. Once I have the template, I should be able to modify it myself to have the separate types. I just need it to have a speed variable I can change. If someone could help me, or at least direct me to a mod that has the code so I can look at it and figure it out, I would be eternally grateful.
That's quite the difficult code. You would have the object to be a container. Then, theres the node part, see below. You would also need to detect the liquid, or rather how far the liquid on the block placed goes. If that value is true, it would need to pump the liquid, so you would need to detect which KIND of liquid it is. You'd then push that to the free container slot of the item. (As in, remove it from the spot and add an instance of the liquidId to the container, not transfering the liquid.) Just a note here, I'm not sure how advanced of a coder you are, but that's FAR from basic stuff. /objects/wired/liquidsensor /objects/wired/shieldgenerator /objects/scripts/autofill These can help you getting started. I can't recall an instance of container specific lua atm, but just check this documentation part. This should be everything you need to get started. There are some people that worked on something like this, I'm not too sure who it was tho. Maybe you'll get a response here, but for lua questions like THIS I really recommend joining the irc at ##starbound-modding while you develop the mod. You will most certainly come up with tons of questions, they can be answered there more easily then in the forum. I wish you good luck tho!
Thanks! I figured that it probably wouldn't be too easy, but looking at those scripts it's quite a lot harder than I thought. This may take awhile and be rather difficult. But hey, at least that means that no one else is likely to do it!
If someone will be looking for that in the future: Code: function init() entity.setInteractive(true) t = { "liquidwater", "liquidlava", "liquidpoison", "liquidalienjuice", "liquidoil", "liquidhealing", "liquidmilk", "liquidlava", "liquidcoffee", "liquidwater", "liquidfuel", "swampwater", "liquidoil"} isActive = nil end function onNodeConnectionChange(args) if entity.isInboundNodeConnected(0) then onInboundNodeChange({ level = entity.getInboundNodeLevel(0) }) end end function onInboundNodeChange(args) if args.level then isActive = true else isActive = false end end function update(dt) local liquid = t local sample = world.liquidAt(entity.position()) if entity.isInboundNodeConnected(0) and isActive and sample[1] == 1 then world.containerAddItems(entity.id(), liquid[1]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 2 then world.containerAddItems(entity.id(), liquid[2]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 3 then world.containerAddItems(entity.id(), liquid[3]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 4 then world.containerAddItems(entity.id(), liquid[4]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 5 then world.containerAddItems(entity.id(), liquid[5]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 6 then world.containerAddItems(entity.id(), liquid[6]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 7 then world.containerAddItems(entity.id(), liquid[7]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 8 then world.containerAddItems(entity.id(), liquid[8]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 9 then world.containerAddItems(entity.id(), liquid[9]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 10 then world.containerAddItems(entity.id(), liquid[10]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 11 then world.containerAddItems(entity.id(), liquid[11]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 12 then world.containerAddItems(entity.id(), liquid[12]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == 13 then world.containerAddItems(entity.id(), liquid[13]) world.destroyLiquid(entity.position()) elseif entity.isInboundNodeConnected(0) and isActive and sample[1] == nil then world.containerAddItems(entity.id(), "perfectlygenericitem") world.destroyLiquid(entity.position()) end end
Holy crap, Kayuko. I am simultaneously extremely impressed and confused. Would you care if I copied this script and gave it a sprite and item that goes with it so it is usable as a mod? I'll give credit to you. I think even if I tried to take all the credit myself, no one would believe it was actually me.
Sure, keep in mind to declare the object as container tho, and edit the chest config to a 3-slot one if you only want 3 slots.
You can try ripping some code from this and updating it, this is a neat one that really needs an update http://community.playstarbound.com/resources/starfoundry.1302/ But it has liquid pumps and storage tanks (that you can't open like a chest, you have to pump/drain it out)
That massive switch statement can be collapsed a bit, into Code: if entity.isInboundNodeConnected(0) and isActive and sample and sample[1] and liquid[sample[1]] ~= nil then world.containerAddItems(entity.id(), liquid[sample[1]]) world.destroyLiquid(entity.position()) end Also note that I think world.liquidAt returns nil when it finds no liquid, so calling sample[1] there would crash the script.