Skip to content

Commit 5da327e

Browse files
author
Philipp Gersch
authored
Merge pull request #6 from DevKevYT/1.9.10
1.9.10
2 parents ca054e9 + 673506f commit 5da327e

26 files changed

+1734
-804
lines changed

Editor.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Devscrip console editor by Sn1pe2win#
1+
#Devscript console editor by Sn1pe2win#
22

33
currentLine = 0;
44
lines = [];
@@ -15,20 +15,20 @@ printAll = {
1515
};
1616

1717
recieveInput = {
18-
print $0 ">";
18+
print $0 "> ";
1919
return (input);
2020
};
2121

2222

2323
printLinesUntil = {
2424
for i $0 {
25-
print $i ">" $lines[$i];
25+
print $i "> " $lines[$i];
2626
println "";
2727
};
2828
};
2929

3030

31-
exec cls;
31+
exec "cls";
3232
call $printHeading;
3333

3434
loop {
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
#Selection sort example by DevKev#
1+
#Selection sort example by DevKev for version 1.9.10#
22

3-
unsorted = [3 4 7 8 9 543 23 7 5 32 1 56 7 65 34 13 5 7 2];
3+
unsorted = [];
44
sorted = [];
55
record = 99999;
66
index = -1;
77

8+
for i 200 {
9+
unsorted[$i] = (int ((random) * 1000));
10+
};
11+
12+
println $unsorted;
13+
814
loop
915
{
1016
for i (length $unsorted)

Examples/demos/hangman

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#Hangman by DevKev for version 1.9.10#
2+
3+
words = [tree devscript script java command block array thread];
4+
word = "";
5+
guessed = [];
6+
wordsplit = [];
7+
blacklist = [];
8+
9+
drawScreen = {
10+
try {
11+
exec cls;
12+
clearConsole;
13+
};
14+
15+
allright = $true;
16+
for i (length $wordsplit) {
17+
if ($guessed[$i] != " ") {
18+
print $guessed[$i] "\t";
19+
} else {
20+
print "_\t";
21+
allright = $false;
22+
};
23+
};
24+
25+
if $allright {
26+
call $drawEndScreen $true;
27+
return;
28+
};
29+
30+
println "\n\n";
31+
println "LIFE [" $life "]";
32+
characters = "";
33+
for i (length $blacklist) {
34+
characters = (($characters + " ") + $blacklist[$i]);
35+
};
36+
println "Wrong Guesses: " $characters;
37+
println;
38+
};
39+
40+
drawEndScreen = {
41+
try {
42+
exec cls;
43+
clearConsole;
44+
};
45+
46+
if $0 {
47+
println " \tY O U W O N !";
48+
} else {
49+
println " \tY O U L O S T !";
50+
};
51+
println;
52+
println "\tThe word was: '" $word "'";
53+
println "\tYou had " $life " lives left";
54+
println "\n\tPlay again? Press [ENTER]";
55+
input;
56+
call $chooseWord;
57+
call $drawScreen;
58+
};
59+
60+
guess = {
61+
char = $0;
62+
for i (length $blacklist) {
63+
if ($blacklist[$i] == $char) {
64+
println "lool";
65+
return $false;
66+
};
67+
};
68+
right = $false;
69+
for i (length $wordsplit) {
70+
if ($wordsplit[$i] == $char) {
71+
guessed[$i] = $char;
72+
right = $true;
73+
};
74+
};
75+
return $right;
76+
};
77+
78+
chooseWord = {
79+
life = 10;
80+
word = $words[?];
81+
guessed = [];
82+
wordsplit = [];
83+
blacklist = [];
84+
for i (stringLength $word) {
85+
wordsplit[$i] = (charAt $i $word);
86+
guessed[$i] = " ";
87+
};
88+
};
89+
90+
addToBlacklist = {
91+
for i (length $blacklist) {
92+
if ($blacklist[$i] == $0) {
93+
return;
94+
};
95+
};
96+
push $0 $blacklist;
97+
};
98+
99+
call $chooseWord;
100+
life = 10;
101+
loop {
102+
call $drawScreen;
103+
print "Guess a character: ";
104+
character = (input);
105+
106+
if ((stringLength $character) gt 0) {
107+
character = (charAt 0 $character);
108+
right = (call $guess $character);
109+
ifnot $right {
110+
life = ($life - 1);
111+
call $addToBlacklist $character;
112+
if ($life == 0) {
113+
call $drawEndScreen $false;
114+
};
115+
};
116+
};
117+
}
118+
119+
120+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#[EXAMPLE 1: BASIC COMMAND SYNTAX]#
2+
3+
#
4+
As you can see, you can put comments in your script by putting the text in between two "hashtags"
5+
Comments are being completely ignored, so you can put them basically everywhere.
6+
#
7+
8+
#In general, there is a command, that accepts certain arguments:
9+
Here we have a "println" command, that accepts strings or any
10+
other datatype. All commands are separated by a ";" and arguments are separated by a space character.
11+
You can use the "help" command to list all available commands and their arguments#
12+
help;
13+
println "Hello";
14+
15+
16+
#Strings are also recognized without the Quotation marks:#
17+
println Hello;
18+
19+
20+
#But they are helpful if you want to pass Strings with spaces#
21+
println "Hello World";
22+
23+
24+
#You can "wrap" multiple commands as arguments for other
25+
commands by putting the command in between "(" and ")"
26+
Here, we add 2 and 2 (=4) and printing the result:
27+
(Remember, the + is just another command, but the command name is
28+
shifted to the right. Otherwise, it would look like this: "+ 2 2". Not very readable.#
29+
println (2 + 2);
30+
31+
#We can also do more complex command "wrapping" and print it
32+
But remember, too much of something is never good better split this up with variables (Covered in example 2)#
33+
println (int ((random) * 1000));
34+
35+
#To format text, you can just put \n and \t inside strings#
36+
println "This is a line\nAnd another line. \tTab";

Examples/tutorials/2 Variables

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#EXAMPLE 2: VARIABLES#
2+
3+
#You can declare and modify variables using the "=" command (Command name is shifted by one to the right)
4+
You can put any character into the variable name, except: "$", ".", ";" and obviously space characters.
5+
Reserved characters like "[", "]", """, "<", ">", "{", "}" may cause weird behaviors.
6+
So in general, you should avoid reserved characters#
7+
foo = "Some text";
8+
2 = "More text";
9+
=*2_&] = "Why would you even name your variable like this?";
10+
11+
12+
#You can access variables by using the "$" character, followed by the variable name#
13+
println $foo;
14+
println $=*2_&];
15+
println $2;
16+
17+
18+
#Variables are entirely replaced by their respective value, so theoretically, you can even do this.
19+
This example will store the command name in a variable and execute it with the given argument:#
20+
commandNameAsVariable = println;
21+
$commandNameAsVariable $foo; #<- Replaced by 'println "Some text"' and executed at runtime! #
22+
23+
24+
#To read variables, you use the "$" sign. But you don't use it to modify variables
25+
Here we change the value of the variable "foo" to "Changed the text!"#
26+
foo = "Changed the text!";
27+
println $foo;
28+
29+
30+
#This rule of variable modification also applies to arrays (Tutorial 4) and Objects (Tutorial 7):#
31+
#We print the first array element ("1") but we will change it to "10"#
32+
array = [1 2 3]; #More on this in tutorial 3#
33+
println $array[0]; #<- Access with $ sign#
34+
array[0] = 10; #<- Modify without $ sign#
35+
$array[0] = 10; #This will create a variable with the name "10", since the value of $array[0] is 10#
36+
println $array[0];
37+
println array[0]; #<- This will just print "array[0]", but not the actual value. You forgot the "$"!#
38+
39+
obj = (new-object {}); #More on this in tutorial 5#
40+
obj.x = 10;
41+
println $obj.x;
42+
43+
44+
#You can list all accessible variables and their Block for debug purposes by executing this command#
45+
listvars;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#CONDITIONAL EXPRESSIONS BASICS by DevKev for version 1.9.10#
2+
3+
#To create if statements, you can use the "if [boolean] [block]" command
4+
Remember, unlike java or similar languages, you still need to use ";" to terminate a command even if it ends with a "}"#
5+
variable = $true;
6+
if $variable {
7+
println "The variable is true!";
8+
};
9+
10+
11+
#If statements work like in most programming languages:#
12+
if $false {
13+
#...#
14+
} else {
15+
#...#
16+
};
17+
18+
19+
#"elseif" is also possible#
20+
if $false {
21+
#...#
22+
} elseif $true {
23+
#...#
24+
} else {
25+
#...#
26+
};
27+
28+
29+
#You can also use the command [boolean] ? [???] [???]" as ternary expression
30+
If the condition is true, the 3rd argument is returned, otherwise the 4th#
31+
condition = $true;
32+
println ($condition ? "Condition is true" "Condition is false");
33+
34+
35+
#To compare two variables you can use the following commands with the two example Variables $var0 and $var1:
36+
"$var0 == $var1" <- Returns $true, if $var0's toString() equals $var1
37+
"$var0 != $var1" <- Returns $true, if $var0's toString() does not equal $var1
38+
"$var0 lt $var1" <- Returns $true, if $var0 is less than $var1 (Works only with numbers)
39+
"$var0 lteq $var1" <- Returns $true, if $var0 is less or equal than $var1 (Works only with numbers)
40+
"$var0 gt $var1" <- Returns $true, if $var0 is greater than $var1 (Works only with numbers)
41+
"$var0 gteq $var1" <- Returns $true, if $var0 is greater or equal than $var1 (Works only with numbers)#
42+
43+
var0 = 22;
44+
var1 = 12;
45+
if ($var0 gt $var1) {
46+
println "var0 is greater than var1";
47+
};
48+
49+
50+
#You can also use logical operators "and" and "or"#
51+
result0 = ($true and $false);
52+
println $result0;
53+
result1 = ($true and $false or $true);
54+
println $result1;
55+
result1 = (($true and $false) or ($true and $true));
56+
println $result1;
57+
58+
#The following example prints, if x is inbetween 10 and 20 or less than 0#
59+
x = 20;
60+
if (($x gteq 10) and ($x lteq 20) or ($x lt 0)) {
61+
println "x is between 10 and 20 or less than 0";
62+
} else {
63+
println "x is less than 10 and greater than 20 and above zero";
64+
};
65+

Examples/tutorials/4 Arrays

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#ARRAYS by DevKev for version 1.9.10#
2+
3+
#Declare a variable as an array using "[" and "]"#
4+
emptyArray = [];
5+
println $emptyArray;
6+
7+
8+
#To declare filled arrays, use the same method, but separate different entries with a space character inside "[" and "]"#
9+
filledStringArray = ["test1" "test2" "test3"];
10+
filledIntegerArray = [1 2 3];
11+
println $filledStringArray;
12+
13+
14+
#All arrays are dynamic and can hold different datatypes and can resolve variables and wrapped commands#
15+
chaoticArray = ["String" (1 + 1) $filledStringArray {}]; #<- A single array with 4 different data types: String, Array, Block#
16+
println $chaoticArray;
17+
18+
19+
#You can also create arrays with multiple dimensions by just putting arrays into arrays
20+
This will create a grid of 4x4 made of "+" when printed properly#
21+
grid = [[+ - + +] [+ + + +] [+ + + +] [+ + + +]];
22+
23+
24+
#You can access array indices like any other language.#
25+
index = 0;
26+
println $filledStringArray[0];
27+
println $filledStringArray[$index]; #<- Using a variable. Maybe the famous $i in for- loops?#
28+
println $grid[0][1];
29+
30+
31+
#You can modify array indices like in Tutorial 2 without the "$"#
32+
index = 1;
33+
filledStringArray[0] = "First Element!";
34+
grid[0][$index] = "+"; #<- Lets repair the grid!#
35+
println $filledStringArray[0];
36+
println $grid;
37+
38+
39+
#There are 3 methods to extend arrays:
40+
You can add array elements simply by choosing any index that is out of bounds (>= 0)
41+
You can also use the "push [value] [array]" to extend arrays
42+
The third method would be to use the "[???] + [???]" command#
43+
emptyArray[5] = 10; #This will automatically fill 0 - 4 with $null and make the array length 6#
44+
println $emptyArray;
45+
46+
#Here is a list of all the methods to expand an array:#
47+
#Method 1:#
48+
push "10" $filledIntegerArray; #Expand by using the "push" command (push the value "10" into $filledIntegerArray)#
49+
50+
#Method 2:#
51+
length = (length $filledIntegerArray); #Expand by finding out the length and expanding with the "out-of-bounds" method#
52+
filledIntegerArray[$length] = 10;
53+
54+
#Method 3:#
55+
$filledIntegerArray + "newValue" #add the String "newValue" to the array using the "+" command. But this method can be confusing, because you need to use the $ sign even if you modify the variable
56+
filledIntegerArray = ($filledIntegerArray + "newValue") #This method has the same result and is a bit more readable#
57+
58+
#You can remove array elements using the "pop [array] [index]" command#
59+
pop $emptyArray 5;
60+
println $emptyArray;
61+
62+
#You can check Array types (If, for example an Array has only Strings (-> "String Array")
63+
or the array contains multiple data types) using the "typeof" command
64+
IMPORTANT: If you want to use the "typeof" command to check array types, remember to put an array indicator (@) at the beginning!
65+
@String != String (-> Array of Strings does not equal a single String)#
66+
println ($filledStringArray typeof "@String"); #prints true: There are only strings in the array#
67+
println ($chaoticArray typeof "@?"); #prints true: This array contains multiple data types, is "any" (?)#
68+
println ($chaoticArray typeof "@block"); #println true: WHY?! This is kind of a special case. Since the type is "any", it is also "block", "string", "array" and so on and will always return true no matter what array type#
69+
println ($filledStringArray typeof "@?"); #prints false: This is the String array#
70+

0 commit comments

Comments
 (0)