I was wondering if I can inflict a status effect when a player touches the block. I'm trying to recreate the asphalt block from terraria. So this would just have the player a get speed boost status when it touches the block. I'd just like to know how to do such a thing since I have almost no coding knowledge.
That is a very interesting concept, liquids can do this (like poison), but blocks? I don't think so. I would love to see this feature get added, though.
If that isn't possible to do, is it possible to have blocks emanate an area of effect status effect? That may be a viable alternative if so.
Is this really a 'block', though? It's probably an 'object'. I'm not sure though and I can't check right now. Objects require knowing a bit more about Starbound, especially since most of the ones you can interact with use a Lua script. Although, either way that would be a good place for topic creator to copy and make into whatever they want.
I've had something like this working for a while actually, though it uses block modifiers rather than actual blocks. That could very easily be re-rigged to use blocks though. In player.config.patch you want to insert the following line: Code: {"op":"add","path":"/statusControllerSettings/primaryScriptSources/-","value":"/scripts/isn_geldetection.lua"} Then, in your scripts folder, use code like this: Code: local oldUpdate = update function update(dt) oldUpdate(dt) local gelPos = { mcontroller.xPosition(), math.floor(mcontroller.yPosition()-3)} local modCheck = world.mod(gelPos,"foreground") if isn_getGelStatus(modCheck) == true then status.addEphemeralEffect(modCheck) end end function isn_getGelStatus(geltype) if geltype == "type1" then return true elseif geltype == "type2" then return true elseif geltype == "type3" then return true else return nil end end This basically bolts on an extra thing in the player character's processing script which checks the tile they're standing on, gets the JSON info for it, checks to see if it's a type that's supposed to be giving a status effect, then applies a status effect of the same ID name as the tile modifier.
For tiles instead of tile mods, I used this: Code: if mcontroller.onGround() then local position = mcontroller.position() local groundmat = world.material(vec2.add(position, {0.5,-3}), "foreground") local groundmat2 = world.material(vec2.add(position, {-0.5,-3}), "foreground") if groundmat == "ice" or groundmat2== "ice" then mcontroller.controlParameters({ normalGroundFriction = 0.2, groundForce = 10, slopeSlidingFactor = 0.5 }) end end This is very similar to "I Said No"s code. Main differences are that it only does additional logic if the players is already on the ground, and it checks tiles 0.5 to the left and 0.5 to the right, so that the effect occurs when moving onto and off of a tile. In this example, instead of adding an effect, I modify the player's friction to make ice slippery. * Actually for your example, you don't want to add a status effect, you just want to modify a controlModifier. So something like this. Code: mcontroller.controlModifiers({ runModifier = 0.5 jumpModifier = 0.5 }) Where 0.5 means a 50% speed increase.
You could do that, yeah. I just find it easier to control and more modular to do it via status effects.
Would honestly be easier if they implemented it so only surface blocks can run scripts. [ blocks with 1 side explosed to open area. You could probably do some interesting things
It's pretty much always just going to be easier to have the script run on players and monsters, I think.
I see. Well, it should still be run from a player script. However, they could (somewhat) easily add a status effect block to tiles, and have the player_primary script check for that by default. That way blocks could be edited or added through JSON patching. I just meant that running scripts on blocks is a higher computational load than running them on players.