Alright. Let me break it down for you. Let's start with the best place to start.
Code: Select all
"on_start" = [
money = 0
pie = 0
sword = 0
treasure = 0
]
I crack myself up sometimes.

Anyway, what this is doing is setting all inventory items to 0 at the start of the map. Next we have:
Code: Select all
"level_trigger_1" = [ money = ( + $money 5 )
echo "You got 5 moneys."
]
This makes it so that every time you hit an object assigned to level_trigger_1, you get 5 "moneys". Next:
Code: Select all
"level_trigger_2" = "showgui Shopkeeper"
This makes level_trigger_2, AKA the shopkeeper, talk. Now we've gotta make him say something, right?
Code: Select all
newgui Shopkeeper [
guitext "What're ya buyin, stranger?" chat
guibar
guilist [
guibutton "Pie: 10 moneys" [
if ( > $money 9 ) [
money = ( - $money 10 )
pie = ( + $pie 1 )
]
]
guibar
guibutton "Sword: 20 moneys" [
if ( > $money 19 ) [
money = ( - $money 20 )
sword = ( + $sword 1 )
]
]
guibar
guibutton "Treasure: 40 moneys" [
if ( > $money 39 ) [
money = ( - $money 40 )
treasure = ( + $treasure 1 )
]
]
]
]
This part gets a little tricky. First, it makes the shopkeeper say "What're ya buyin, stranger?". Then it shows a menu underneath. The menu has 3 items. Pie, sword, and treasure. Therefore, we must make buttons that tell the item and how much it costs. After we tell what the button says, you have to make it do something when it's pressed. For this, you have to make sure the player has enough money first. If so, your money decreases by the amount of the price and your item increases by 1. Now how do we view the inventory?
Code: Select all
newgui Inventory [
guibutton "Back" "cleargui 1"
guibar
guitext ( format "You have %1 moneys in your wallet." $money )
guitext ( format "You have %1 pies. Yum." $pie )
guitext ( format "You have %1 swords. Not that you can use them..." $sword )
guitext ( format "You have %1 treasures. Lucky you!" $treasure )
]
newgui main [
guilist [
guilist [
guibutton "Inventory" "showgui Inventory"
]
]
guibar
@main
]
First we need to define what the inventory will have in it. So first we put in a Back button for obvious purposes.

Next we have to tell the gui to put in some text telling what you have. So we use guitext to do that. Now hold it. You have to type format before your text for this to work. That way, it'll read the %1 as the item you specified right after the text. The last part of the code just puts the inventory button in the main menu.
Whew. That took a while.