ID:158225
 
Hey. I'm trying to make a Marauder's Map. There's one in Hogwarts: A History. I can't seem to figure out how to get it to work right. Could anyone point me in the right direction? Or show me a segment of a code that would help me? I need it to give the person's name and their location. Please, any help would be nice.
Gregs wrote:
Hey. I'm trying to make a Marauder's Map. There's one in Hogwarts: A History. I can't seem to figure out how to get it to work right. Could anyone point me in the right direction? Or show me a segment of a code that would help me? I need it to give the person's name and their location. Please, any help would be nice.

Do you mind explaining what a "Marauder's Map" is?
In response to Calus CoRPS
http://www.youtube.com/watch?v=9G_SdCcYFJw

I also thought about applying this concept as a game. It was a pretty cool idea coming from what's her face.

ts
In response to Calus CoRPS
Calus CoRPS wrote:
Gregs wrote:
Hey. I'm trying to make a Marauder's Map. There's one in Hogwarts: A History. I can't seem to figure out how to get it to work right. Could anyone point me in the right direction? Or show me a segment of a code that would help me? I need it to give the person's name and their location. Please, any help would be nice.

Do you mind explaining what a "Marauder's Map" is?
A "Marauder's Map" is a map that reveals everyone's location throughout the whole game. Like say someone is in Hogwarts Library. It would say "Person" Hogwarts Library 123,412. It doesn't need the co-ordinates but at least their location. Or something i could work with.
In response to Gregs
for(var/client/C)
src << "[C.mob]: [C.mob.loc.loc], ([C.mob.x], [C.mob.y], [C.mob.z]"


Display however you wish, and assuming you have named areas (which is what C.mob.loc.loc is grabbing).
In response to Garthor
Garthor wrote:
for(var/client/C)
src << "[C.mob]: [isturf(C.mob.loc) ? C.mob.loc.loc : "Somewhere special"], ([C.mob.x], [C.mob.y], [C.mob.z]"


I'd advice on making sure not to generate a runtime error here, if I may, since you might get flooded rather fast if you have a hundred players on-line, of which some might be 'in the void (null)'.
In response to Schnitzelnagler
Schnitzelnagler wrote:
Garthor wrote:
for(var/client/C)
> src << "[C.mob]: [isturf(C.mob.loc) ? C.mob.loc.loc : "Somewhere special"], ([C.mob.x], [C.mob.y], [C.mob.z]"

I'd advice on making sure not to generate a runtime error here, if I may, since you might get flooded rather fast if you have a hundred players on-line, of which some might be 'in the void (null)'.

I left that as a learning experience.
In response to Garthor
Thanks :).
In response to Schnitzelnagler
Schnitzelnagler wrote:
Garthor wrote:
for(var/client/C)
> src << "[C.mob]: [isturf(C.mob.loc) ? C.mob.loc.loc : "Somewhere special"], ([C.mob.x], [C.mob.y], [C.mob.z]"

I'd advice on making sure not to generate a runtime error here, if I may, since you might get flooded rather fast if you have a hundred players on-line, of which some might be 'in the void (null)'.
Im getting errors.
runtime error: Cannot read null.mob
proc name: Read (/obj/Marauders_Map/verb/read)
source file: verbs.dm,76
usr: the gg (/mob/You/Player)
src: Marauders Map (/obj/Marauders_Map)
call stack:
Marauders Map (/obj/Marauders_Map): Read()
Gregs (/client): BanCheck(null, "Gregs")
Gregs (/client): New()
In response to Gregs
So. I'm trying to implement a item in the game kind of like the Marauder's Map from Harry Potter. And what the map does is, tells people location. Now, I kind of have any idea for the code and its:
obj
Marauders_Map
icon = 'scrolls.dmi'
icon_state = "blank"
dontsave = 1
wlable = 1
var
content
client/C
verb
read()
set name = "Read"
for(var/client/C)
src << "[C.mob]: [isturf(C.mob.loc) ? C.mob.loc.loc : "Somewhere special"]"
Take()
set src in oview(1)
view()<<"[usr] takes the [src]"
Move(usr)
Drop()
Move(usr.loc)
view()<<"[usr] drops their [src]"

>So. I got that all good and every. Click compile. Everything turns up clean. BUT. When i click "read" in the game. I get this:

runtime error: Cannot read null.mob
proc name: Read (/obj/Marauders_Map/verb/read)
source file: verbs.dm,76
usr: the gg (/mob/You/Player)
src: Marauders Map (/obj/Marauders_Map)
call stack:
Marauders Map (/obj/Marauders_Map): Read()
Gregs (/client): BanCheck(null, "Gregs")
Gregs (/client): New()

>What am i doing wrong??
In response to Gregs
Not entirely sure that this is what you are looking for but it seems like you are trying to display the area that people are in.
The following should do it:
proc/get_area(var/area/a)
if(istype(a)) return a
while(!istype(a))
a = a.loc
return a

obj
Marauders_Map
icon = 'scrolls.dmi'
icon_state = "blank"
dontsave = 1
wlable = 1
verb
read()
set name = "Read"
for(var/mob/M in world)
if(M.client && M.loc)
var/area/location = get_area(M)
usr << "[M]: [location.name]"
Take()
set src in oview(1)
view()<<"[usr] takes the [src]"
Move(usr)
Drop()
Move(usr.loc)
view()<<"[usr] drops their [src]"
In response to Lyndonarmitage1
Why would you take my entirely reasonable format of looping through clients and replace it with the utterly boneheaded format of looping through mobs looking for ones with clients?
In response to Gregs
What you are doing wrong is indentation, and then declaring a client/C variable for the obj instead of fixing THAT error.
In response to Garthor
Garthor wrote:
Why would you take my entirely reasonable format of looping through clients and replace it with the utterly boneheaded format of looping through mobs looking for ones with clients?

Well yours gave me a proc error when i read it in game. So if you tell me how to fix it. I would be more then glad to use yours.
In response to Gregs
It's not just about "Fixing it" it's about doing it correctly.
In response to Gregs
He already told you the problem: [link]

Compare your code to the for() loop in Garthor's initial example in this thread.
In response to Kaioken
Kaioken wrote:
Compare your code to the for() loop in Garthor's initial example in this thread.

And better yet, try to understand instead of simply copy and pasting.