ID:2046780
 
(See the best response by Nadrew.)
code
mob
proc
ObjList()
var/objs = 0
for(var/obj/P as null|anything in typesof(/obj))
winset(src, "Objects.objlist", "current-cell=[++objs]")
src << output("<center><a href=?src=\ref[P];cmd=action><Font color=black>[P]</a>", "Objects.objlist")
src << output("[objs] Found", "Objects.objsfound")
winset(src, "Objects.objlist", "cells=[objs]")

Topic(href,href_list[])
if(href_list["cmd"])
switch(href_list["cmd"])
if("action")
if(src == /obj/SingleFence)
var/T = input("How Many Do u Want To Create?") as null|num
if(T == 1)
var/obj/F = new src(usr.loc)
view() << " <font color = white>With A Few Waves Of The Hands [usr] Create's a [F:name] "
return
else
var/obj/F = new src(usr.loc)
F.amount = T
view() << " <font color = white>With A Few Waves Of The Hands [usr] Create's [T] [F:name]'s "
return
else
var/obj/F = new src(usr.loc)
view() << " <font color = white>With A Few Waves Of The Hands [usr] Create's a [F:name] "
return


im trying to make a window to show all Objects coded in game in a skin window and when you click an object it creates it, all Objects show in windows but when I click an object to create it I get the error: runtime error: Cannot execute null.Topic, any help would be great thanks().

Best response
You're setting the ref to P, but P is just a typepath, not an object.

What you want is something like:
<a href="?create_object=[P]">[P]</a>


Then inside of client/Topic(), you'd do something along the lines of:

client/Topic(href,href_list[])
if(href && href_list["create_object"])
var/new_type = href_list["create_object"]
new new_type(mob.loc)
In response to Nadrew
I got this to work thanks

1 other thing is when I click to make a fence I want it to ask me how many to create but I cant seem to get it to work

var/obj/amount = 1
client
Topic(href,href_list[])
if(href && href_list["create_object"])
if(href_list["create_object"] == "/obj/SingleFence") var/T = input("How Many Do u Want To Create?") as null|num
if(T == 1)

var/obj/new_type = href_list["create_object"]
new new_type(mob.loc)
view() << " <font color = white>With A Few Waves Of The Hands [usr] Create's a [new_type:name] "
return
else
var/obj/new_type = href_list["create_object"]
new new_type(mob.loc)
new_type.amount = T <<<<<<<THIS IS WHERE I CANT GET IT TO WORK

view() << " <font color = white>With A Few Waves Of The Hands [usr] Create's [T] [new_type:name]'s "
return

at the part where it says new_type.amount = T I get the error:
runtime error: Cannot modify /obj/SingleFence.amount
new_type is still only a type path (or more accurately, just a string), not an obj. What you need to do is have a var hold the object you just created, which you aren't doing.
In response to Lummox JR
how would I go about doing that? if u don't mind me askin
All you need to do is assign the result of new() to a var.
In response to Lummox JR
sorry but i dont know how i would do that
var/obj_type/obj_instance = new obj_type(parameters)

// or (because you can use a space instead):

var obj_type/obj_instance = new obj_type(parameters)





Your corrected code would read:

                    var/obj/new_type = href_list["create_object"]
var/obj/my_new_obj = new new_type(mob.loc)
my_new_obj.amount = T


I'd skip storing the object type in a variable though, it doesn't look like you need it at this time. (Edit: Or on second thought, I do tend to favor verbosity; it's up to you but it's not necessary.)
In your code, you can either have a second variable containing the object you created, or simplify the usage of new_type.

var/obj/new_type = new href_list["create_object"](mob.loc)
new_type.amount = T


But for future reference, what Lummox means is storing the result of new() in a variable (like I did above) so you can utilize it further in the code, this isn't needed if you don't need to interact much with the object after creation.

var/obj/something/my_obj = new() // Creates a new /obj/something and assigns it to the my_obj variable.
Thank you very much