Page 1 of 2

List of scripting commands

Posted: June 7th, 2010, 5:45 am
by Venima
Any mode:

Declaring/modifying variables
number1 = 0 //variable "number1" now exists and becomes the value of 0
number1 = (+ $number1 2) //variable "number1" is increased by 2
number1 = (- $number1 $number2) //variable "number1" is decreased by variable "number2"

Mapmodel & Entity commands
level_trigger_3 = [] //when approaching mapmodels with trigger tags of 3, carries out the script within the square brackets []
trigger 2 1 //mapmodels with trigger tags of 2 will carry out an animation based on their trigger types (uses numbers ranging from -1 to 1) Trigger Types List
platform 4 1 //platforms with a tag of 4 will move forward (-1 backward, 0 stop, 1 forward)
platform 4 1 //elevators with a tag of 4 will move up (-1 down, 0 stop, 1 up)
part_text_2 = "Enter here to begin." //particles with type "text" and alias 2 will display "Enter here to begin."

Guis
newgui Hello [] //creates a new gui window like the one when hitting Esc, scripting name for the gui is "Hello", displayed name is same as scripting name
newgui Hello [] "Stranger" //same as above except the displayed name is "Stranger"
guitext "Hello and welcome to sandbox script list." //adds text to the gui window showing "Hello and welcome to sandbox script list."
guitext "Hello and welcome to sandbox script list." chat //same as above however the icon to the left of the text is a chat bubble.
guibutton "Continue" "" //adds a button to the gui window displaying "Continue" and carries out the script in the second pair of quotation marks ""
guibutton "Continue" [] //same as above only carries out the script within the square brackets []
guilist [] //creates a vertical bar that allows you to create a list, script within that list is within the square brackets []
guibar //adds a bar to the gui window.
showgui Hello //will trigger newgui Hello
cleargui //removes all gui windows that are open
cleargui 2 //goes back 2 gui windows (e.g. from Hello3 back to Hello1)

Handy side commands
echo "Wow this works!" //displays "Wow this works!" in the top-left corner of the screen/window.
if (> $number1 4) [] //if variable "number1" is more than 4, then the script in the square brackets is carried out []
if (= $number1 $number2) [] [] //if variable "number1" is equal to variable "number2", then the script in the first square brackets is carried out, otherwise the script in the second square brackets is carried out
sleep 1000 [] //waits 1000 milliseconds before carrying out the script within the square brackets []
music "filepath+filename" //plays music from the filepath and name given inside the quotation marks ""
In place of quotation marks for text you can have: (format "You have %1 gold and %2 silver" $countgold countsilver) //after "guitext" for example, say countgold was 3 and countsilver was 5, it would display "You have 3 gold and 5 silver"

Anything you can write in console with a forward slash can be used in the map script without one. Note: for console commands that are editmode only, you have to save and load the map again before it lets you use them in the map script.

code example:

Code: Select all

level_trigger_1 = [
	showgui Hello
]

newgui Hello [
	guitext "Hello and welcome to the script list." chat
	guitext "Would you like some help?" chat
	guibar
	guibutton "Yes" "showgui Hello_Yes"
	guibutton "No" "cleargui"
]
Trigger Types List

Re: List of scripting commands

Posted: June 7th, 2010, 9:16 am
by arcones
That type of script is pretty much what I had. However I noticed this:
Venima wrote:newgui Hello [] "Stranger" //same as above except the displayed name is "Stranger"
So I'd basically be placing it after the gui's and before the last bracket?

Code: Select all

    level_trigger_1 = [
       showgui Hello
    ]

    newgui Hello [
       guitext "Hello and welcome to the script list." chat
       guitext "Would you like some help?" chat
       guibar
       guibutton "Yes" "showgui Hello_Yes"
       guibutton "No" "cleargui"
    ]

newgui "Hello_Yes" [
  guitext "Now once I place the stranger part after the" chat
  guitext "brackets, it'll appear?"
  guibar
  guibutton "Yes." "showgui Yes"
  guibutton "No." "showgui No"
] stranger //do I place it before or after the bracket?

Re: List of scripting commands

Posted: June 8th, 2010, 7:48 pm
by Venima
you place it here:

Code: Select all

