Hullo all.
I've created a scripting language called Aex.Uni Scripting Language (Yes, it's a very creative name indeed). Anyways, I decided to make a DBPro plugin for this relatively simple scripting language (In two senses). So, here it is.
Now note, I made this scripting language in 2 days. I didn't make it in some language with simple string management. I made it in C++ (It has a string class, and I created several string classes, but I decided against using either of those and handled the string pointers directly). So for 2 days work I think it's pretty good, and it is complete (Exactly where I want it to be).
Here are several example scripts to see what the language is like:
test1.ac
; Data section (The data section should ALWAYS be before the code section)
.data
; Integers
int myInteger
; Code
.code
; Display a nice message
print "We're going to set some flags..."
; Set a flag
setFlag 40, 100
setFlag 90, 200
setFlag 16, 50
; Do a test function
print "" ; New line
print "Performing a test function."
test 0, 1, 2, 3, 4, 5, 6, 7
; Additional test
print "" ; New line
print "Setting flag 100 to 0"
setFlag 100, 0
; Put the value of flag 90 into myInteger
print "" ; For new line
print "Retrieving the value of flag 90 and placing it in g_myInteger"
getFlag:$myInteger 90
; Display myInteger to the screen
printi $myInteger
test2.ac
; Data section
.data
; String that retrieves the input
string name
string feeling
; Code section
.code
; Ask the user for his or her name
print "What is your name?"
input:$name "My name is "
print ""
; Ask the user how he or she is feeling
printc "How are you feeling, "
printc $name
print "?"
input:$feeling "I'm feeling "
print ""
; The program is ending, say good bye to the user
print "Well, have a good day."
print "See ya! :)"
test3.ac
; Data section
.data
; String that retrieves the input
int val1
int val2
; Code section
.code
; Set value 1
print "Setting val1 to 100"
seti:$val1 100
; Set value 2
print "Setting val2 to 200"
seti:$val2 200
; Display the values
printc "Val1 = "
printi $val1
printc "Val2 = "
printi $val2
; Comparing values 1 and 2
cmpi $val1, $val2
goto_if_gt 1
goto_if_lt 2
goto_if_eq 3
goto 4
; Larger than label
label 1
print "val1 > val2"
goto 4
; Less than label
label 2
print "val1 < val2"
goto 4
; Equal label
label 3
print "val1 = val2"
; Finish label
label 4
print "Thanks for running this test program!"
print "That'll do. You can go now."
test4.ac
; Code section
.code
; Tell the user that we're going to go to another label then continue execution
print "Going to label 1 (will return)"
; Temporarily go to label 1
gosub 1
; We've returned from label 1, infom the user
print "We've returned from execution!"
print "Going to label 2 (won't return)"
; Now go to label 2
goto 2
; This is label 1
label 1
; Inform the user we're inside of the label
print "We're in label 1!"
return
; This is label 2
label 2
; Inform the user we're inside of the second label
print "We're in label 2!"
print "Good bye!"
test5.ac
; Data section
.data
float fval1
float fval2
; Code section
.code
; Set our floats to random values
setf:$fval1 23.4
setf:$fval2 19.7
; Which is bigger?
cmpf $fval1, $fval2
goto_if_gt 1
goto_if_lt 2
goto 3
; Label 1 - fval1 > fval2
label 1
print "fval1 is bigger than fval2"
goto 3
; Label 2 - fval1 < fval2
label 2
print "fval2 is bigger than fval1"
goto 3
; Label 3
label 3
print "Good bye!"
init.ac For DBPro
; Main code for the script
.code
; Create the objects
makeObjectCone 1, -1000.0 ; This is an environment object - we're not interacting with it
makeObjectCube 2, 100.0 ; Another environment object
makeObjectSphere 3, 20.0 ; This is who we'll later interact with
; Position the objects
positionObject 2, 30.0, 45.0, 70.0 ; Position our other environment object (The cube)
; Done!
main.ac For DBPro
; Data
.data
; Key states
int up_key ; Set to 1 if the W key is being pressed, 0 otherwise
int left_key ; Set to 1 if the A key is being pressed, 0 otherwise
int down_key ; Set to 1 if the S key is being pressed, 0 otherwise
int right_key ; Set to 1 if the D key is being pressed, 0 otherwise
; Code
.code
; Retrieve the various key states
keyDown:$up_key 17
keyDown:$left_key 30
keyDown:$down_key 31
keyDown:$right_key 32
; Check for moving forewards
cmpi $up_key, 0
goto_if_gt 1
; Check for moving backwards
cmpi $down_key, 0
goto_if_gt 3
; Proceed to checking for turning movements
goto 5
; Control turning movements
label 5
; Check for turning to the left
cmpi $left_key, 0
goto_if_gt 2
; Check for turning to the right
cmpi $right_key, 0
goto_if_gt 4
; Proceed to setting the camera to the object
goto 6
; Move foreward
label 1
moveObject 3, 2.0
goto 5
; Move backwards
label 3
moveObject 3, -2.0
goto 5
; Turn to the left
label 2
turnObject 3, -2.0
goto 6
; Turn to the right
label 4
turnObject 3, 2.0
goto 6
; Done
label 6
; Set the camera to our object
camToObj 3
The download is attached.
Cheers,
-naota
I'm not a dictator to those that do stuff for me by will. Only those who don't.