ID:176556
 
Im trying to make a code so that after you chop a tree down and its a stump you cannot chop it anymore...Here's what I've dont so far:

turf
obj
small_tree
icon = 'turfs.dmi'
icon_state = "small_tree"
var
stump = 0
verb
Cut()
if(locate(/obj/Bronze_axe) in usr)
set src in oview(1)
set category = "Wood Cutting"
var/cut = rand(1,4)
if(cut == 1)
usr << "You Miss The Tree!"
return
if(cut == 2)
usr << "You Miss The Tree!"
return
if(cut == 3)
usr << "You Miss The Tree!"
return
if(cut == 4)
usr << "You Get Some Lumber!"
src.icon_state = "small_tree_stump"
new/obj/Lumber(usr.loc)

else if(locate(/obj/Iron_axe) in usr)
set src in oview(1)
set category = "Wood Cutting"
var/cut = rand(1,4)
if(cut == 1)
usr << "You Miss The Tree!"
return
if(cut == 2)
usr << "You Miss The Tree!"
return
if(cut == 3)
usr << "You Miss The Tree!"
return
if(cut == 4)
usr << "You Get Some Lumber!"
src.icon_state = "small_tree_stump"
new/obj/Lumber(usr.loc)

else
usr << "You need an axe!"
return

THanks in advance!
-Crio
Oh so you just want to check the icon state to see if its a tree icon state or a stump icon state, something like this
if(src.icon_state == "small_tree")
//whatever it does when you have a full tree
else if (src.icon_state = "small_tree_stump")
//Tell them it has no wood left
It would also be a good idea to make the tree grow back after a while.
In response to Scoobert
Ok thanks, ill add a code to make it gro back later
I think its best to make some kind of spawner.
I am using this spawner:

obj
Tree_spawnpoint
spawntype = turf/obj/small_tree
obj
Spawner
name = "Spawner"
var
spawned = 0
max_spawned = 2
spawntype
New()
..()
spawn while (1)
src.check_spawn()
var
time = rand(100,300)
sleep(time)
proc
check_spawn()
if(spawned < max_spawned)
var/mob/M = new spawntype(src.loc)
M.owner = src
spawned ++
mob
var/atom/owner
Del()
if(owner && istype(owner, /obj/Spawner))
var/obj/Spawner/O = owner
O.spawned -= 1
..()

It sould spawn your tree 10 or 30 sec after chopping it down. Originally the code is for spawning rabits so i dunno if it works for your tree but you can use it as a example. I hope it can help you a bit.
BTW: You are using: var/cut = rand (1,4)
You can just use:

if(cut == 4)
usr << you got some wood
else
usr << you got no wood

and you can also just delete the var thing and use:
if(prob(25))
usr << you got some wood
else
usr << you got no wood

Greetz Fint
In response to Fint
if(cut == 4)
usr << you got some wood
else
usr << you got no wood

I was thinking the same thing, but i didnt want to say anything in fear the lummox is around **scanning the crouds of byondians**
In response to Scoobert
He want the verb to get away.
When you change the icon state the verb will still be there.
In response to Fint
Oh, i though he just wanted to check to see if there was wood there or now, he could have also replaced the object with a tree stump object when it was cut down, but your code is more complicated...urrr...simple...
[edit]
I reread his post, all he wanted was a code to check to see if they can chop the wood or not, he never said anything about removing the verb, my way was a lot simpler for what he wanted. So :P
In response to Scoobert
Awww, did he scare you last night?
In response to Jotdaniel
Yes and i am scarred for life now, i will never get a job, never finish a game, never be the same. lol, i cant even finish this post.
In response to Scoobert
he wrote:

Im trying to make a code so that after you chop a tree down and its a stump you cannot chop it anymore

So the verb has do be gone when the stump appears
In response to Fint
of, you cant chop it anymore, but that doesnt mean you cant try. ;P
src.verbs -= turf/obj/small_tree/verb/Cut()

...
...

turf/obj?
In response to Garthor
this is already answered (just to tell ya)
In response to Koolguy900095
Nobody gave that specific answer. =P
In response to Koolguy900095
Heres another idea. Make the tree stump a separate obj. then do this


obj/tree/verb/Cut()
//whatever the cut does
new/obj/tree/stump in src.loc
del(src)


then tree stump

obj/tree/stump
New()
spawn() Respawn()
proc/respawn()
spawn(600)//this waits one minute
new/obj/tree in src.loc
del(src)


How would this do to solve your problem?
In response to Garthor
Yeah i know, but i just edited scooberts and got my answer sorta...:-/ but im ok with it
In response to Koolguy900095
Look at mine...I felt that since everyone else tried to help you I might as well also.
In response to Jotdaniel
This is great thanks :D mma use this instead (sorry scoobert :P)
In response to Koolguy900095
Sometimes simple answers work best. Sorry to steal your moment of glory scoobert.
In response to Jotdaniel
I dont mind, i was going to segest that way, but i didnt want to confuse him at all, I had a few more ideas, this was my second though.
Page: 1 2