newgui "Hello_Yes" [
  guitext "Now once I place the stranger part after the" chat
  guitext "brackets, it'll appear?"
  guibar
  guibutton "Yes." "showgui Yes"
  guibutton "No." "showgui No"
] "stranger"
The quotes around it are essential.

Re: List of scripting commands

Posted: June 8th, 2010, 8:01 pm
by Venima
Here's a great example of some simple but complex looking code:

By all means try it out. Level_trigger_1 should be an rpg character with trigger type 27.

Code: Select all

coins = 20
gChoice = 0
gTenMugs_Badmug = 0
gBet = 0
gTenMugs_RightGuesses = 0
gTenMugs_1 = 0
gTenMugs_2 = 0
gTenMugs_3 = 0
gTenMugs_4 = 0
gTenMugs_5 = 0
gTenMugs_6 = 0
gTenMugs_7 = 0
gTenMugs_8 = 0
gTenMugs_9 = 0

level_trigger_1 = [showgui Gamer1-1]

newgui Gamer1-1 [
	guitext "Wanna play a game?" chat
	guibar
	guibutton "Sure!" "showgui Gamer1-2" chat
	guibutton "Not right now thanks." "cleargui" chat
] "Bramier"
newgui Gamer1-2 [
	guitext "It's called Ten mugs..." chat
	guibar
	guibutton "Sure!" "showgui Game_TenMugsStart" chat
	guibutton "What is it?" "showgui Gamer1-3" chat
	guibutton "Sorry I've got to go now." "cleargui" chat
] "Bramier"
newgui Gamer1-3 [
	guitext "Well..." chat
	guitext "First of all you bet a certain amount of coins, say 10." chat
	guitext "You have to pay a 5th in advance." chat
	guitext "I then put a coin under 9 mugs of 10 and rotate them around." chat
	guitext "If you guess a mug with a coin under it, you get a 10th of what you bet for." chat
	guitext "If you guess a mug with nothing under it, I get the rest of your bet and the" chat
	guitext "game ends there." chat
	guitext "You can keep guessing mugs until you don't wish to continue." chat
	guitext "Remember you only have to pay your bet if you guess wrongly." chat
	guibar
	guibutton "I think I've got it." "showgui Gamer1-4" chat
	guibutton "Sorry I've got to go now." "cleargui" chat
] "Bramier"
newgui Gamer1-4 [
	guitext "So you wanna play?" chat
	guibar
	guibutton "Sure!" "showgui Game_TenMugsStart" chat
	guibutton "No thanks." "cleargui" chat
] "Bramier"

