Well first of all, it's rather unfair that you'd give an example like:
Code: Select all
//command
alias myalias [1]
//infix variant
myalias = [1]
Because, to be honest, I don't use it. Start with the basics.
Well, let's say you place down a pie. You really REALLY want to pick that pie up. When you first place it in edit mode there is a small box beneath the mapmodel. Looking at the box you should see several things, but at the moment lets focus on two things:
Trigger Type
Level_Trigger #
Trigger Type
Trigger types tell the engine which animation/sound/etc to run for the mapmodel. When the trigger type is 12, the pie would be picked up, disappearing from the ground in the process. Heres the entire list of trigger types and their functions:
Sandbox Mapping/Command Editing Reference
Level Trigger
Level trigger's are associated with coding. When I have a code that begins with level trigger 1, whatever comes after that (inside the brackets of course) responds solely to level trigger one.
Code: Select all
"level_trigger_1" = "showgui Friend"
newgui "Friend" [ <---Bracket
guitext "Hi I'm your friend!" chat
guitext "Want to talk?" chat
guibutton "Sure!" "showgui Friend_1"
guibutton "No. (close)" "cleargui"
]<--- Bracket
Now, if it was supposed to respond to picking up a pie, I'd set the Trigger Type on the pie to 12, but set my level_trigger to whatever the code was for either chatting about the pie, adding the pie to an inventory, etc.
Here's an example from the shop script:
Code: Select all
"on_start" = [ <----------Part one
money = 0
pie = 0
sword = 0
treasure = 0
]
"level_trigger_1" = [ money = ( + $money 5 ) <----------Part two
echo "You got 5 moneys."
]
"level_trigger_2" = "showgui Shopkeeper" <----------Part three
newgui Shopkeeper [ <---------- continuation of Part three
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 )
]
]
]
]
newgui Inventory [ <----------Part four
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
]
Part One
It looks like a lot, and it is. But I'll break it down.
Code: Select all
"on_start" = [
money = 0
pie = 0
sword = 0
treasure = 0
]
This bit of code shows what you own when you start. At the moment, you own nothing.
Part Two
Code: Select all
"level_trigger_1" = [ money = ( + $money 5 )
echo "You got 5 moneys."
]
This level trigger will be associated with ANY mapmodel with the level trigger 1. Note that it's not relating to any trigger type, but the level trigger. This bit of code basically says that money (A.K.A. whatever mapmodel you have set up for this) equals five moneys. Once you pick up the mapmodel (lets use a coin) it'll say "You got 5 moneys."
Part Three
Code: Select all
"level_trigger_2" = "showgui Shopkeeper"
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 code tells any mapmodel with the level trigger of 2 to show a dialogue window, therefore it's best to use a person/elf/ogre etc. Showgui "shopkeeper" is a basic code which tells the engine that what will follow is newgui "shopkeeper". This will bring up a new dialogue window (it's important to note that this is all to bring up the dialogue window for "What are ya buyin, stranger?")
The function "guilist" is the GUI command for bringing up a list (the buttons which allow you to buy items.) The bracket [ following the guilist means that anything that follows it inside the ] (the close bracket) is part of that list.
Code: Select all
guibutton "Pie: 10 moneys" [
if ( > $money 9 ) [
money = ( - $money 10 )
pie = ( + $pie 1 )
]
]
The GUI command guibutton creates a button has multiple abilities. In this case, it's to buy a pie This basically says: if you have more than 9 moneys, you can buy a pie for 10 moneys( if ( > $money 9 ) ). Now what comes in between the next two brackets. When you buy the pie, you will lose 10 moneys, but you will gain a pie. Experimentation for these type of values does help.
Each guibutton after the guilist is essentially the same, except that they have different values.
Part Four
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
]
I believe the first 3 lines are rather easy to understand, so I'll move onto the guitext.
This guitext is a format for showing numbers with each item (the items expressed with the "on_start" command).
Each line of text tells what percentage of 100 it has. So lets say you picked up 5 coins, it would show 5 coins in the inventory.
Showing the $money at the end means the engine knows what item has 5 coins. It's the same with each item. If there's any confusion please let me know! I want to make this as clear as possible
Arcones