ID:171677
 
How would you code "If the user's contents contains a certain object"?
if(locate(/obj/X) in src.contents)

[EGUY]
In response to EGUY
How could I implement a variable into an object name?

if(locate(/obj/"R[draft_round]P[draft_pick]")in src.contents)


I keep getting this error:
football.dm:199:error: "R[draft_round]P[draft_pick]": missing comma ',' or right-paren ')'
football.dm:199:error: "R[draft_round]P[draft_pick]": missing comma ',' or right-paren ')'


This is the whole of what im trying to do.

var
draft_round
max_draft_round
draft_pick
max_draft_pick

proc/pro_football_draft()
world << "The Pro Football Draft will now begin. All team owners please report to (1,1)!<BR>If you do not make your appropriate draft pick within 8 minutes, your pick will be skipped!<BR><BR>There are currently 6 rounds and 10 picks per round!"
sleep(50)
world << "<B>Round</B> 1 <B>Pick</B> 1!"
draft_round = 1
draft_pick = 1
sleep(4800)
spawn() pro_football_draft2()

proc/pro_football_draft2()
while(1)
if(draft_round<=max_draft_round&&draft_pick<=max_draft_pick)
return 0
else
draft_pick += 1
world << "<B>Round</B> [draft_round] <B>Pick</B> [draft_pick]!"

obj/draft_machine
icon = 'objects.dmi'
icon_state = "draftmach"
verb/Use_Draft_Machine()
set src in view(1,usr)
if(usr.teamname == null)
usr << "You cannot participate in the draft because you don't have a team."
if(draft_round == null)
usr << "The draft has not begun yet"
if(locate(/obj/"R[draft_round]P[draft_pick]")in src.contents)
usr << "Hello, [usr]! Please select a player from the draft pool."


Im trying to make an nfl draft which I don't have to edit manually when someone creates another team so I don't have to edit the code to accomidate the number of draft picks.
In response to ZLegend
Not sure if this is what your looking for but can't you use list?

for example:

mob/var/totalplayers = 0
mob/var/teamplayers = list()
proc/Draft()
var/players = list("Player 1", "Player 2", "Player 3","Player 4")
while(src.totalplayers < 5)
var/draftchoice = input("Who will you draft?") in players
players -= draftchoice
src.teamplayers += draftchoice
src.totalplayers += 1
world << "[src] has chosen [draftchoice]!"

The players list can also have objs or mobs if you have players with individual skills. Just make players =list() then players += /obj/nfl_player.
In response to EGUY
Well the list of players will be manually set for name creation and unique status reasons. So you won't have a running back who runs like a lineman or a kicker that blocks like a full back.

What im trying to do is implement a variable into the path name of an object. Here's how it works:

The draft calls for the owner of Round2 Pick6

When the owner goes up to the "draft machine" it will check his inventory for obj/R"[draft_round]"P"[draft_pick]" but the complier wont let me put a variable into the object path.

The whole purpose of this is so I don't have to manually create a team for someone who wants to start a franchise. Then go back and edit some more coding, then reboot the world which I try to avoid sometimes.

and btw, what does while(src.totalplayers < 5) do?
In response to ZLegend
idk

but maybe you could use:
for(var/obj/A in [the list you are searching in])
if("[A.type]" == "/obj/R[draft_round]P[draft_pick]")
//whatever


This should work if you use it right.

[EGUY]
In response to EGUY
Wouldn't putting /obj/name of object in " " make it just text and not a path?