ID:175024
 
I cant figure out how to make a verb named "cut" or maybe "break" where the player or any other mob destroys the dense obj in front of them. I just started byond like a week ago so.........
Here ya go.


<code> turf/Tree icon='Turfs.dmi';icon_state="tree";density=1;var/dense1=1 verb/Cut() if(dense1 == 1) dense1 = 0 density = 0 else ..() </code>


Time to explain.

<code>turf/Tree</code> -- This defines a path for a turf called "Tree", all you do when you have defined this is place it on the map.


<code>icon='Turfs.dmi';icon_state="tree";density=1;var/ dense1=1</code>

icon='Turfs.dmi' -- Here you select the image file you are going to use for the "Tree".

icon_state="tree" -- If there is more than one icon in the image file named "Turfs.dmi" then you will have to use this to select your named image.

density=1 -- This is so that your "Tree" will not let anything go through it, it makes it a solid object.

var/dense1=1 -- This is a variable I set so that your "Tree" can be checked for its density. 1 = TRUE and 0 = FALSE.


<code>verb/Cut()</code> -- Here we set a verb so you can cut dow the tree in the way, or at least make it a passable object.


<code>if(dense1 == 1)</code> -- Here we check our variable. If it is TRUE, which it will be, then it will follow on to set the density to 0 to make it passable and the dense1 variable will be set to FALSE.


<code>dense1 = 0</code> -- Here we set the variable to FALSE.


<code>density = 0</code> -- Here we now set the tree's density variable to FALSE so we can pass through it.


<code>else ..()</code> -- If the dense1 variable is already FALSE, then we all the procedure to do as it would normally do, and pass. Although here, we leave the tree as passable.


Sorry if the explanation is not perfect, but, I am not all that good at explaining things...

--Lee
In response to Mellifluous
umm this isnt working (i dont mean that in an ungratefull way)

Nevermind Im probably just stupid but the cut verb is not coming up under commands when I am in front of the tree. Ill keep playing around with it.
In response to NYIsles788
NYIsles788 wrote:
umm this isnt working (i dont mean that in an ungratefull way)

Nevermind Im probably just stupid but the cut verb is not coming up under commands when I am in front of the tree. Ill keep playing around with it.

Ooops, I made a mistake, sorry.

I shall fix it up for you now :)


Here is fix:

<code> turf/Tree icon='Turfs.dmi';icon_state="tree";density=1;var/dense1=1 for(mob/M in oview(1)) M.verbs += turf/Tree/verb/Cut() verb/Cut() if(dense1 == 1) dense1 = 0 density = 0 else ..()</code>

--Lee
In response to Mellifluous
With copy and pasting I get(one error) inconsistant indentation only on the M.verbs += turf/Tree/verb/Cut() line. I tried moving that line.
If it doesn't matter what type of object is being destroyed, you could do something like this:

<code>mob/verb/Cut() for(var/obj/O in get_step(src, dir)) if(O.density) del(O)</code>

That will delete any dense /obj types existing one square away in the direction the player is facing.