ID:179956
 
When i buy an item from a shopkeeper, it used to go into an inventory tab, but when i put in my characters stats, the stat tab took it over, and i cant get both of them up there at the same time....whats the probleM?
Could you show the code for your stat panels?
In response to Foomer
Here..........

mob
var
HP=30
MaxHP=30
Defense=10
Strength=20
Kills=0
Exp=0
MaxExp=100
Level=1
Gold = 0
Speed = 25
KillerTabs = 0
MagicPoints = 0
MaxMagicPoints = 50
MagicPower = 15
MagicDefense = 5

mob
icon = 'killer.dmi'

Stat()
statpanel("Stats")
stat("Level",Level)
stat("HP","[src.HP]/[src.MaxHP]")
stat("Experience","[src.Exp]/[src.MaxExp]")
stat("Defense","[src.Defense]")
stat("Strength","[src.Strength]")
stat("Gold","[src.Gold]")
stat("Killer Tabs","[src.KillerTabs]")
stat("Magic Points","[src.MagicPoints]/[src.MaxMagicPoints]")
stat("Magic Power","[src.MagicPower]")
stat("Speed","[src.Speed]")
stat("Magic Defense","[src.MagicDefense]")
In response to RayJack
RayJack wrote:
Here..........

mob
var
HP=30
MaxHP=30
Defense=10
Strength=20
Kills=0
Exp=0
MaxExp=100
Level=1
Gold = 0
Speed = 25
KillerTabs = 0
MagicPoints = 0
MaxMagicPoints = 50
MagicPower = 15
MagicDefense = 5

mob
icon = 'killer.dmi'

Stat()
statpanel("Stats")
stat("Level",Level)
stat("HP","[src.HP]/[src.MaxHP]")
stat("Experience","[src.Exp]/[src.MaxExp]")
stat("Defense","[src.Defense]")
stat("Strength","[src.Strength]")
stat("Gold","[src.Gold]")
stat("Killer Tabs","[src.KillerTabs]")
stat("Magic Points","[src.MagicPoints]/[src.MaxMagicPoints]")
stat("Magic Power","[src.MagicPower]")
stat("Speed","[src.Speed]")
stat("Magic Defense","[src.MagicDefense]")


I don't see where you are making your inventory tab because any other statpanels have to be called under the same Stat proc because if the Stat proc is called more then once one statpanel will take over the other.
In response to Nadrew
well, when i just had the shopkeeper coding in, when i bought something it came up automaticaly, now that i have stats, it wont pop up anymore.....so, do i declare
Stat()
statpanel("Inventory")
somewhere in the shopkeeper coding or what?
In response to RayJack
RayJack wrote:
well, when i just had the shopkeeper coding in, when i bought something it came up automaticaly, now that i have stats, it wont pop up anymore.....so, do i declare
Stat()
statpanel("Inventory")
somewhere in the shopkeeper coding or what

See doing that would call the Stat() twice you can only call it once in your code here is a example

mob
var
Health=100
Stat()
statpanel("Stats")
stat("Health",Health)
statpanel("Items",src.contents)


That only calls the proc once and makes a Stats panel and a Items panel in one proc.
In response to Nadrew
YEah, i tried that, but instead of items, i called it inventory. But i still have a problem...when i buy items, they dont show up in my inventory tab
In response to RayJack
RayJack wrote:
YEah, i tried that, but instead of items, i called it inventory. But i still have a problem...when i buy items, they dont show up in my inventory tab

When buying the items do you have this:

usr.contents+=new/obj/Itemname

?
In response to Nadrew
no....
error: /obj/Itemname:bad path

where should i put it...Do you need to see the shopkeeper coding?
In response to RayJack
RayJack wrote:
no....
error: /obj/Itemname:bad path

where should i put it...Do you need to see the shopkeeper coding?


That would be helpful and Itemname was a example you should change that to the item you want to add.
In response to Nadrew
Stat()
statpanel("Inventory")
stat("Gold: ",usr.Gold)
for(var/obj/O in usr) stat(O)

