ID:178734
 
This code generates the mission okay. But when I "get" an item that is on the "parkinglot" it doesn't make it unoccupied and gives me a bad var error.


turf
parkinglot
var/occupied = 0

obj/missions
icon = 'items.dmi'
verb/get()
set src in oview(1)
src.loc = usr
src.loc.occupied = 0//bad var here
//also tried src.loc.loc(back when parking lot as an area
verb/drop()
set src in usr
src.loc = usr.loc
note
icon_state = "note"



Thanks for reading

-ST
src.loc = usr
src.loc.occupied = 0
I think it might be because you're setting it's location to usr' contents, then checking it's location. Try switching those two lines around.
Sariat wrote:
This code generates the mission okay. But when I "get" an item that is on the "parkinglot" it doesn't make it unoccupied and gives me a bad var error.


> turf
> parkinglot
> var/occupied = 0

> src.loc.occupied = 0//bad var here

The problem is that locs are not always turfs, they can be any atom, or even null. Test to make sure it is a turf, and either use a turf alias or the Unspeakable Alternative Which Shall Not Be Named Here.
I'm no expert on the syntax, but it looks to me as though if src.loc = usr, then src.loc.occupied is equivalent to usr.occupied, and occupied isn't a property of mob. I may be wrong. I'm a major newbie here. But why don't you just set usr.loc.occupied = 0 instead?

-Justin
In response to Shadowdarke
Shadowdarke wrote:
Sariat wrote:
This code generates the mission okay. But when I "get" an item that is on the "parkinglot" it doesn't make it unoccupied and gives me a bad var error.


> > turf
> > parkinglot
> > var/occupied = 0
>
> > src.loc.occupied = 0//bad var here


The problem is that locs are not always turfs, they can be any atom, or even null. Test to make sure it is a turf, and either use a turf alias or the Unspeakable Alternative Which Shall Not Be Named Here.

I use a little proc I wrote for myself called my_turf that returns the turf of any object. It's very useful!

I don't have it in front of me, but it's something like:

proc/my_turf(atom/movable/what)
var
this_loc = what.loc

while(this_loc && !(isturf(this_loc))
this_loc = this_loc.loc

return this_loc
turf
parkinglot
var/occupied = 0
proc/parkinglotmission()
var/turf/parkinglot/X
var/obj/missions/note/note
note = /obj/missions/note
for(X in world)
if(X.occupied == 0)
X.occupied = 1
new note(X)
break

This works fine and all, but you can tell where the note is going. Example:
X = parking lot
N = note


XXXXXX
XXXXXX
XXXXXX
XXXXXX
XXXXXX

That is the parking lot. When a note is created, it goes in order. Example:

I call the proc once, this is what the map looks like.

XXXXXX
XXXXXX
XXXXXX
XXXXXX
NXXXXX

I call it again, this is what the map looks like.


XXXXXX
XXXXXX
XXXXXX
XXXXXX
NNXXXX

i call it again, this is what the map lookslike.


XXXXXX
XXXXXX
XXXXXX
XXXXXX
NNNXXX

and so on and so on.


How could I stop it from spawning in order?


-ST

In response to Sariat
Add all the possible locations where it could be placed to a list, then pick randomly from the list:

proc/note_mission
var/list/locations = list()
for(var/turf/T in world)
locations += T
var/create_at = pick(T)
// create it at T

In response to Foomer
Ahhh thanks ;) And if I ever lose my files again or somebody is searching the forums 999 days from now and needs something like this:

proc/parkinglotmission()    
var/turf/parkinglot/X
var/obj/missions/note/note
note = /obj/missions/note
var/list/locations = list()
for(var/turf/parkinglot/T in world)
locations += T
for(X in world)
if(X.occupied == 0)
X.occupied = 1
new note(pick(locations))
break


I know I would find this useful. Sometimes people solve problems off the forums ;)

-ST