Jump to content

Simplest way to make an usable item ?


Recommended Posts

I would like to make an usable item (like pan flute for example) that will start rain when used. So, i have the code for the rain part

 

	TheWorld:PushEvent("ms_forceprecipitation")

But i don't know what is the best way to make a simple usable item using this function.

Link to comment
Share on other sites

@Lumina I'd use the spellcaster component. Look at the yellowstaff (Starcaller's Staff) code in prefabs/staff.lua. You can give it the spell function that runs the code above.

However, you may want to consider also manipulating the moisture level before forcing it to rain, as if there is very little moisture (e.g. it just rained) the rain will stop almost immediately. Basically the way rain mechanics work is the world has a "water tank" that fills up, and when it gets full, it starts raining, which depletes it until it's empty. Various seasons set the full and empty thresholds to change how long it ends up raining. If you look at the code for the Telelocator staff, it adds moisture rather than directly forcing the rain. You could also do both, though.

TheWorld:PushEvent("ms_deltamoisture", TUNING.TELESTAFF_MOISTURE) --it's set to 500

 

Link to comment
Share on other sites

@rezecibOk, thanks, i'll take a look. If i want to stop rain, for another item for example, is it better to empty the moisture ? Like, by using :

TheWorld:PushEvent("ms_deltamoisture", -TUNING.TELESTAFF_MOISTURE)

?

Edited by Lumina
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...