newgui Game_TenMugsStart [
	if (> $coins 9) [
		guitext "How much do you want to bet?" chat
		guitext (format "You have %1 coins." $coins)
		guibar
		guilist [
			guibutton "10 coins." [
				gBet = 10
				gTenMugs_BadMug = (rnd 10)
				coins = (- $coins 2)
				showgui Game_TenMugs1
			] chat
			if (> $coins 19) [
				guibar
				guibutton "20 coins." [
					gBet = 20
					gTenMugs_BadMug = rnd 10
					coins = (- $coins 8)
					showgui Game_TenMugs1
				] chat
			] []
		]
		guilist [
			if (> $coins 49) [
				guibutton "50 coins." [
					gBet = 50
					gTenMugs_BadMug = rnd 10
					coins = (- $coins 20)
					showgui Game_TenMugs1
				] chat
			] []
			if (> $coins 99) [
				guibar
				guibutton "100 coins." [
					gBet = 100
					gTenMugs_BadMug = rnd 10
					coins = (- $coins 40)
					showgui Game_TenMugs1
				] chat
			] []
		]
		guibar
		guibutton "Sorry I've got to go now." "cleargui" chat
		gTenMugs_1 = 10
		gTenMugs_2 = 10
		gTenMugs_3 = 10
		gTenMugs_4 = 10
		gTenMugs_5 = 10
		gTenMugs_6 = 10
		gTenMugs_7 = 10
		gTenMugs_8 = 10
		gTenMugs_9 = 10
		gTenMugs_RightGuesses = 0
		RN2 = 0
	] [
		guitext "You don't have enough coins to play." chat
		guitext (format "You only have %1 coins" $coins) chat
		guitext "Come back when you have 10 coins." chat
		guibar
		guibutton "Oh, ok." "cleargui" chat
	]
] "Ten Mugs"
newgui Game_TenMugs5 [
	guitext "Another round?" chat
	guibar
	guibutton "Sure!" [
		showgui Game_TenMugsStart
	] chat
	guibutton "Sorry I've gotta go." "cleargui" chat
] "Ten Mugs"
newgui Game_TenMugs4 [
	guitext "That mug doesn't have a coin under it, too bad." chat
	guibar
	guibutton "Damn. Ah well." [
		//RN = (* $gBet 0.4)
		//RN2 = (- $gBet $RN)
		//coins = (- $coins $RN2)
		coins = (- $coins 8)
		showgui Game_TenMugs5
	] chat
] "Ten Mugs"
newgui Game_TenMugs3 [
	guitext "You have already chosen this mug. Choose another one." chat
	guibar
	guibutton "Oops... ok." "cleargui 2" chat
] "Ten Mugs"
newgui Game_TenMugs2 [
	if (= $gChoice $gTenMugs_1) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_2) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_3) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_4) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_5) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_6) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_7) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_8) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_9) [showgui Game_TenMugs3] 	[
		if (= $gChoice $gTenMugs_BadMug) [showgui Game_TenMugs4] [
			RN3 = (+ $RN2 1)
			guitext "That mug has a coin under it, well done!" chat
			guitext (format "So far you have earnt %1 coins." $RN3) chat
			guibar
			guibutton "Ok." [
			//RN = (* $gBet 0.1)
			//coins = (+ $coins $RN)
			coins = (+ $coins 1)
			RN2 = (+ $RN2 1)
			gTenMugs_RightGuesses = (+ $gTenMugs_RightGuesses 1)
			if (= $gTenMugs_RightGuesses 1) [gTenMugs_1 = $gChoice] []			
			if (= $gTenMugs_RightGuesses 2) [gTenMugs_2 = $gChoice] []	
			if (= $gTenMugs_RightGuesses 3) [gTenMugs_3 = $gChoice] []	
			if (= $gTenMugs_RightGuesses 4) [gTenMugs_4 = $gChoice] []	
			if (= $gTenMugs_RightGuesses 5) [gTenMugs_5 = $gChoice] []	
			if (= $gTenMugs_RightGuesses 6) [gTenMugs_6 = $gChoice] []	
			if (= $gTenMugs_RightGuesses 7) [gTenMugs_7 = $gChoice] []
			if (= $gTenMugs_RightGuesses 8) [gTenMugs_8 = $gChoice] []	
			if (= $gTenMugs_RightGuesses 9) [gTenMugs_9 = $gChoice] []	
			cleargui 1] chat
		]
	]]]]]]]]]	
] "Ten Mugs"
newgui Game_TenMugs1 [
	//RN = (* $gBet 0.4)
	//RN2 = (* $gTenMugs_RightGuesses $gBet)
	//RN2 = (* $RN2 0.1)
	RN3 = (- 9 $gTenMugs_RightGuesses)

	// Temporary
	RN = 2
	guitext (format "Coins given in advance: %1, Coins earnt: %2" $RN $RN2) chat
	guibar
	guitext (format "There are %1 good choices left." $RN3) chat
	guibar
	guilist [
		guibutton "1" [
			gChoice = 0
			showgui Game_TenMugs2
		] chat
		guibar
		guibutton "2" [
			gChoice = 1
			showgui Game_TenMugs2
		] chat
		guibar
		guibutton "3" [
			gChoice = 2
			showgui Game_TenMugs2
		] chat
		guibar
		guibutton "4" [
			gChoice = 3
			showgui Game_TenMugs2
		] chat
		guibar
		guibutton "5" [
			gChoice = 4
			showgui Game_TenMugs2
		] chat
	]
		guibar
	guilist [
		guibutton "6" [
			gChoice = 5
			showgui Game_TenMugs2
		] chat
		guibar
		guibutton "7" [
			gChoice = 6
			showgui Game_TenMugs2
		] chat
		guibar
		guibutton "8" [
			gChoice = 7
			showgui Game_TenMugs2
		] chat
		guibar
		guibutton "9" [
			gChoice = 8
			showgui Game_TenMugs2
		] chat
		guibar
		guibutton "10" [
			gChoice = 9
			showgui Game_TenMugs2
		] chat
	]
	guibar
	guibutton "I'll leave it there." "showgui Game_TenMugs5" chat
	guibutton "Sorry I've got to go now." "Game_TenMugsGottaGo" chat
] "Ten Mugs"
newgui Game_TenMugsGottaGo [
	if (< $gTenMugs_RightGuesses 2) [
		guitext "You've barely even started, here have your coins back." chat
		guibar
		guibutton "Thanks." [
			//RN = (* $gBet 0.4)
			//coins = (+ $coins $RN)
			//RN2 = (* $gBet 0.1)
			//RN3 = (* $gTenMugs_RightGuesses $RN2)
			coins = (+ $coins 2)
			//coins = (- $coins $RN3)
			coins = (- $coins $gTenMugs_RightGuesses)
			cleargui
		] chat
	] [cleargui]
] "Ten Mugs"

