ID:141678
 
Code:
        proc/plant()
spawn(200)
if(greenhouse.tempature == 33)
if(greenhouse.shady == 2)
if(water == 3)
var/obj/Herbology_Objects/Mimbulus/M = new/obj/Herbology_Objects/Mimbulus
M.loc = src.loc
view()<<"The Mimbulus Cactus blooms"
del src
else
view()<<"The plant dries up from lack of water"
del src
else
view()<<"The plant dies because the tempature was set wrong"
del src


Problem description:
Ok, so.. I don't know what the problem is. It returns no errors, but it just won't actually grow. I'm fairly sure it's this proc because, even if I do something wrong it won't give me the right message. (Such as make the temperature the wrong number.) Oh and please ignore the wacky spelling of temperature there..
1. Do any of those messages come up? Put messages to tell you if each if() condition failed. If you don't get any messages, the proc didn't get called.
2. You are using a dirty new.
var/obj/Monkey/M=new(loc) //Look up the new proc in the DM Reference(F1 in Dream Maker).
//is the same as...
var/obj/Monkey/M=new/obj/Monkey
M.loc=loc
//You can tell which one is a lot cleaner.
In response to Kaiochao
I've done everything wrong, at the different places. It's never given me the wrong temperature message or the lack of water message.
In response to SHSPlyr03
Is your greenhouse shady?
In response to Kaiochao
Mhmm. I have everything preset, and just to make sure, when I get there, I put them all to the right thing again. Idk what to do.
In response to SHSPlyr03
Are you actually calling plant()? Maybe something is wrong in the code calling it.
In response to Kaiochao
    plant1
icon = 'Plants.dmi'
icon_state = "cactus2"
var/area/greenhouse/greenhouse
var/water = 0
New()
var/area/greenhouse/G
for(G in view( 0))
if(istype( G ))
greenhouse = G
plant()
proc/plant()
spawn(200)
if(greenhouse.tempature == 33)
if(greenhouse.shady == 2)
if(water == 3)
var/obj/Herbology_Objects/Mimbulus/M = new/obj/Herbology_Objects/Mimbulus
M.loc = src.loc
view()<<"The Mimbulus Cactus blooms"
del src
else
view()<<"The plant dries up from lack of water"
del src
else
view()<<"The plant dies because the tempature was set wrong"
del src
verb
Water()
set src in oview(1)
water +=1
view()<<"[usr] waters the [src]"

There's everything for plant1. I didn't write this, by the way. Just trying to fix it
In response to SHSPlyr03
Stuff the code with debug messages. All possible routes.
Debug messages will show you how far the code got before it stopped.
In response to Kaiochao
Err.. Stuff it with Debugs.. ?_?
In response to SHSPlyr03
//Example of debug messaging
var/truevar=1
var/falsevar
mob/Login()
world<<"[src] logged in" //Common debug message, comes up when the mob successfully logs in. Usually unnecessary for debugging.
if(truevar)
world<<"truevar passed" //truevar was true :)
else
world<<"uh oh!" //truevar was false!
if(falsevar)
world<<"uh oh!" //falsevar was true!
else
world<<"falsevar passed" //falsevar was false :)

This outputs:

[src] logged in
truevar passed
falsevar passed


Any "uh ohs" show that something went wrong, since truevar should be true and falsevar should be false.
In response to Kaiochao
    plant1
icon = 'Plants.dmi'
icon_state = "cactus2"
var/area/greenhouse/greenhouse
var/water = 0
New()
var/area/greenhouse/G
for(G in view( 0))
if(istype( G ))
greenhouse = G
grow()
proc/grow()
if(truevar)
world<<"truevar passed"
else
world<<"uh oh!"
if(falsevar)
world<<"uh oh!"
else
world<<"falsevar passed"
spawn(200)
if(greenhouse.tempature == 33)
if(truevar)
world<<"truevar passed"
else
world<<"uh oh!"
if(falsevar)
world<<"uh oh!"
else
world<<"falsevar passed"
if(greenhouse.shady == 2)

