Hey! I just got started... and kinda searched for a way to make a custom item that is able to sample liquids and to create them in exchange for pixels. I'm a bit confused by all those different item types ".consumable" ".gun" ".miningtool" ".wiringtool" endings... but that probably is a part of the answer for my question. Can i define actions for right click/left click use of my item? Can i make my item use a custom lua script? My idea was to lower the player pixels based on the sampled liquid and kinda create some of it at the cursor. I also thought i knew were the liquids were.. but they seem to have moved with the last patch. Am i right that all those special file ending hint that those aren't as modular (yet) as objects are? Can i achieve the same result with an effect?
For the most part you need to decide what your idea resembles the most. .objects can be assigned .lua scripts, but swords can use left and right click. I'd say your item is most like the beamaxe or a combination of everyting, Look through those files and their .luas to determine what you can use from each and start from there.
Thanks for the reponse! I know that objects could do it... the only problem in my eyes is that those are stationary items and i rather want an item one carries around to use whereever s/he wants. I was more thinking about the paint gun then the matter manipulator. But you are right it isn't too far off. Sadly i can't see anything that tells me how i would be able to create water with them... I wish they would support a script attribute with a function for right click and one for left click. For me it looks like the wiring tool, paint gun, beamaxe/matter manipulator are overall hardcoded, with a good bunch of generic attributes like stack sizes, description and so on. I'm kinda missing the link between action and item... Right Click => Run this script Or something similar... =/
If you just want a gun that creates water or any other liquid, check out the water balloon gun for an example. \ Starbound \ assets \ items \ guns \ test \ waterballoongun.gun Items cannot have scripts assigned to them. The water balloon gun works by firing a waterballoon projectile. The waterballoon projectile spawns water OnReap - when it dies. Hits something. Code: { "projectileName" : "waterballoon", "physics" : "grenade", "frames" : "waterballoon.png", "level" : 3, "animationCycle" : 0.5, "frameNumber" : 2, "actionOnReap" : [ { "action" : "liquid", "liquidId" : 1, "quantity" : 1000 } ], "damageKind" : "default" }
Thats kinda what i was afraid of... can they at least have actions? Just a gun that creates water... isn't really what i wanted.
If you make it an object, you could use a lua to update it's position to the player's and have it place water on interaction. There's some problems with this, of course, but it seems to be more f what you want.
Objects can't float, can they? I mean, I've never actually tried, but I don't think I've ever seen an in-game object that was not attached to a tile. Even torches need a background to sit on. If you made an object that followed the player, part of it would have to touch the ground at all times. Jumping would break it, and so on. ...Actually, I've never seen an object move, either. I think you'd have to smash it and respawn it in the new location. After some very careful collision detections. Though, even if you could get an object to work, you'd have a tough time draining the player's pixels, aye? I guess you could kill the player on-use.
There must be a set position or something, like how the torches float when you're looking for a place to set them and how they go red if it's not a valid location. I'm just thinking out loud though, I'm not saying it's possible, just that it's worth trying
Hmmmmm. You're right, an object can be anywhere when it's being placed. I.. don't know how you'd replicate that outside of the player's control. I do think, though, that you can call scripts from an object in that phase - I believe init() is called repeatedly during that process, until the object is placed. I might be wrong about that, but I distinctly remember once during debugging an object I made that I included a world.logInfo call in init() and got like 20~30 lines of it before the object was placed. Then again, I don't think that object had a main(), so that might have been called rather than init() if it was present. Hmm, well, on second thought maybe those calls were rapid-fire after placement or something. No idea. Lemme go test it..
Then maybe in your init you could put a listener that waits for a key press or a mouse click that triggers an action rather than a placement. It would be pretty shaky though. Too bad there's no gun object or something in between.
Yupp, verified! init() is called repeatedly during object placement! Oh, and main() is ignored until the object is placed. You could probably do lots of silly stuff with this. An object that spawns pixels or something, but kills you when you try to place it... Little orbital spheres that shoot anything that gets near you? I'm not sure how you could intercept player key presses from an object. I feel there would have to be a tech involved, and I think using a tech rather defeats the purpose of making the object in the first place. I don't THINK you'd be able to use onInteraction with the object in the placement state, either.
You could use the constant call of init() as your own thread and poll for keypresses. You need another lua library to do it but it's possible. When that key's pressed you can call the main() or whatever function you want. And that's without a tech. Edit: I like your pixel spawning death trap idea
Oh. I ... guess I have trouble thinking outside of the scope of the game itself. Adding another lua library to actively check for keypresses yourself didn't even occur to me. Yes, if you can detect keypresses then there's a helluva lot you could do with this. You could assign different actions to different keypresses and have one floating object do any number of things. Mind ya, we'd still need to get the object into the placement phase without use of the player's beammamajig. I don't know how. Yea, I thought it could be funny. Especially if you package it secretly with another mod, so they don't expect to find it.
I tried playing around with placeObject a bit, but trying to place an object in the air just... doesn't do anything. I even tried to place an object which had an init that immediately smashed the object and spawned another in the same place. No luck. Nothing happens. Well, there are other things to play around with besides objects. Mobs and NPCs, for example, need not be spawned on a flat surface, and can have custom scripts attached to them rather than the normal A.I., so they can be freely manipulated.