ID:161772
 
Lack of a better topic title... anyway...

I have a area with 2 vars, for sake of simplicity..
var
Required
PlayerVar

I can set both fine and dandy, however I cannot check against it properly and for the life of me I can't figure out how to do it properly because as far as I'm aware it's returning
"Test"
rather than..
Test

which is causing
GetReq(mob/M,Req as text)
return M.vars[Req]

To fail.

[*Solved*]
I had managed to slip in a OR condition inside the GetReq command which was causing it to succeed due to another reason. I apologize to everyone in here that tried to help me and I caused hassle to.

......MAN I feel *bleep*ing daft now.
Are you storing text to it or an item such as a mob or obj? Even if storing a mob or obj it will show the name as text when sent as output to a usr or world.
In response to Jholder84
Text at the moment, I know how to handle objects and such as
/obj/itembranch/itembranch/itemname

or such :)
In response to Bunnie
When checking your text vars try this: http://www.byond.com/docs/ref/info.html#/proc/cmpTextExact

Might give different results.
In response to Jholder84
You seem to be mis-understanding what I'm receiving in that command.

var
Required
PlayerVar

Alright? Now for example inside the area we edit the instance so it has...

|PlayerVar|"HP"


Then in the area we involve it in this function...

GetReq(mob/M,Req as text)
return M.vars[Req]


What I will end up receiving is
M.vars"HP"
Rather than what I'm hoping to get, which is (obviously)..
M.varsHP

And before you try to recommend that I do something such as..

area
var
hpneeded
hprequired
Enter(var/mob/PC/M)
if(M.HP>hpneeded)
//Do stuff

I don't want to sit there and define a area several hundred times for each variable, so I want to be able to modify the actual area's checking variable and then the required variable, such as..

area
var
playervar
playerneeds
hprequired
Enter(var/mob/PC/M)
if(GetReq(M,playervar)>playerneeds)
//Do stuff
In response to Bunnie
That last post helped. If I am understanding you then you are setting playervar to the stat you're wanting to check such as HP. Yes?
In response to Jholder84
That's right. Sorry I didn't explain with such depth before. So one Area could check a variable named HP.. another might be EXP.. another might be a name.. things like that, which would be applied to the MOB
In response to Bunnie
area
var
playervar
playerneeds
hprequired
Enter(var/mob/PC/M)
if(GetReq(M,playervar)>playerneeds)
//Do stuff


Few mistakes here.
First, Enter() is not for "doing stuff." It is only supposed to return 1 or 0 to permit or deny entry (generally you want to return ..() to allow entry so long as it doesn't violate normal rules of entry). If you want to do stuff, then that belongs in Entered().
Next, you need to verify that M's type is what you said it is. So, the first line of that should be:
if(istype(M))

Next, you aren't describing why what you're trying to do isn't working. If you look at the entry for vars, the list is indexed by strings, so M.vars["HP"] is correct. So what's wrong?
In response to Garthor
Okay let's make sure that you can't accidentally miss what I'm trying to do here..

proc
GetReq(mob/M,Req as text)
return M.vars[Req]

area
var
required
playerreq
Enter(var/mob/PC/M)
set src in view(1)
if(M.client)
if(GetReq(M,playerreq) == required)
return ..()
else
return
else return ..()


There you go, nicely spliced and typed up for you to make sure theres no longer any mis-understanding what I'm ttto do. Hopefully.
In response to Bunnie
Oh, I almost forgot: "as text" (and any other "as") has no meaning outside verbs, for() loops, and input(). Can also be used in variable declarations and those things will use that type implicitly.

Additionally, "set src" also has no meaning outside verbs, so putting it in Entered() is rather silly.

You still need to check the type of M, and M.client doesn't cut it. If M isn't a mob at all, then you're just going to get an error.

Now, just to humor you, I've put together this test case:

proc
GetReq(mob/M,Req as text)
return M.vars[Req]

mob/var
test = "real"
real = 100

mob/verb/test()
world << GetReq(src, test)


This works. Now, tell us what's wrong instead of whining about it.
In response to Garthor
Garthor wrote:
Oh, I almost forgot: "as text" (and any other "as") has no meaning outside verbs, for() loops, and input(). Can also be used in variable declarations and those things will use that type implicitly.

Additionally, "set src" also has no meaning outside verbs, so putting it in Entered() is rather silly.

You still need to check the type of M, and M.client doesn't cut it. If M isn't a mob at all, then you're just going to get an error.

Now, just to humor you, I've put together this test case:

proc
> GetReq(mob/M,Req as text)
> return M.vars[Req]
>
> mob/var
> test = "real"
> real = 100
>
> mob/verb/test()
> world << GetReq(src, test)

This works. Now, tell us what's wrong instead of whining about it.

Halarious.

area
var
required
playerreq
Enter(var/mob/PC/M)
set src in view(1)
if(M.client)
if(GetReq(M,playerreq) == required)
return ..()
else
return
else return ..()


Something about THAT we're missing there. maybe the playerreq part.

We're applying the playerreq variable to a AREA so that we examine the area</> to find what variable we're putting against the required variable.
In response to Bunnie
For the last goddamn time: WHAT THE HELL IS WRONG?
In response to Garthor
Dude. That code works in MY game without modding more than 1 line to define what stat is being checked. What more do you want from this?
In response to Garthor
I've pointed out clearly TWICE what is wrong now, I don't understand how you are not getting what I'm on about.
Lets try it as simple as I can get it...

area // An AREA. We know what this is.
var // Lets declare some variables!
required // We'll use this to match against, For our demo, We're gonna assume this is Frank!
playerreq // We'll use this to find the variable we're matching against required, lets say this is name !
Enter(var/mob/PC/M) // When we enter..
set src in view(1) // Obvious...
if(M.client) // If we're a player..
if(GetReq(M,playerreq) == required) // If our name == Frank
return ..() // Enter
else // Otherwise
return // We can't!
else return ..() // If we're not a player... Enter


That IF branch isn't being examined properly, Regardless of name being Frank, we enter.
In response to Bunnie
I have no idea what the hell you're doing wrong. That worked just fine for me. Just make sure that you are setting required and playerreq right. I used name and it worked. when I changed my name it kept me out. If I didn't set required then it didn't matter. It would let me in.
In response to Bunnie
Thank you for finally actually telling us what's wrong, however, I'm not able to reproduce your problem on my end.. Now: did you actually put that area on the map? Or have you made a subtype of this area that overrides Enter() and doesn't return ..()? Are you adjusting loc directly without calling Move()? Are you already inside the area? Because aside from those options, there's nothing that would result in what you are describing.

You also still haven't removed the useless "set src" or "as text" lines, or added the if(istype(M)) line that is needed.