I'm pretty much at a stand still because I'm not fluent in Lua; a beginner really. If anyone could figure out why these scripts aren't doing what they're meant to, it would really help. Also, if you'd like, I will give a credit on the mod once it's released. Just a note; you do need the Bees! mod because that's what this is meant for Objects with Lua download (pulled these from the actual mod directly, so no clue if this version will work right away when installed as is) Mutagen Extracter: It's supposed to take any item with the word "queen" or "drone" in it and automatically craft it (with varying chances) into Mutagen OR Genetic Waste in a specific slot Genetic Infuser: It's supposed to take recipes (defined in said Lua, not as recipe files, there would be FAR too many then) and output them in a specific slot
What IS the mod doing? Is it throwing an error? Not doing anything? Is anything showing up in the log?
Simply put:the Lua just isn't doing what it's supposed to. I assume everything is right, then, but the slots may be wrong? That's a random guess, though.
Let's focus on the mutagen extractor first. One error I see right off. This: Code: if string.find(contents[2].name, "queen") and contents[1].name == "glassvialempty" then if math.random(2) == 1 then self.item = "glassvialmutagen" itemchance = queenitem end if math.random(2) == 2 then self.item = "geneticwaste" itemchance = wasteitem end end should be changed to this: Code: if string.find(contents[2].name, "queen") and contents[1].name == "glassvialempty" then if math.random(2) == 1 then self.item = "glassvialmutagen" itemchance = queenitem else self.item = "geneticwaste" itemchance = wasteitem end end for both the queen block and the drone block. But I also suspect that you have a bigger problem. Rather than having a main() function, starbound calls an update() function that runs automatically every fraction of a second or so. I would try renaming the main() function to update(). declare it like this: Code: function update(dt)
Why would you get rid of the different chance at getting the second item? Just asking. Also, I changed the main() to update() to no luck, probably cuz I couldn't figure out the first thing Edit: I think I see what you pointed out now and I fixed it, still no luck
I got the impression that you were trying to make it a 50/50 chance of either getting the "glassvialmutagen" or "geneticwaste". With the code you posted you would be re-rolling the random number twice and potentially be getting multiple outputs. Ok, so let's try a few more things. Firstly, just to be safe, you should probably declare your "queenitem" , "droneitem" and "wasteitem" variables at the beginning of your Lua script to ensure that all of your functions can access them. So the first bit of your code should look like this: Code: local contents local queenitem local droneitem local wasteitem Next, there's a few things that I would change in your update() function to simplify things and to make it more clear what you are doing. Change this code: Code: function update(dt) contents = world.containerItems(entity.id()) if not contents[1] and not contents[2] then return end if contents[1] and contents[2] and not contents[3] then equipped() workingMutagen() end end to this: Code: function update(dt) contents = world.containerItems(entity.id()) if not contents[1] === nil and not contents[2] === nil and contents[3] === nil then equipped() workingMutagen() end end
This is the error I'm receiving now [13:54:06.128] Error: Failed to instantiate object for placement preview. mutagenextractor {} : (LuaException) Error code 3, [string "/objects/mutagenextractor/mutagenextractor.lu..."]:50: unexpected symbol near '=' Are you sure it's ===?
I *thought* that's how Lua does it... I might be thinking of Javascript though. Try it with '==' instead.
Apparently, Lua does it with = and ~=, I know, confusing coming from another language (C# here), but yeah. == == == ~= == != Apparently /confusion on