Re: List of scripting commands

Posted: June 8th, 2010, 9:30 pm
by Hirato
that's by no means a great example.
The code in question can still be simplified a lot.
  • When placing the bet, you can create those options through the use of a loop, and iterate though a list of the bets. betlist = "10 20 50 100" loop i (listlen $betlist) [create buttons here]
  • losing the round only takes 8 coins, the rules state it needs the other 4/5 of your bet
  • Don't list the mugs they've already chosen, this will greatly simplify the second GUI
  • choosing the mug can also be simplified through a loop: loop i 10 [] (remember the @ tokens, see our wiki)
otherwise, good work :)

Re: List of scripting commands

Posted: June 9th, 2010, 5:15 am
by Venima
When I made it I wasn't familiar with the loop yet, and I can't be bothered to change the code XD

At least people will understand it easily. :P

Re: List of scripting commands

Posted: June 9th, 2010, 8:25 am
by arcones
Uh huh, makes perfect sense V... :roll:

Code: Select all

newgui Game_TenMugs2 [
   if (= $gChoice $gTenMugs_1) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_2) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_3) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_4) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_5) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_6) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_7) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_8) [showgui Game_TenMugs3] [if (= $gChoice $gTenMugs_9) [showgui Game_TenMugs3]    [
      if (= $gChoice $gTenMugs_BadMug) [showgui Game_TenMugs4] [
Once I got to this, I basically quit :lol: I understand how the name works tho' Thanks for the tip! :)

Re: List of scripting commands

Posted: August 15th, 2010, 7:05 pm
by chocolatepie33
Maybe you should learn C++, Arc... I only know the basics, but this makes sense to me...
To me right now, Cubescript looks like (or maybe is actually) C++.
It shares with C++ :
  • If statements (If X = #, then action)
    Variable declaration (int X = 5 )
    Output (in C++, it's called cout, here, it's guitext)
    Pointers (Don't know enough to show you)
Just to name a few...
The one thing I haven't seen yet with Cubescript is input...
for example, C++ has the cin function, which is like (cin >> number) if number is a declared integer.
With that, you type it in. With cubescript, there's clickable guibuttons, but those make for limited options.
The only example is the "first time with PAS? type in your name." And I don't know how to make that.
Tutorial, anyone?

Re: List of scripting commands

Posted: September 1st, 2010, 7:49 pm
by chocolatepie33
Okay, never mind, I found it!
It's the complicated thing called a guifield. (Don't ask me how to use it, though.)

Re: List of scripting commands

Posted: November 20th, 2010, 9:21 am
by Grafman
Thanks for posting this for this is the first time I have seen the trigger list. Again, I am very new to Sandbox. I am taking a class at our community college in C Programming - so some of this looks familiar.

Can you tell me if there are any more quests (besides the baker and apple in the village map)? The trigger list mentioned something about a carrot...

I am hoping to have my students make a game for pre-school kids that the kids will go around a map and pick-up certain objects (mapmodels?) like fruits and vegetables (let's say a tomato) and when they Pick up the objects the response would be "This is a tomato" --- appreciate the help, Happy Thanksgiving!
grafman