ID:174395
 
Hey! I am trying to make a radar!
I tried this code (adapdted from a demo):

mob/var/obj/radar  // This client var will point to the radar object on the player's screen (handy because we'll need to reference to it later!)

client/New()
var/obj/O = new // This code creates the radar object and places it on the client's screen. Note how the object 'follows' the mob around as he moves. This is because the object is 'attached' to the client screen.
O.icon = 'Radar.dmi'
O.icon_state = "Radar"
O.screen_loc = "10,10"
src.screen += O
src.radar = O
..()

proc/Update_Radar()
for(var/mob/M in world)
if(M.radar)
M.radar.overlays.Cut() // Clear the radar of existing blips
var/obj/I = new
I.icon = 'Radar.dmi' // Put a white cross-ish obj at the centre to get a better idea of distance ingame
I.icon_state = "Self"
M.radar.overlays += I // Add the white cross-ish image to the radar's overlays
for(var/mob/O in world) // Search through all of the mobs...
if(get_dist(O.mob,M) < 40 && O.mob.z == M.z && O.mob != M) // If the mob is within 10 squares of the player, is on the same z level, and isn't itself (don't want to place yourself on it, do you?)
I = new
I.icon = 'Radar.dmi' // Create our new blip for the mob found
if(O.client==1)
I.icon_state = "Player"
if(/mob/monster)
I.icon_state = "Hostile"
if(/mob/monster)
if(O.client !=1)
I.icon_state = "Freindly"
I.pixel_x = -(O.mob.x - M.x)*4 // Remove the comments on the *2 to modify the range/spacing of the blips
I.pixel_y = -(O.mob.y - M.y)*4
M.radar.overlays += I
spawn(7)
Update_Radar()

But it will be obvious to you that I got lots of errors. 7 exacty:

Radar.dm:22:error:O.mob:undefined var
Radar.dm:22:error:O.mob.z:undefined var
Radar.dm:22:error:O.mob:undefined var
Radar.dm:27:error:/mob/monster:undefined type path
Radar.dm:29:error:/mob/monster:undefined type path
Radar.dm:32:error:O.mob.x:undefined var
Radar.dm:33:error:O.mob.y:undefined var

Zeta.dmb - 7 errors, 0 warnings (double-click on an error to jump to it)

How can I fix this?

~GokuSS4Neo~

P.S.THANK YOU VERY MUCH FOR YOUR TIME AND HELP!
You seem to have taken code meant for a client and given it to a mob. That would be the cause of your errors.
In response to Jon88
Yer, I have. But I can't find any other way of doing a Radar ?!

~GokuSS4Neo~
In response to Gokuss4neo
I have found out most the things I have done wrong and fixed them. It is now Client based e.t.c. But I was wondering, how can you say using if "is it a /mob/monster"?

~GokuSS4Neo~
In response to Gokuss4neo
istype()
In response to Garthor
Thank you!

~GokuSS4Neo~
In response to Gokuss4neo
This is getting very annoying -_-'

The radar will now give no errors, so I can run the game, but In-Game the Radar comes up but doesn't display where anyone is!!
Here is my code :

client/var/obj/radar // This client var will point to the radar object on the player's screen (handy because we'll need to reference to it later!)

world/New()
..()
Update_Radar()

client
verb
Turn_Radar_On()
var/obj/O = new O.icon = 'Radar.dmi'
O.icon_state = "Radar"
O.screen_loc = "12,12"
src.screen += O
src.radar = O
..()
proc/Update_Radar()
for(var/client/C)
if(C.radar)
C.radar.overlays.Cut()
var/obj/I = new
I.icon = 'Radar.dmi'
I.icon_state = "Self"
C.radar.overlays += I // Add the white cross-ish image to the radar's overlays
for(var/mob/M in world) // Search through all of the mobs...
if(get_dist(C.mob,M) < 10 && C.mob.z == M.z && C.mob != M) // If the mob is within 10 squares of the player, is on the same z level, and isn't itself (don't want to place yourself on it, do you?)
I = new
I.icon = 'Radar.dmi' // Create our new blip for the mob found
if(M.client==1)
I.icon_state = "Player"
else
if(istype(M,/mob/monsters))
I.icon_state = "Hostile"
else
I.icon_state = "Friendly"
I.pixel_x = -(C.mob.x - M.x)//*2 // Remove the comments on the *2 to modify the range/spacing of the blips
I.pixel_y = -(C.mob.y - M.y)//*2
C.radar.overlays += I // Add the blip to the radar on the client's screen
spawn(7)
Update_Radar()
In response to Gokuss4neo
proc/Update_Radar()
for(var/client/C)
if(C.radar)
C.radar.overlays.Cut()
var/obj/I = new
I.icon = 'Radar.dmi'
I.icon_state = "Self"
C.radar.overlays += I // Add the white cross-ish image to the radar's overlays
for(var/mob/M in world) // Search through all of the mobs...
if(get_dist(C.mob,M) < 10 && C.mob.z == M.z && C.mob != M) // If the mob is within 10 squares of the player, is on the same z level, and isn't itself (don't want to place yourself on it, do you?)
I = new
I.icon = 'Radar.dmi' // Create our new blip for the mob found
if(M.client==1)
I.icon_state = "Player"
else
if(istype(M,/mob/monsters))
I.icon_state = "Hostile"
else
I.icon_state = "Friendly"
I.pixel_x = -(C.mob.x - M.x)//*2 // Remove the comments on the *2 to modify the range/spacing of the blips
I.pixel_y = -(C.mob.y - M.y)//*2
C.radar.overlays += I // Add the blip to the radar on the client's screen
spawn(7)
Update_Radar()


When you had the If(M.client) and the else, you indented the adding the ''blip'' to the radar, so i redid it, and it SHOULD work now
In response to JackGuy
for(var/client/C)
if(C.radar)
C.radar.overlays.Cut()
var/obj/I = new
I.icon = 'Radar.dmi'
I.icon_state = "Self"
C.radar.overlays += I // Add the white cross-ish image to the radar's overlays
for(var/mob/M in world) // Search through all of the mobs...
if(get_dist(C.mob,M) < 10 && C.mob.z == M.z && C.mob != M) \\I think the this part (in bold) would check if the other are the same type, and since all players got same mob (usually) they dont appear, change it to something like this: C!=M.client This would check if the client is diffrent (Can anyone comfirme if i'm right or not?)
I = new
I.icon = 'Radar.dmi' // Create our new blip for the mob found
if(M.client==1)
I.icon_state = "Player"
else
if(istype(M,/mob/monsters))
I.icon_state = "Hostile"
else
I.icon_state = "Friendly"
I.pixel_x = -(C.mob.x - M.x)//*2 // Remove the comments on the *2 to modify the range/spacing of the blips
I.pixel_y = -(C.mob.y - M.y)//*2
C.radar.overlays += I // Add the blip to the radar on the client's screen
spawn(7)
Update_Radar()