var/list/ril[3]
//------------ Later in code...
proc
create_item(zlevel)
var/obj/item/new_obj
var/x = rand(1,75)
var/y = rand(1,75)
var/z = zlevel
var/itemnum = rand(0,3)
ril.Add(/obj/item/gold,0)
ril.Add(/obj/item/gold,1)
ril.Add(/obj/item/gold,2)
ril.Add(/obj/item/gold,3)
var itemstr = ril[itemnum]
new_obj = new itemstr(locate(x,y,z))
Why will this not create? It keeps saying that I can't create NULL!?! All this proc does is add some items to the list ril, then randomly selects one and creates it.
Also: Why do I get warned that I don't use new_obj, but that I defined it? I did use it, I created (Er, tryed to) and item with it. (This happens in other places in my script too. Cept those work. This one doesn't.)
You are adding 3 null values to the beginning of ril when you declare it. It's not quite like an array size limit. Here's an example:
The Add() proc takes the items to add as arguments. You are adding a type and then a num. By that logic, roughly half of the time, you are going to get a num and not a type (not counting the nulls). That number will not work as a type to be created.
Unlike other languages, the first index of a DM list is 1. A value of 0 for itemnum will cause an error. Why not just use pick()?
You might want to keep in mind that the items you add are still being stored when the proc is done. You are adding the same things to the list whenever the proc is run and not removing them in the code you have shown. Do you use the list for something else?
PS: The new_obj var is assigned a value and then nothing is done with it. As a local var, it is destroyed soon after. It's not even storing the value for use later. It doesn't really hurt anything, but it doesn't help either.