ID:165025
 
Code:
area/mr_area
icon = 'area.dmi'

layer = TURF_LAYER+1
obj/object
icon = 'blah.dmi'
verb/get()
set src in oview(0)
layer = MOB_LAYER+1
usr.overlays += src
usr << "TESTING"
invisibility = 1
usr<<"Time to play a game [usr]!"
spawn(600)
if(usr.loc==/area/mr_area)
usr<<"Success!"
del(src)
return
else
usr.loc=locate(1,2,3)
usr<<"Hah you failed to complete whatever"
usr.overlays=null
invisibility = 0
return


Problem description:


When I put on the object it works but when I hit mr.area (My area icon) its supposed to delete the object...
Need help and I would apreciate it ^_^
It doesn't work because you're posting a code problem in the Developer How-To forum. :)


Seriously, this forum gets more posts for code problems than people asking how stuff can be done. It's starting to get under my skin.


No offense please, you're not the only one. I just wish people would realize the difference between the two.

Anyway, now that I've ranted, I'll take a look at your code and see if I can work something out. Chances are someone else will beat me to it though. :)
In response to Zagreus
Here's an idea. Why not overwrite the area's Enter() proc to make it check all that stuff?
I don't think you can do if(usr.loc==/area/whatever) like that. I tried the following:

area/general/test

mob/verb/testarea()
if(src.loc==/area/general/test)
world << "You're on a test area"


When standing on my test area, it didn't work. The other day I was fooling around with something for my random encounter demo and did the following, it might be beneficial to you.

area/general/test

mob/verb/testarea()
world << areatest(src)


mob/proc/areatest(mob/M as mob)
for(var/area/A in oview(0,src))
if(A.parent_type==/area/general) return "Found"
return "not found"


Basically outputs Found to the world when you're on a testarea (or any general area, rather) and use that verb.

You'd have to change some things around and do some of your own creation, but that might give you an idea of where to start.
In response to Pyro_dragons
Your method's great too.

It really depends on how he wants to do it.

Does he want it to go off the second he enters it, or 600 ticks after he starts his verb?

Modifying the areas Enter() to take into account the time remaining on the verb would be a bit more complex, that's why I suggested what I did (after I finished yelling at him for using the wrong forum) :)
In response to Zagreus
Im not getting any of this lol im real tired but Im not sure of 1 thing you both said no effece lol...

Im not sure if your answering my quetion but thx anyways =/
In response to Zagreus
Zagreus wrote:
I don't think you can do if(usr.loc==/area/whatever) like that. I tried the following:

> area/general/test
>
> mob/verb/testarea()
> if(src.loc==/area/general/test)
> world << "You're on a test area"
>


It won't work because you checking the player's location, which is a turf. To find the player's location of an area, you need to check the location of the turf.

area/general/test
mob/verb/testarea()
if(loc.loc==/area/general/test) world<<"You're on a test area!"
In response to Jazzyfizzle
Yeah, we both kinda answered, giving two different methods. But then MFC had to come along and give a direct answer. :)

Based on what he said
        usr<<"Time to play a game [usr]!"
spawn(600)
if(usr.loc==/area/mr_area) //This is your problem


It sounds like you can change that if statement to
if(loc.loc ==/area/mr_area)


and it'll work... I've never really tried something like that, but according to MFC, that'd be your best bet right now.

Really, all three of our solutions work, it's just getting down to whatever the most efficient one is and how you want it to operate.
In response to Mega fart cannon
Blah dont know where to put there in my code lol -_-
I think I explained this all wrong...

I need it so when I step onto mr_area my obj will be deleted then the slepp(600) effect deactivates -_-
In response to Zagreus
Okay, I also didn't understand any of those solutions except that last one, which I tried, which did not work.

That's my script, I guess I didn't fully test it out -.- sorry 'bout that. I can't find out a way to make it work >.<
In response to RIPyro
None of this has been tested

Method 1:

