ID:165876
 
OK....Ive searched in the help on the game and in this forums and i couldn't find anything, SO, i am asking for the code to delete an object after it has been used and maybe a little message that shows after its been deleted? Thanks, And i love these forums too <3 helps me so much


Also, Could you help me making a spawn scroll type thing?This is my code right now:

Create(O as null|anything in typesof(/obj)){//THIS IS THE MESSED UP LINE
set desc="Create an Object, Mob, or Turf.";
if(!O)return;var/T = new O(usr.loc);
world.log<<"<font color=#607B8B>[usr] created a [T:name].";
view() << "With a scroll from [usr]'s hands, [usr] muttered out a word and a [T:name] appeared."}
</3>
What do you mean by used? Where's your code which uses it?
what do you mean by used?like this?:
obj/Whatever
verb/Use()
usr<<"You use [src]"
usr<<"[src] has been deleted because you used it!"
del(src)

You need to stop asking for code, though.Maybe it'd help you out to thoroughly read the DM guide.
In response to Dragon_fire6653
Dragon_fire6653 wrote:
what do you mean by used?like this?:
> obj/Whatever
> verb/Use()
> usr<<"You use [src]"
> del(src)
> usr<<"[src] has been deleted because you used it!"
>

You need to stop asking for code, though.Maybe it'd help you out to thoroughly read the DM guide.
Ill try but it doesnt explain it as well as people do,But thanks for the code i though del(src) would do it but i wasn't sure
In response to Dragon_fire6653
Dragon_fire6653 wrote:
what do you mean by used?like this?:
> obj/Whatever
> verb/Use()
> usr<<"You use [src]"
> del(src)
> usr<<"[src] has been deleted because you used it!"
>

You need to stop asking for code, though.Maybe it'd help you out to thoroughly read the DM guide.

That won't work properly. If the src is deleted, anything below the del(src) won't run. You should do usr << "[src] has been deleted..." before doing del(src).
In response to DeathAwaitsU
DeathAwaitsU wrote:
Dragon_fire6653 wrote:
what do you mean by used?like this?:
> > obj/Whatever
> > verb/Use()
> > usr<<"You use [src]"
> > del(src)
> > usr<<"[src] has been deleted because you used it!"
> >

You need to stop asking for code, though.Maybe it'd help you out to thoroughly read the DM guide.

That won't work properly. If the src is deleted, anything below the del(src) won't run. You should do usr << "[src] has been deleted..." before doing del(src).
Thanks, Anyways can you answer my other question (if your scratching your head i edited my post
In response to DeathAwaitsU
Ah.Ok, i'll fix that.
Animay3 wrote:
Also, Could you help me making a spawn scroll type thing?This is my code right now:

Create(O as null|anything in typesof(/obj)){
set desc="Create an Object, Mob, or Turf.";
if(!O)return;var/T = new O(usr.loc);
world.log<<"<font color=#607B8B>[usr] created a [T:name].";
view() << "With a scroll from [usr]'s hands, [usr] muttered out a word and a [T:name] appeared."}</font>

What exactly is the problem?

How do you do code tags too?

<DM>
*Code*
</DM>

*Edit*

Also, please end your HTML tags. It's extremely annoying when people don't.
In response to DeathAwaitsU
Thanks
In response to Animay3
If you have a <code>spawn()</code>ing proc or you want to continue past the deletion of the object - which should happen right away, to prevent spamming the verb - you can 'delete' the object below. Once the proc finishes, the object will be automatically deleted by the garbage collector.

obj/Whatever
verb/Use()
usr<<"You use [src]"
src.loc=null //'delete' the object by removing it from the inventory and map
usr<<"[src] has been deleted because you used it!" //this will now execute


Keep in mind to check for any references to the object. In my projects, I have a variable called <code>equipped</code> for every player which references to the selected item. In that case, I would also have to check for that and if so, set it to null or something else.