You are on page 1of 7

NOTE: These 'help' scripts are non-functional.

They are just text provided to help you understand how ShockScript works.

ShockScript is a scripting engine for Flash written by me, Shock Value. It allows you to write your own scripts to make events occur in the gameworld. For example, you might write a script that causes an explosion to occur if the Buddy touches a wall. Or you might write a script that shoots a continuous stream of baseballs at the Buddy. (Both of these examples are provided as sample scripts, among others.) It's all up to you.

However, to get these results, you must familiarize yourself with the language. **This is not a functional script.**

These help files assume that you have at least a basic understanding of programming concepts. If you are familiar with Flash Actionscript or JavaScript, you should have no problem. If you are new to programming, then you will need to learn basic programming concepts first, which is knowledge that is outside the scope of these help files. **This is not a functional script.**

Expressions are written just as they are in Actionscript or Javascript.

1+2 evaluates to 3. 1+2*3 evaluates to 7. (3*(8-6)-2)*(3+3) evaluates to 24. **This is not a functional script.**

ShockScript includes all of the operators that are available in Actionsript and uses the same precedence rules as ActionScript uses.

* : multiplication / : devision % : modulo + : addition and string concatenation - : subtraction << : bitwise left shift >> : bitwise right shift >>> : bitwise unsigned right shift < : less than <= : less than or equal to > : greater than >= : greater than or equal to == : equal to != : not equal to & : bitwise AND ^ : bitwise XOR | : bitwise OR && : logical AND || : logical OR

The operators above are ordered by decreasing precedence.

myVar = 1+2;

'myVar' now holds the value '3'.

anotherVar = "variable number "+2; 'anotherVar' now holds the string "variable number 2" thirdVar = 1+myVar*2; 'thirdVar' now holds the value '7'

Variables can also be assigned by using the assign(varName,expression) function, which will be explained later. **This is not a functional script.**

Semicolons (;) seperate lines of code and MUST be used. This is unlike Actionscript, which recognizes line breaks as well as semicolons as ending lines of code.

Example:

myVar = "Hello!"; trace(myVar); setGrav(0) **This is not a functional script.**

Functions can be used as follows:

someFunction(argument1,argument2)

You cannot define your own functions; you must use the built in ones. However, there are many built in functions which are listed on the following help page. You can use functions anywhere an expression is used, just like in ActionScript. **This is not a functional script.**

say(text,time) explode(x,y,power) 1.0 is about normal for power create(objectType,x,y,xVelocity,yVelocity) valid objectType strings: "baseball", "molotov", "bowlball", "bouncyball", "grenade", "fireball", "mine", "baby", "orb", "radio", "vortex". Returns the unique objectName assigned to the object you created. destroy(objectName) removes specified object (if destructable) noAutoDelete(objectName) makes specified object not be auto deleted when adding more objects; note that it can still be destroyed through destroy() function or through a mousover when a throwing item is selected addConstraint(objectName,x,y,len) adds a constraint to specified target (objectName) at x, y of length len; constraint is removed when object is deleted addSpring(objectName,x,y,strength) similar to addConstraint, except with a flexible attachment; strength can be between 0.0-1.0, but lower numbers (like .05) work best resetForces() resets all added forces (constraints, springs, etc.) flashMessage(text, timeInFrames) water(x, y, xv, yv, lifeSpanInFrames, strength, spread, size, disappearOnContact) fireClip(x, y, xv, yv, lifeInFrames, scale) about 4.0 is normal for scale addBuddyVel(x,y) setBuddyVel(x,y) setBuddyPos(x,y) addBuddyRot(rotationAmount) setBuddyRot(angleRadians) getBuddyRot() getBuddyX()

getBuddyY() getEmotion() returns happiness of buddy from -100.0 to 100.0 getXV(objectName) returns x velocity of object, valid strings for objectName: "body", "rArm", "lArm", "rLeg", "lLeg", plus all strings returned by 'create' function (see ex-throwableBall) getYV(objectName) ... y velocty ... getX(name) ... x position ... getY(name) ... y position ... playSound(soundName) resetVariables() resets all user variables pow(x,y) returns x to the y power sin(x) cos(x) tan(x) atan(x) atan2(x,y) max(x,y) returns greater value min(x,y) returns lesser value sign(x) returns -1 if negative, 0 if 0, 1 if positive random() returns random floating point, 0.0 to 1.0 randomBet(x,y) returns random floating point between x and y sqrt(x) ceil(x) floor(x) round(x) pi() returns pi (3.14159...) e() returns e

asin(x) acos(x) abs(x) absolute value charAt(string,letterPosition) bnot(x) returns false if x is true, true if x is false bor(x,y) logical OR (same as x||y) band(x,y) logical AND (same as x&&y) above(x,y) returns true if x is greater than y, else false (same as x>y) below(x,y) x<y equal(x,y) x==y sqr(x) returns x*x exp(x) returns e to the x log(x) gettime() returns time since movie start, in seconds getXMouse() getYMouse() getMouseDown()

assign(myVar,value) Same as writing 'myVar = value'. Note that the first argument of the funtion is not a string, it is the exact text that you write. You would use this function like this: assign(x,10); which would set variable 'x' to '10'.

evaluate(scriptText) This function allows you to evaluate text as if it were ShockScript code. Example: 'evaluate("x = "+10)' would evaluate 'x = 10' and thus set variable 'x' to '10'.

firstRun() This function returns true on the first run of your code when 'Run Every Frame' is checked, and false on every other run. If you click 'Run Once', it is also true for that run. When writing scripts, be sure that they conform to general coding standards and those listed above. ShockScript has little to no error detection, so erroneous scripts might compile and run with unexpected results. In Flash, syntax errors are recognized by the compiler automatically, but again, in ShockScript this is not the case.

The reason ShockScript has no error detection is simple--I just don't have to time to write it in. The process would be difficult and full of bugs. And it would never be perfectly consistant, so I wouldn't want people to rely on it. So, unfortunately, you will have to locate all syntax errors yourself.

Also, all example scripts should be set to run every frame unless otherwise noted.

You might also like