obj/var/cost = 0


mob/shopkeeper/verb/buy()
set src = oview(1)
Buy() //call the Buy() proc and set up the deal


mob/shopkeeper/Wench
/*
Curly is a little crippled.
*/
icon = 'Wench.dmi'
icon_state = "Wench"

name = "Wenches"
welcome_message = "Wuddya Want!?"
goodbye_message = "Good riddens!"
continue_message = "Do you want anything else or what!!"
continue_answer = YES
cantafford_message = "You're obviously a Killer, because you sure as hell ain't no math teacher."
outofstock_message = "The other Killer that was here talkin crap about you took the last one honey..."

obj
Armor
icon = 'Armor.dmi'
Armor
icon_state = "Armor"
cost = 20

mob/shopkeeper/Peasent
/*
Moe's just a bit odd.
*/
icon = 'Peasent.dmi'
icon_state = "Joe"

name = "Store"
welcome_message = "Yo killa, wuddya want?"
goodbye_message = "Hey, while ur gone,...you think you can pick me up some deoderant...I'm out."
continue_message = "You want anything else, Im missin' my stories!"
continue_answer = YES
else_message = "OK"
cantafford_message = "GET THE HELL OUT!"
outofstock_message = "I'm outta them."

obj
Weapon
icon = 'IcePick.dmi'
IcePick
icon_state = "Pick"
cost = 50
obj
Aaxe
icon = 'Aaxe.dmi'
Aaxe
icon_state = "Aaxe"
cost= 25


//Constant variables.
//These just make it so you type YES or NO
//instead of the "Y" or "N". This way you
//can avoid spelling errors more easily.
var/const/YES = "Y"
var/const/NO = "N"

mob/shopkeeper
var/welcome_message = "Hello!"
var/goodbye_message = "Goodbye!"
var/continue_message = "Would you like anything else?"
var/continue_answer = YES
var/else_message = "What else?"
var/cantafford_message = "I'm sorry, you don't have enough money."
var/afford_message = "Thank you!"
var/outofstock_message = "I'm sorry, we're out of stock right now."

New()
..()

//Look at every obj in my location, and add it to my inventory
spawn(1) for(var/obj/O in src.loc) O.loc = src


proc/Buy()
if(!src.contents.len)
alert(outofstock_message)
return

var/continuing
//If they want to continue, or just got here, start the loop
while((!continuing) || (continuing == continue_answer))

//When they first enter the store, the message is a 'welcome_message'. Once they have
//bought something and they say they would like to buy something else, the message
//changes to the 'else_message'.
var/greeting = else_message
if(continuing != continue_answer)
greeting = welcome_message

//Add all of the objects to a 'associative' list of the inventory. This way, any
//inventory item that is bought can be accessed using inventory["itemname - itemcost"].
//Eg. inventory["longsword - 25 gold"] will access the longsword obj in the shopkeeper.
var/inventory[0]
for(var/obj/O in src)
if(!O.cost)
inventory["[O.name] - [O.cost] gold"] = O //let the user know that it is free.
else
inventory["[O.name] - [O.cost] gold"] = O //if it has a price, tell them how much.

//Now, make a list for the input proc that contains all of the items and their costs
var/inventory_strings[0]
for(var/obj/O in src)
if(!O.cost)
inventory_strings += "[O.name] - FREE"
else
inventory_strings += "[O.name] - [O.cost] gold"

//All right! Now that that is settled, ask the user what they would like.
var/choice = input(greeting,src.name) as anything in inventory_strings+"Nothing"

//If they don't want anything, skip the purchase stuff and exit the loop
if(choice == "Nothing") continuing = " " //any value except null and YES or NO works

else //They're buying something!
var/obj/item = inventory[choice] //Access the item (see above)
if(usr.Gold >= item.cost) //if they can afford it
usr.Gold -= item.cost //subtract the cost from their money
new item.type(usr) //create a new one inside the player
alert(afford_message) //and say thanks.
else //but, if they can't afford it
alert(cantafford_message) //tell them.

