ID:141504
 
Code:
mob
strummed
verb
red()
set hidden = 1
if(usr.hitting == 0)
usr.hitting = 1
for(var/obj/flashred/K in usr.z)
if(K.z == usr.z)
for(var/mob/red/L in usr.z)
if(L.loc == K.loc||L.y == K.y+1||L.y == K.y-1)
usr << "You hit a red note!"
usr.score += 5
usr<<sound('B note.wav')
usr.hitting = 0
return
else
usr << "You missed a red note!"
usr.score -= 5
usr.hitting = 0
return
else
usr.hitting = 0
return
else
return


Problem description: My problem is I need a way for say, you get sent to (47,53,6) of 30 worlds that are the exact same, however this verb im using keeps returning instead of doing the code because its selecting flashred out of (x,y,1) instead of (x,y,6) or whatever Z the player is in, how can I fix this?

You're selecting the entire z layer, so it defaults to x=1 and y=1 in that z layer. Try being more specific.
In response to Spunky_Girl (#1)
the x and y has nothing to do with it thats just the usr's location its only the z, i repeat the x and y have no effect, the code should still work no matter the x or the y.
In response to SadoSoldier (#2)
30 maps

Each map has a flashred flashgreen flashyellow flashblue and flashdarkgreen

The code is ment to select the flash's in the usr's z not the other z's.

Unfortunetly that is not the case. That is my problem.
In response to SadoSoldier (#3)
You seem to have misread my post. You're locating only the z layer. No x or y coordinates on that z layer, so they default to 1.

So if you do "in src.z", it'll locate the coordinates (1,1,src.z) by default. If src's z is 4, then it'll locate the coords (1,1,4). If src's z is 150, it'll locate the coords (1,1,150). Understand now?
In response to Spunky_Girl (#4)
And im saying that it doesnt matter if x and y is 1 if its (87,54,2) or (45,5,2) it doesnt matter the code should still work since nothing is based on the x or the z except for the locate of the red note which is not even in that code.
                    for(var/obj/flashred/K in usr.z)
for(var/mob/red/L in usr.z)
/* Do these actually work?
I would have guessed that you should have created a list through the use of block */



My problem is I need a way for say, you get sent to (47,53,6) of 30 worlds that are the exact same, however this verb im using keeps returning instead of doing the code because its selecting flashred out of (x,y,1) instead of (x,y,6) or whatever Z the player is in, how can I fix this?

I'm sorry, I'm not sure that I understand what you intend to do. Could you re elaborate?
In response to Schnitzelnagler (#6)
Step by step,

You log in and then you go through all the instructions and character choosing then you head into the room to the left, you click on a guitar and it sends you to the guitar playing room now in order for the code i showed you to work you must have pressed the strum verb which makes usr.strumming == 1 allowing you to momentarily use the red verb after which if you do use the verb it locates the object flashred in world(i took out usr.z and replaced it with world, didnt help much) then in order to make sure its working i used if(K.z == usr.z) else return thus is my problem, it locates the wrong flashred and when that area of the code comes along it shuts the code down because !K.z == usr.z --- need further explanation of the problem?
In response to SadoSoldier (#7)
Try using...
var/obj/flashred/K = locate() in src.z
if(K)
//...
else
//...
In response to Spunky_Girl (#8)
I tried this..
mob
strummed
verb
red()
set hidden = 1
usr<<"hidden"
if(usr.strumming == 1)
usr<<"1strumming"
if(usr.hitting == 0)
usr<<"0hitting"
usr.hitting = 1
usr<<"1hitting"
var/obj/flashred/K = locate() in src.z
usr<<"flashred"
if(K.z == usr.z)
usr<<"k.z"
for(var/mob/red/L in world)
usr<<"usrz"
if(L.loc == K.loc||L.y == K.y+1||L.y == K.y-1)
usr<<"loc"
usr << "You hit a red note!"
usr.score += 5
usr<<sound('B note.wav')
usr.hitting = 0
return
else
usr << "You missed a red note!"
usr.score -= 5
usr.hitting = 0
return
else
usr<<"ffs"
return
else
usr.hitting = 0
usr<<"hitting"
return

else
usr<<"strumming"
return

and ended up with this...

runtime error: Cannot read null.z
proc name: red (/mob/strummed/verb/red)
usr: SadoSoldier (/mob)
src: SadoSoldier (/mob)
call stack:
SadoSoldier (/mob): red()
hidden
1strumming
0hitting
1hitting
flashred

So for some reason after i put in what you told me to put in it quits the next line is if(K.z == usr.z) but it doesnt hit that part of the code, nor does it hit the else part...
In response to SadoSoldier (#9)
In other words, it's not finding the K object on that layer.

var/obj/flashred/K = locate()
if(K && K.z == src.z)
//...


I doubt that would have any effect, but it would further prove that it's not finding K on the usr's z layer if it doesn't work.
In response to Spunky_Girl (#10)
yeah i already knew it wasnt but i did it anyway and its still saying its in a different z
In response to SadoSoldier (#11)
Well then that would be your problem :D
The z variable is a number. There are no /obj/flashred's in the number (why would there? It makes no sense), so nothing happens. You can fix this by looping through a list of everything in the Z level, which can be obtained using the block() proc.

Also, Boolean shortcuts are your friend. You can read the section on Boolean Logic in the DM guide.