ID:170637
 
Ugh. I think this'd be evily simple but im code fried and its only noon!

I want this code to spawn a obj to a location and check to see if someones coords match the objs coords. If so I want the coords to be stored in the person that uses the verbs vars.

Heres what I was thinking...
mob
var
coord1 = 0
coord2 = 0
coord3 = 0
truecoord = 0


obj
newobj/B

mob
verb
newobj()
var/A = new /obj/newobj/B(loc = locate(src.x,src.y+1,src.z))
src.x = usr.coord1
src.y = usr.coord2
src.z = usr.coord3


I need to combine the 3 coord's to make the truecoord but this is where my problem is... Only way I can think to do this atm is this...

usr.truecoord = usr.coord1,usr.coord2,usr.coord3


Doesn't work. Theres an easier way to do this code i'm sure I think its called nesting? Which I dont know how to do.
[edit]
I forgot the part about the IF part but i cant do that till I get this working anyway.
Lilcloudy1 wrote:
I want this code to spawn a obj to a location and check to see if someones coords match the objs coords. If so I want the coords to be stored in the person that uses the verbs vars.

Cloudy, you're being very unclear. When asking for help on the developer forum, you should be informative, accurate, and specific. Also, good grammar is a plus (It makes your post understandable)

Right now, as I understand it, you want to, in a mob/verb, create a random obj at a random location and check if there are any player characters at that location. Then, if there is a player character at that spot, you want to store the location in a variable belonging to the src of the verb. I doubt this is what you want. Please clarify.
In response to Wizkidd0123
That is what I want. If there is a player where that object spawns I want the players location stored. The location isn't random. I don't think I can ask in any other way...


Spawn the object>If a mobs coords match the objs coords> do somthing

Thats what I want. I'm sorry I don't know how to...explaine more clearly...
In response to Lilcloudy1
What an idiot I am. As I thought it was simple, I figured it out. A little break really helps. Thanks WIZ, I will try to make my posts more clear in the future.

While I'm here, could you explaine nesting in a loop? (I think thats what its called) If thats not what its called, and you have no idea what im talking about ( again =] ) dont trouble yourself trying to figure it out. Thanks

-c1
In response to Lilcloudy1
Well I haven't heard of nesting myself, but someone might else have. Explain more and maybe I can help. Or maybe someone else.





-Doh
In response to Lilcloudy1
Nesting means to place inside more or less, and a loop... is a loop.
Example:
for(y = 0, y < h, y++)
for(x = 0, x < w, x++)
// Instructions

Nested for loops.
In response to Nova2000
Nova2000 wrote:
Nesting means to place inside more or less, and a loop... is a loop.
Example:
> for(y = 0, y < h, y++)
> for(x = 0, x < w, x++)
> // Instructions
>

Nested for loops.


I see, but I dont understand the example y++ and x++ what does that do?

Does that have somthing to do with adding =1?
In response to Lilcloudy1
You can look it up in the help file (press F1 in Dream Maker). Basically it adds one to the variable, but it can be before or after the variable (i++ or ++i) and have different results.

var/x=0
while(x < 3)
var/y=0
while(y < 3)
world<<"y([y++]) is less than three."
world<<"x([++x]) is less than or equal to three."
In response to YMIHere
YMIHere wrote:
You can look it up in the help file (press F1 in Dream Maker).

If you want to look it up, it's called

for() loop
In response to Wizkidd0123
Oh, good idea, I figured he meant the operator itself. =)
In response to YMIHere
YMIHere wrote:
You can look it up in the help file (press F1 in Dream Maker). Basically it adds one to the variable, but it can be before or after the variable (i++ or ++i) and have different results.

> var/x=0
> while(x < 3)
> var/y=0
> while(y < 3)
> world<<"y([y++]) is less than three."
> world<<"x([++x]) is less than or equal to three."
>



So that says, X is 0, Y is 0, while y is less than three display for (y++), ...er zero plus 1 is less than or equal to three... what the hell...
In response to Lilcloudy1
y will count up to three by adding one to y on every iteration just after displaying it. Then one will be adding to x just before displaying it. Then it will repeate this process until x is equal to three. Both loops stop when their respective variable is 3, but by using the increment operator both ways it is displayed differently. y appears to start at 0 and end at 2, while x appears to start at 1 and end at 3. I put it in nested loops because it was on topic, but this will demonstrate it as well as keep it a little less complicated.

mob
var/Number=0
verb/PreincrementNumber()
src << "Number = [++Number]"
verb/PostincrementNumber()
src << "Number = [Number++]"


Here, if you click the PreincrementNumber() verb first, you'll get "Number = 1" because it adds to it, then displays it (think prefix). If you click PostincrementNumber() right after that you will get the same message. That's because it doesn't add to it until after it's displayed it. =)