//Ask the player if he wants to buy anything else.
//Note that the answer is based off of the continue_answer variable. For example:
// "Is that all?" should be answered with a NO to keep going
// "Want anything else?" should be answered with a YES to keep going
var/OK = alert(continue_message,src.name,"Yes","No")
switch(OK)
if("Yes") continuing = YES
if("No") continuing = NO

//Loop starts over, or ends, here


//Now that the loop is over,
alert(goodbye_message)
In response to RayJack
Well this is a library and at the top you are calling the stat proc and its a great lib but it can interfer with other code (why I don't use libs) and this is mainly all you need:
mob
var
Health=100

Stat()
statpanel("Stats")
stat("Health",Health)
statpanel("Inventory",contents)
mob/ShopKeeper
icon='Shopkeeper.dmi'
verb/Buy()
set src in oview(1)
usr.contents+=new/obj/Itemname

NOTE:Don't use the /obj/Itemname path use your own obj path.
NOTE 2:Learn how the library actually works before trying to add new things to it.
In response to Nadrew
dm:10:error:var/contents:bad var
.dm:8:error:Stat :undefined proc
In response to RayJack
RayJack wrote:
dm:10:error:var/contents:bad var
.dm:8:error:Stat :undefined proc


So me the code you're using now I see no need to define the cotents var because it is a build in var of DM and as for the Stat bad proc this maybe where it is placed in the code file and/or how it is indented.
In response to Nadrew
Nadrew wrote:
Well this is a library and at the top you are calling the stat proc and its a great lib but it can interfer with other code (why I don't use libs)

It interferes with other code because it is a poorly made library. If you have to make many modifications to make it interface with someone elses game, it should be a demo instead. Look at Spuzzum's and especially Deadron's libraries for examples of what libraries should be.

In the case of this library, all the designer would have had to do is add ..() to the Stat() code and perhaps instruct users to add a ..() to their own Stat() procs, depending on where the code gets included.
In response to Nadrew
Nadrew wrote:
See doing that would call the Stat() twice you can only call it once in your code here is a example
That only calls the proc once and makes a Stats panel and a Items panel in one proc.

Incorrect, you can spread Stat() over several locations in your code as long as you tell it to run the pre-existing code as well. You do that with the ..() instruction.

In each Stat() proc, add the line
..()
(indent it properly, of course), so that it doesn't overide the other Stat() proc.
In response to Shadowdarke
Shadowdarke wrote:
Nadrew wrote:
Well this is a library and at the top you are calling the stat proc and its a great lib but it can interfer with other code (why I don't use libs)

It interferes with other code because it is a poorly made library. If you have to make many modifications to make it interface with someone elses game, it should be a demo instead. Look at Spuzzum's and especially Deadron's libraries for examples of what libraries should be.

In the case of this library, all the designer would have had to do is add ..() to the Stat() code and perhaps instruct users to add a ..() to their own Stat() procs, depending on where the code gets included.


I believe that is actually Spuzzum's shope keeper code.
In response to Shadowdarke
Shadowdarke wrote:
Nadrew wrote:
See doing that would call the Stat() twice you can only call it once in your code here is a example
That only calls the proc once and makes a Stats panel and a Items panel in one proc.

Incorrect, you can spread Stat() over several locations in your code as long as you tell it to run the pre-existing code as well. You do that with the ..() instruction.

In each Stat() proc, add the line
..()
(indent it properly, of course), so that it doesn't overide the other Stat() proc.


Wow,I guess I learn something new everyday,that will have to go into my next library update thanks Shadow that was helpful to me also.
In response to Nadrew
Nadrew wrote:
I believe that is actually Spuzzum's shope keeper code.

Spuzzum's shop keeper code is a demo, not a library ;) Demo's aren't meant to be plug'n'play. They teach you ideas and techniques.