ID:1996491
 
(See the best response by Super Saiyan X.)
Code:
mob/var        //varible testing
rpp=100

mob
Stat()
stat("RPP","[src.rpp]")
statpanel("Inventory",src.contents)

obj
StarterItems

IronMace1
icon='weapons.dmi'
icon_state="mace1"

IronMace2
icon='weapons.dmi'
icon_state="mace2"

IronMace3
icon='weapons.dmi'
icon_state="mace3"



var/list/RandomStarterItem = list("/obj/StarterItems/IronMace1", "/obj/StarterItems/IronMace2", "/obj/StarterItems/IronMace3"), //etc...//)

mob/verb/RandomStarterItem()
if(usr.rpp>=100)
usr.contents+=new pick(RandomStarterItem)
usr.rpp-=100
else
src<<"You need at-least 100 roleplay points."
return


Problem description:
Trying to have the player use their RPP to earn a random starting item. Not quite sure what I'm doing wrong.


loading random list.dme
main.dm:67:error: >=: bad variable definition
main.dm:67:error: if: invalid variable name: reserved word
main.dm:68:error: pick: undefined var
main.dm:71:error: "You need at-least 100 rpps.": bad variable definition
main.dm:71:error: src: bad variable definition
random list.dme:16:error: return: invalid variable name: reserved word
random list.dmb - 6 errors, 0 warnings (12/11/15 11:15 pm)


Best response
one of your issues is real simple, there's an extra comma AFTER your list definition.

Also, you don't want those paths to be strings. You want them to be literal paths. Otherwise, you'll have to use text2path().
You have an extra comma at the end of the list, after the closing parenthesis. That's what's causing your errors.

Now, you're going to get extra errors because the line usr.contents+=new pick(RandomStarterItem) is not how you do what you're trying to do.

All you have to do is move the pick(RandomStarterItem) to a variable instead of directly trying to create it and use the text2path() function so you can get the raw path. Like so:

//...
RandomStarterItem()
if(usr.rpp>=100)
var/item = text2path(pick(RandomStarterItem)) <----
usr.contents+=new item <----
//...
In response to Super Saiyan X
Super Saiyan X wrote:
one of your issues is real simple, there's an extra comma AFTER your list definition.

Also, you don't want those paths to be strings. You want them to be literal paths. Otherwise, you'll have to use text2path().

Thank you!
In response to Kats
Kats wrote:
You have an extra comma at the end of the list, after the closing parenthesis. That's what's causing your errors.

Now, you're going to get extra errors because the line usr.contents+=new pick(RandomStarterItem) is not how you do what you're trying to do.

All you have to do is move the pick(RandomStarterItem) to a variable instead of directly trying to create it and use the text2path() function so you can get the raw path. Like so:

> //...
> RandomStarterItem()
> if(usr.rpp>=100)
> var/item = text2path(pick(RandomStarterItem)) <----
> usr.contents+=new item <----
> //...
>



Thank you! The visual correction helped me a lot more.
You could actually save the overhead of calling text2path() every time and just have a list of types instead of a list of strings.