ID:169733
 
With this browser shop code, this error comes up when I compile it, "Shops.dm:158:error:sellamount:undefined var"...

mob
icon = 'mob.dmi'
icon_state = "a1"
Shop_Keepers
Weapons
name = "Arthor Berkins"
var/html
verb
Buy()
set src in oview(1)
usr.Shop_Keepers = src
Weapons(usr)


proc
Weapons()
usr << "Running proc"
html = {"
<style>
<center><BODY BGCOLOR=gray TEXT=white LINK=black ALINK=black VLINK=black><font face = verdana>
</style>
<center><BODY BGCOLOR=gray TEXT=white LINK=black ALINK=black VLINK=black><font face = verdana><big>Welcome to the Dartora Shop!<br></center></big></b>
<center><BODY BGCOLOR=gray TEXT=white LINK=black ALINK=black VLINK=black><font face = verdana><font size = "1">Supplying everyone with all needs</center></p>
<center><table border = "3" cellspacing = "1" cellpadding = "1"></center>
<Caption><center><BODY BGCOLOR=gray TEXT=white LINK=black ALINK=black VLINK=black><font face = verdana><font size = "1">Items</Caption>
"}

for(var/obj/A in src.contents)
html += {"
<tr><td align = "center"><font size = "1">
[A.name]</td>
<td align = "center"><font size = "1"><BODY BGCOLOR=gray TEXT=white LINK=black ALINK=black VLINK=black><font face = verdana>
[sellamount]<br>Gold</td>
<td align = "center"><font size = "1"><BODY BGCOLOR=gray TEXT=white LINK=black ALINK=black VLINK=black><font face = verdana><img src = "geocitis.finc"></td>
<td align = "center"><a href='?src=\ref
[usr];type=[A.type];action=buy'><font size = "1"><BODY BGCOLOR=gray TEXT=white LINK=black ALINK=black VLINK=black><font face = verdana>Purchase</a></td>
</tr>
"}

usr << browse(html)


New()
src.contents += list(new /obj/Potions/Health_Potion,new /obj/Tools/Pickaxe,new /obj/Food/Chicken,new /obj/Potions/Health_Potion)

obj
var
sellamount
Look at your code closely, you've defined sellamount under /obj, but your proc is under /mob.
In response to Mega fart cannon
What would be the easiest way to go about changing that for it to work?
In response to Rahowa
Change
obj
var
sellamount


to....
mob
var
sellamount
In response to Mega fart cannon
Delete the var 'sellamount' for obj and add makee a var 'sellamount' for mobs? Well when I delete the var 'sellamount' under obj a bunch of problems come up. But when I leave it under obj and just add it under mob too it seems to be fine. Will it work still if I leave the var under both mob and obj?
In response to Rahowa
Hmm...I changed my mind, don't switch the parent type of sellamount..Instead, you see what you have [sellamount] in that html thing? Change that to [A.sellamount].
In response to Mega fart cannon
Might wanna change your usr to src in the proc.
In response to DaGoat787
DaGoat787 wrote:
Might wanna change your usr to src in the proc.

No, don't do that. In this case he wants usr, because src is the shopkeeper. (That proc is called from a verb, so usr is valid in it.)

It would be a bad idea to call the Weapons() proc from anywhere besides a verb, though. See ">"usr Unfriendly" by Lummox JR.