area/mr_area
icon = 'area.dmi'
layer = TURF_LAYER+1
var/safe
proc/Testtimer()
set background=1
var/timeleft=600
safe=1
while(timeleft)
sleep(10)
timeleft-=10
safe=0
Enter()
for(var/obj/O in usr.contents)
if(O.type==obj/object)
if(safe)
usr<<"Success!"
del(O)
return
else
usr.loc=locate(1,2,3)
usr<<"Hah you failed to complete whatever"
usr.overlays=null
O.invisibility=0
return



obj/object
icon = 'blah.dmi'
verb/get()
set src in oview(0)
layer = MOB_LAYER+1
usr.overlays += src
usr << "TESTING"
invisibility = 1
usr<<"Time to play a game [usr]!"
for(var/area/A in world)
if(A.type==/area/mr_area)
A.Testtimer()


Method 2: (You'd have to wait for the time to go down to 0 even if you made it to the area)

area/mr_area
icon = 'area.dmi'

layer = TURF_LAYER+1
obj/object
icon = 'blah.dmi'
verb/get()
set src in oview(0)
layer = MOB_LAYER+1
usr.overlays += src
usr << "TESTING"
invisibility = 1
usr<<"Time to play a game [usr]!"
spawn(600)
for(var/area/A in oview(0,usr)
if(A.type==/area/mr_area)
usr<<"Success!"
del(src)
return
else//Edit: Remove this else, and take away one indent from everything below. I missed it on myf irst post
usr.loc=locate(1,2,3)
usr<<"Hah you failed to complete whatever"
usr.overlays=null
invisibility = 0
return


Theres other ways too. But I'm beyond sleepy, and I'm probably not making any sense to anyone right now, so I better take a nap.
In response to Zagreus
I tried both but idk why all this wont work... The second one just kept leading me to me dme page...

On the first one it had 2 undefined vars and 1 undefined Proc... Alright Im out for tonight W/B
In response to Jazzyfizzle
$10 says he copy pasted.
In response to Pyro_dragons
$100,000 says Zagreus doesn't really care if he copy-pasted.
In response to RIPyro
I knew he would, that's why I didn't bother testing it. :)

I'm supposed to be asleep. Good night.
In response to Zagreus
I'll just try and do it myself I asked like 7 times I read the DM guide so go ahead bet on me I really dont care lol
So what Im not as good as you people at codeing so you go ahead and bet on that i copied and pasted it? That's sad but whatever forget the forum just came here for help -_-
Obv.

Whatever cya ppl -_-
In response to Jazzyfizzle
Dude, and I want to help you.

But the way to learn is to look at the code, think about how it works, think about how you can implement it to suit your needs, and then re-create it.

Copying and pasting won't make you any better at writing code, and that's what we're trying to do here.

I wasn't making fun of you. But I'm certainly not here to write it for you. I'm just trying to help you understand the basic how-to's of things. (This is the how-to forum after all).

So please, just chill out and relax, no one here is laughing at you.

I was hoping the little snippet of code I posted up would help explain what I meant when I showed you my previous snippet, or how it may be done using Enter() as per Pyro's suggestion. It wasn't intended for a plug in play solution though. If you want that, you're better off asking in classified ads.

Lets get some rest tonight, and maybe after things have cooled off, we can try this again tomorrow. Start by taking a look at the current state of your code. Decide exactly what you want it to do and how you're going to do it. When you run into errors, or if you don't understand exactly how any of the procs work, come here and we'll help.

In order to do things the right way, you need to know exactly how every piece of your code functions. If you don't get anything, stop, read the reference, ask us, but don't just put it in because "someone said it works".

In response to Zagreus
Thats the problem IDK what you did wrong it does'nt look like you did anything wrong the code was just for 1 map I should'nt be wasteing this much time trying to make a decent map im just gona make it into somthing diffrent maybe I can make sence out of what I do understand of your code and turn it into something good for my map...


The DM guide did'nt explain half of the things you said in there thats why I am not real sure how to write it out =/

In response to Pyro_dragons
If already, Entered(). Enter() should only be used for [dis]allowing the entrance by returning 0 or 1, and not actually do actions.
Page: 1 2