if(water == 3)
var/obj/Herbology_Objects/Mimbulus/M = new/obj/Herbology_Objects/Mimbulus
M.loc = src.loc
view()<<"The Mimbulus Cactus blooms"
del src
if(water <= 3)
if(truevar)
world<<"truevar passed" //truevar was true :)
else
world<<"uh oh!" //truevar was false!
if(falsevar)
world<<"uh oh!" //falsevar was true!
else
world<<"falsevar passed" //falsevar was false :)
view()<<"The plant dries up from lack of water."
del src
return
if(water >= 3)
if(truevar)
world<<"truevar passed" //truevar was true :)
else
world<<"uh oh!" //truevar was false!
if(falsevar)
world<<"uh oh!" //falsevar was true!
else
world<<"falsevar passed" //falsevar was false :)
view()<<"The plant dies from being over watered."
del src
return
if(greenhouse.tempature != 33)
if(truevar)
world<<"truevar passed" //truevar was true :)
else
world<<"uh oh!" //truevar was false!
if(falsevar)
world<<"uh oh!" //falsevar was true!
else
world<<"falsevar passed" //falsevar was false :)
view()<<"The plant dies because the tempature was set wrong"
del src
return

omg! I put so many debug things in there.. To test I put some on the take, drop, and plant verbs for the actual seed. They all work. But after I plant it, no uh oh's or false var was false or anything popped up. x.x
In response to SHSPlyr03
It's defeating the purpose if all your debug messages are exactly the same. You wouldn't be able to tell them apart.
In response to Kaiochao
I put them before a specific message, so I'll know what it's talking about. That doesn't matter much anyways, since the only one's I get are from Picking it up and then planting it..
In response to SHSPlyr03
SHSPlyr03 wrote:
>       New()
> var/area/greenhouse/G
> for(G in view( 0))
> if(istype( G ))
> greenhouse = G
> plant()


view() defaults to usr, I'm fairly certain you want to use src here (the plant). Also, the istype() check isn't doing anything here because you've already type casted G and for() will respect that. =)


>       New()
> var/area/greenhouse/G
> for(G in view(src,0))
> greenhouse = G
> plant()


Of course, it makes more sense to use locate() here since you only want one.


>       New()
> greenhouse = locate() in view(src,0)
> plant()

In response to SHSPlyr03
Personally, I use numbers as my debug methods. It's alot cleaner than strings, if a little less descriptive.
In my newest project I've actually put in
#define BEGIN_DEBUG var/debugCounter=0
#define DB debugCounter++;world<<debugCounter
#define END_DEBUG debugCounter=0

I'm not sure if I really like the idea yet, but it's a cool idea.
In response to SHSPlyr03
There's everything for plant1. I didn't write this, by the way. Just trying to fix it

It's not written very well, so, good for you. If you're trying to fix it you might want to rewrite it in a manner such that you don't have to define plant and water for each type of plant you have

Assuming plant1 is an /obj type
obj
plants
var
neededTemperature
neededLighting
neededWater
area/greenhouse/greenhouse
obj/Herbology_Objects/plantType

New()
//YMI had a good way of setting the greenhouse other than a possible null pointer runtime error
// and having the parameters of view backwards O_O (I'm watching you YMI)
greenhouse = locate() in view(0,src)
if(!greenhouse) src.loc = null //No greenhouse means no chance to grow I suppose.
else plant()

proc
plant()
spawn(200)
if(greenhouse.temperature == neededTemperature)
if(greenhouse.shady == neededLighting)
if(water == neededWater)
var/obj/Herbology_Objects/thisHerb = new plantType(src.loc)
else
//Not enough water
else
//Not the right lighting
else
//Not the right temperature
//in all cases this /obj is trashed so we can do it here to save lines of code
//BYOND has a nice garbage collector so if you nullify all pointers to an object
//(OOP object mind you, not /obj) then it will be cleaned up for you.
src.loc = null //Null out any other references to src too.

verb
Water()
set src in oview(1)
water++ //ever shorter than water += 1 woohoo.
view() << "[usr] waters the [src]."

//Quickly and easily define as many plants as you want
plant1
neededTemperature = 33
neededLighting = 2
neededWater = 3
plantType = /obj/Herbology_Objects/Mimbulus/

//Another plant for example
plant2
neededTemperature = 9001
neededLighting = 0
neededWater = 1
plantType = /obj/Herbology_Objects/Over9000Weed/

Not saying my way is perfect, but it's a lot better than your current setup.

Besides that, you haven't given us enough information to help you solve the issue. What proc/verb creates plant1 and how is it set up? Is the plant1 del()ing after 20 seconds?

Try putting in:
            plant()
world << "Before spawn(200)"
spawn(200)
world << "After spawn(200)"
if(greenhouse.temperature == neededTemperature)
world << "temp good"
if(greenhouse.shady == neededLighting)
world << "shadyness good"
if(water == neededWater)
world << "water good"
var/obj/Herbology_Objects/thisHerb = new plantType(src.loc)
world << "[thisHerb] created."
src.loc = null //Null out any other references to src too.

To see what output you get.