ID:2904086
 
Project Overview:
So in this Game, the map of the Game is the map of another Game.... Players can move the Camera all across the Map, but the can't actually move their Player unless they set a WayPoint...
I am a really noobie person with some aspects of BYOND...
I want to create a WayPoint that only the player will see.

Code:
obj
WayPoint
icon = 'WayPoint.dmi'
mob
var
WayPointLocation

mob/verb/setWaypoint()
set name = "Set Waypoint"
usr.WayPointLocation = usr.loc
usr.WayPointLocation += new /obj/WayPoint



mob/verb/removeWayPoint()
usr.WayPointLocation = null
usr.WayPointLocation -= new /obj/WayPoint


mob/verb/toggleWayPoint()
if(!usr.Waypoint)
setWaypoint()
else
removeWayPoint()


Problem description: Compiles properly but it doesn't allow me to place a WayPoint on the map... Has an error for usr.loc being src...

Also, I don't know how to make it a multiple instance in which 10 different clients would each have their own WayPoint and not see each others WayPoint.

Sorry for having no clue on where to start.

Tried to improve my code:

mob/player/var/WaypointActive = 0
mob/player/var/target_loc
mob/player

verb/SetWaypoint()
var/obj/waypoint/W = new
src.WaypointActive = 1
W.set_target_loc(locate(x, y, z), usr)
src.target_loc = W.target_loc

verb/RemoveWaypoint()
var/obj/waypoint/W = locate()
src.WaypointActive = 0
target_loc -= W

proc/UpdateWaypointVisibility()
for(var/obj.waypoint/W in world)
if(W.owner == usr)
if(src.WaypointActive == 1)
W.target_loc += W
else if(src.WaypointActive == 0)
W.target_loc -= W
else
return 1


There are no errors and the code looks clean but it doesn't do anything and doesn't throw an error in the game until I click remove waypoint (Create Waypoint does nothing and throws no errors)
Sorry for blowing up my own Post...
I realized I hadn't done it correctly...
So I attempted to fix up my code...

// mob/player.dm
mob/player/var/WaypointActive = 0
mob/player/var/target_loc
mob/player

verb/SetWaypoint()
var/obj/waypoint/W = new
src.WaypointActive = 1
W.target_loc(locate(x, y, z), usr)
W.target_loc = src.loc
UpdateWaypointVisibility()


verb/RemoveWaypoint()
src.WaypointActive = 0
UpdateWaypointVisibility()

proc/UpdateWaypointVisibility()
for(var/obj.waypoint/W in world)
if(W.owner == usr)
if(src.WaypointActive == 1)
W.target_loc = new(W)
else if(src.WaypointActive == 0)
del(W)
else
return 1


Now it doesn't throw an error on compile and when I use either SetWaypoint() or removeWaypoint() the both do not throw an error inGame but there is nothing happening from these verbs, it should be putting a blip on the map...

It does nothing but doesn't throw a single error...
obj
WayPoint
icon = 'WayPoint.dmi'
var/xobj=3
var/yobj=3
var/zobj=3
mob
var/tmp
obj/WayPointLocation

mob/verb/setWaypoint()
set name = "Set Waypoint"
if(WayPointLocation)
W.xobj=usr.x
W.yobj=usr.y
W.zobj=usr.z
else
for(var/obj/WayPoint/O in contents)
WayPointLocation=O
if(WayPointLocation)return
else
var/obj/WayPoint/W=new()
W.xobj=usr.x
W.yobj=usr.y
W.zobj=usr.z
WayPointLocation=W
contents+=W


mob/verb/removeWayPoint()
usr.WayPointLocation= initial(usr.WayPointLocation)


mob/verb/toggleWayPoint()
if(!usr.Waypoint)
setWaypoint()
else
removeWayPoint()

I made my version
mob/var/turf/TSaved

TSaved=loc
I got it working the way I wanted:

// mob/player.dm
obj/WayPoint
icon = 'MAP/Waypoint.dmi'

var
WayPointLocation = 0

mob/player
var/tmp
obj/WayPoint

verb/setWaypoint()
set name = "Set Waypoint"
if (!WayPoint)
WayPoint = new /obj/WayPoint
WayPoint.loc = locate(usr.x, usr.y, usr.z)
WayPointLocation = 1

verb/removeWayPoint()
if (WayPoint)
WayPoint.loc = locate(1, 1, 1)
WayPointLocation = 0

verb/toggleWayPoint()
if (!WayPointLocation)
setWaypoint()
else
removeWayPoint()
I believe loc will return to null in load game. Because this var is reference, to call and use. You can storage the obj is contents, then it be restaured in the world with the player. I know 2 ways, seccond could be a world savefile with all obj. You can give this obj, in creation person, we will live forever.