ID:140328
 
Code:
mob
var
rank
New()
rank = rand(1,6)
Login()
..()
var/turfCol = 0
for(var/mob/m in world)
var/obj/clicker/o = new
o.icon = m.icon
o.name = "[m.name] ([m.rank])"
src << output(o, "Lobby.grid1:1, [++ turfCol]")

obj/clicker/Click()
for(var/mob/M in world)
if(M.name == src.name)
var/Challenge = input(M, "Do you want to play as a critter?", null, "no") in list("yes", "no")
switch(Challenge)
if("yes")
//Challenge Proc
if("no")
usr << "[M] has declined your challenge."


Problem description:
Ok. I click on the person name but it doesn't show the input screen. Any idea what i'm doing wrong here?
Well, since the obj/clicker you created in the mob's Login() is named "[mob.name] ([mob.rank])", when the /obj/clicker's Click() proc is ran, it will only execute the stuff under your if statement if a mob in the world is named "[mob.name] ([mob.rank])" (Same as the src, which is the /obj/clicker) I'm assuming your player mobs do not have their rank appended to their names, otherwise you probably wouldn't have specified it as such when you named the clicker. This is probably why you are never seeing the prompt.

You may be better off defining a new variable of type /mob to obj/Clicker named owner or something and then assigning the mob to it on Login(). This will allow you to also bypass the need for a for() loop and the first if() statement (just use the new owner variable in place of M).

mob
var
rank
New()
rank = rand(1,6)
Login()
..()
var/turfCol = 0
for(var/mob/m in world)
var/obj/clicker/o = new
o.icon = m.icon
o.name = "[m.name] ([m.rank])"
o.owner = m
src << output(o, "Lobby.grid1:1, [++ turfCol]")

obj/clicker
var/mob/owner

obj/clicker/Click()
var/Challenge = input(owner, "Do you want to play as a critter?", null, "no") in list("yes", "no")
switch(Challenge)
if("yes")
//Challenge Proc
if("no")
usr << "[owner] has declined your challenge."
In response to Zagreus
I didn't quite understand.
In response to Gamemakingdude
Say my mob's name is Zagreus.

When I am created I am assigned a random rank from 1 to 6. Lets say hypothetically that I'm given rank 1.

After I log in, you create a new /obj/clicker and name it "Zagreus (1)"

When you get to your Click() proc and get to the following lines:

    for(var/mob/M in world)
if(M.name == src.name)


It will loop through every mob in the world and see if their name is equal to "Zagreus (1)". My mob's name is "Zagreus", not "Zagreus (1)", so that statement will be false for me and I will never receive the challenge prompt.
In response to Zagreus
I have tried what you said and it doesn't work.

obj
a
mob
var
rank
New()
rank = rand(1,6)
Login()
..()
var/turfCol = 0
for(var/mob/m in world)
var/obj/clicker/o = new
o.icon = m.icon
o.name = "[m.name] ([m.rank])"
src << output(o, "Lobby.grid1:1, [++ turfCol]")

obj/clicker/Click()
for(var/mob/M in world)
world << "[M.name] [src.name]"
if(findtext(M.name , src.name)==1)
world << "Test!"
var/Win = input(M,"[usr] challenges you!",null,"No") in list("Yes","No")
switch(Win)
if("Yes")
//The proc to start the game
else
usr << "[M] Declined your challenge."

It doesn't get pass when it outputs the M.name and src.name. So its not executing the click proc.
In response to Gamemakingdude
When you're saying that it doesn't get past
world << "[M.name] [src.name]"

Do you mean that it outputs that for each mob in the world but doesn't do anything after it, or that it doesn't do that at all?

Also, you're using findtext() backwards. The first argument is the haystack (text string you want to search), and the second argument is the needle (what you're searching for). For example:

findtext(M.name, src.name) //searches M's name for the src's name

findtext(src.name, M.name) //searches the src's name for M's name.

In response to Zagreus
Its not outputting it at all. So its not executing the the click proc.
In response to Gamemakingdude
Okay, honestly I haven't really attempted at doing clickable objects in grids before, so you might be better off getting help from someone else at this point. I was able to get it working just fine but I can't really spot the difference of what would be hindering yours.

As a test I modified my current project slightly. First I made a new icon called test.dmi and filled it with a solid color.

Then I modified an obj I use for my inventory system like so:
obj/equipment/heldItem
icon='test.dmi'
Click()
alert(usr, "You clicked it!")


Then I modified the output I have to my inventory grid like so:

client/proc/updateInventory()
var
row = 1
col = 3
winset(src, "gameInv.gridInv", "cells=0x0")
for(var/obj/O in mob.contents)
if(!O.wearing)
src << output(O, "gameInv.gridInv:1,[row]")
src << output("<a href='?src=\ref[O];action=view'>[O.name]</a>", "gameInv.gridInv:2,[row]")
//Bunch of other stuff you don't need to see.


When I ran the game and clicked on the new icon, I received the alert as expected. So I really have no idea why yours isn't showing up. Sorry dude.

Perhaps you have another instance of Click() for obj/Clicker somewhere that isn't calling the parent (..()). But that's a long shot. At this point I'm a bit lost for why yours isn't working.
In response to Gamemakingdude
First thing I see here is that your not adding var/obj/clicker/o to a list. The reference to 'o' will be lost unless something maintains a ref to it.

Example
var/obj/clicker/o = new
o.icon = m.icon
g_ListOfClickers.Add(o); // g_ListOfClickers is a global var

As for the clicker/Click() thing.

When you compare the mobs name "tsfreaks" with the one clicked, you are comparing to the name+rank "tsfreaks (3)" instead of just the name. The rank should probably go in its own column.

ts
In response to Tsfreaks
Oooo. Garbage collection! I had JUST thought of that when I noticed that someone else replied. Thanks for pointing that out. :-)