Page 1 of 2

Cubescript Basics

Posted: November 23rd, 2010, 4:10 pm
by DaGeek247
Hey, first off, how do i remove the user of my game ability to go into edit mode? the following code was my best attempt to fix it, but it fails.

Code: Select all

//below keeps user from entering edit mode. to bad it doesnt work.
editbind "E" [if (&& (= $shiftkey 0) (= $ctrlkey 0)) [echo "Whoops! No cheating!!!"]
	if (&& (= $shiftkey 0) (= $ctrlkey 1)) [echo "Whoops! No cheating!!!"]
	if (&& (= $shiftkey 1) (= $ctrlkey 0)) [echo "Whoops! No cheating!!!"] 
	if (&& (= $shiftkey 1) (= $ctrlkey 1)) [echo "Whoops! No cheating!!!"]]
How do I get it to work?

Secondly, How does the basic syntax of variables in cubescript work? I want for a chest trigger to set a variable, and echo something. I got the echo part to work, but i have no idea how variables work here. How do I
A. Set a variable
B. Echo or use the contents of a variable?

thirdly, (and lastly) how do if statements in cubescript work? I have a trigger type 9 door, and i want it to open ONLY if a variable has been set by the trigger. how do i do this?

Any help would be MOST appreciated.

Re: Cubescript Basics

Posted: November 23rd, 2010, 5:32 pm
by arcones
Here are two tutorials for removing edit mode: (I prefer the first one)
Tutorial for removing edit mode
Removing edit mode

Geek, please check out other posts concerning Cubescript as I've already answered this question. Also, there is a tutorial for Cubescript that has several links attached to it ;)

Arcones

Re: Cubescript Basics

Posted: November 23rd, 2010, 7:32 pm
by chocolatepie33
for #2 and #3, with variables, you initialize them with the "on_start = [" command, then you can use guibuttons and level triggers to add to them.
Here's an example code:

Code: Select all

on_start = [
money = 0
]

level_trigger_1 = [showgui CP]
newgui CP [
guitext "Would you like 5 dollars?"
guibar
guibutton "Sure." [ money = ( + $money 5 ) ; cleargui]
guibutton "Nah, I'm fine." [cleargui]
]

level_trigger_2 = [ money = ( + $money 500 ) ]         // a bag of coins
with #3, to do something like that (I'm surprised Arc didn't say this, I think I got this from him a bit ago), it's something like this:

Code: Select all

level_trigger_3 = [ if ( > $key 0 ) [ trigger 3 1 ; key = ( - $key 1 ) ] ]
the first number after trigger (3) is the level trigger. The 1 is a boolean value, meaning it is true or false. The 1 lets the door open. An elevator has a code of 1, 0, or -1. 1 starts an elevator up, 0 stops it, and -1 makes it go down, like a sideways number line.

Re: Cubescript Basics

Posted: November 23rd, 2010, 7:53 pm
by arcones
Aye,

@Geek here's a by far the best example of syntax I have ever seen for CS.
Shop Script Example

@CP, you probably did get it from me, but I got it from the shop script. And Chocolate, the reason I keep giving people sites to learn CS, is because until they do, they'll continually come back for help. This topic right here kinda explains why: Scripting

Anyway, there are tons of Support questions about CS, so just keep checking and I'm sure you'll see more answers for your questions.

Re: Cubescript Basics

Posted: November 24th, 2010, 9:14 am
by DaGeek247
one last question, how do remove edit mode from only ONE game?

Re: Cubescript Basics

Posted: November 24th, 2010, 9:26 am
by arcones
What do you mean?

For one map, or if you wanted to post a standalone game and remove the edit mode for that?

Re: Cubescript Basics

Posted: November 27th, 2010, 9:17 pm
by DaGeek247
no. how would i remove edit mode in one map via cubescript in the cfg file? that was my REAL question.

Re: Cubescript Basics

Posted: November 27th, 2010, 9:29 pm
by chocolatepie33
so, you're taking it out of one map, not out of all of Sandbox, right?

Re: Cubescript Basics

Posted: December 2nd, 2010, 2:13 pm
by DaGeek247
yes, that is correct.

Re: Cubescript Basics

Posted: December 2nd, 2010, 5:33 pm
by arcones
Actually, it's better if it's a game (with multiple maps) to just extract the program as a game itself instead of just trying to lock-out edit mode in one map. Someone can always go into the map.cfg and delete the code that doesn't allow editing.

All the maps thus far posted on this forum have allowed edit mode (even some maps that were puzzle/adventure maps). So, unless it is a game, it's best to just leave it.