ID:264587
 
Code:
mob
proc
GridBase()
src << output(new/obj/Basechoose/SkinW, "grid1:1,1")
src << output(new/obj/Basechoose/SkinB, "grid1:1,2")

obj/Basechoose
SkinW
icon='NHC Base Male.dmi'
icon_state="Skin"
layer=9999
Click()
usr<<'select.ogg'
alert("You have selected your base icon!")
SkinB
icon='NHC Base Male Dark.dmi'
icon_state="Skin"
layer=9999
Click()
usr<<'select.ogg'
alert("You have selected your base icon!")


Problem description: The problem here is well first I know I programmed the grid proc very basic but I am only testing. My main problem here is when the object loads up in the grid I cannot activate the action when I click on them. Can anyone tel me why?

They're getting collected by the garbage collector because they do not have any attachment to the game after the proc finishes putting them in the grid. There are a few ways to fix this; first, you could give these objects a location on the map, but that would eventually create a lot of unnecessary objects and cause lag/problems.

Second, and more preferably, you can store them in a list (even more preferably, a temporary one attached to the mob this is for). As an example:

mob
var/tmp
list/base_garbage // Non-initialized temporary list.
proc
GridBase()
var/list/bases=typesof(/obj/Basechoose)-/obj/Basechoose // Create a list of all bases.
if(!base_garbage) base_garbage=new // Initialize our temporary list.
var/count=1
for(var/X in bases) // Loop through all bases.
var/obj/Y=new X // Make a new one,
base_garbage+=Y // and store it in the temp list.
src << output(Y,"grid1:1,[count]") // Then output it,
count++ // And increase our position on the grid.

EndBase()
del(base_garbage) // Delete our temporary list and everything in it.
// This helps save us resources.