how to make a money condition

ok player character has 100 dollars in the money area of the player tab..

in the shop there is a wrapped meatbun that costs 10 and a jar of tea that cost 15 etc

i type buy it said cant buy it when i made a verb buy;purchase but i cant make use of the price part in this matter there is no conditions for money on quest lie ifs
like if player has the right amount or not....


What I did was create a function that handled it in a library.

Here's the basic code for it though. Just create a library and place it inside. Don't forget to add the library to the game too! Also, just fill in the name of the items (Item 1, for example, with the name of the item you want the player to buy).

<function name="Shop"><![CDATA[
  ClearScreen
 menulist = Split("Item 1 Here;Item 2 Here;Item 3 Here", ";")
ShowMenu ("", menulist, true) {
if (result = "Item 1 Here") {
msg ("<br/>{color:mediumturquoise:\"Hm...4 gold for that.\"}<br/><br/>Would you like to buy this?")
menulist = Split("Yes;No", ";")
ShowMenu ("", menulist, true) {
if (result = "Yes") {
if (player.gold >= 4) {
msg ("<br/>You toss the shop owner the gold{random: and then take the item in hand:}. ")
CloneObjectAndMove (Item 1, player)
player.gold = player.gold - 4
UpdateAllAttributes
Shop
}
else {
msg ("<br/>You don't have enough.")
wait {
UpdateAllAttributes
Shop
}
}
}
else if (result = "No") {
UpdateAllAttributes
Shop
}
}
}
else if (result = "Item 2 Here") {
msg ("<br/>{color:mediumturquoise:\"Hm...2 gold for that.\"}<br/><br/>Would you like to buy this?")
menulist = Split("Yes;No", ";")
ShowMenu ("", menulist, true) {
if (result = "Yes") {
if (player.gold >= 2) {
msg ("<br/>You toss the shop owner the gold{random: and then take the item in hand:}. ")
CloneObjectAndMove (Item 2, player)
player.gold = player.gold - 2
UpdateAllAttributes
Shop			
}
else {
msg ("<br/>You don't have enough.")
wait {
UpdateAllAttributes
Shop
}
}
}
else if (result = "No") {
UpdateAllAttributes
Shop
}
}
}
else if (result = "Item 3 Here") {
msg ("<br/>{color:mediumturquoise:\"Hm...2 gold for that.\"}<br/><br/>Would you like to buy this?")
menulist = Split("Yes;No", ";")
ShowMenu ("", menulist, true) {
if (result = "Yes") {
if (player.gold >= 2) {
msg ("<br/>You toss the shop owner the gold{random: and then take the item in hand:}. ")
player.gold = player.gold - 2
CloneObjectAndMove (Item 3, player)
UpdateAllAttributes
Shop
}
else {
msg ("<br/>You don't have enough.")
wait {
UpdateAllAttributes
Shop
}
}
}
else if (result = "No") {
UpdateAllAttributes
Shop
}
}
}
}
UpdateAllAttributes
]]></function>

Hopefully it helps!

Anonynn.


@anonynn
um it keeps giving me an error i should tell you im not on the software im on the site....
cant get it im on chromebook


What kind of error are you getting?

Keep in mind, the code doesn't go into the game itself but a separate library. In the game itself, you type/code Shop wherever the code for your shop is and it should call the function that contains the shop :)

Anonynn.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums