ID:176757
 
How would i make it so after spawning(300) or whatever that if your on the water you teleport to where you casted the spell? My code is:

Walk_on_water()
set category = "Spells"
if(usr.mp-25 < 0)
usr <<"\green You dont have enough Mana!"
else
usr <<"\green You succefully cast the spell, now you can walk on water"
walk_on_water = 1
spawn(300)
walk_on_water = 0
usr <<"\green The spell ran out!"
Koolguy900095 wrote:
How would i make it so after spawning(300) or whatever that if your on the water you teleport to where you casted the spell? My code is:
 Walk_on_water()
set category = "Spells"
if(usr.mp-25 < 0)
usr <<"<b>\green You dont have enough Mana!</b>"
else
usr <<"<b>\green You succefully cast the spell, now you can walk on water</b>"
walk_on_water = 1
spawn(300)
walk_on_water = 0
usr <<"<b>\green The spell ran out!"

Two little things you forgot here: You forgot to close the <B> tag for when the spell ran out, and you forgot to put your code in <DM> tags for the forum post--that always helps.

Of course, those don't relate to what you're asking.
To teleport back, you need to save your old location:
Walk_on_water()
set category = "Spells"
if(usr.mp < 25)
usr <<"<b>\green You dont have enough Mana!</b>"
else
usr.mp -= 25
usr <<"<b>\green You succefully cast the spell, now you can walk on water</b>"
usr.walk_on_water = 1
var/turf/spellstart = loc
spawn(300)
if(istype(usr.loc,/turf/water))
usr.loc = spellstart
usr.walk_on_water = 0
usr <<"<b>\green The spell ran out!</b>"

One thing I might suggest, instead of putting in "<B>\green ...</B>" all the time, is to make a short proc to output text in a spell format for you:
proc/SpellText(msg)
return "<SPAN CLASS=spell>[msg]</SPAN>"
And you can set up a client script file (.dms) that has a style defined for you:
// in style.dms or whatever you call it:

.spell {font-weight: bold; color: #00c000}
Having styles set up like that can be really handy.

Lummox JR