Skip to content

Commit ebfab2f

Browse files
authored
Add files via upload
1 parent df3a14d commit ebfab2f

32 files changed

Lines changed: 5266 additions & 693 deletions

Editor.txt

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#Devscrip console editor by Sn1pe2win#
2+
3+
currentLine = 0;
4+
lines = [];
5+
printHeading = {
6+
println "";
7+
println "OFFICIAL DEVSCRIP CONSOLE EDITOR";
8+
println "Type /help for a list of commands";
9+
println "";
10+
};
11+
12+
printAll = {
13+
call $printHeading;
14+
call $printLinesUntil (length $lines);
15+
};
16+
17+
recieveInput = {
18+
print $0 ">";
19+
return (input);
20+
};
21+
22+
23+
printLinesUntil = {
24+
for i $0 {
25+
print $i ">" $lines[$i];
26+
println "";
27+
};
28+
};
29+
30+
31+
exec cls;
32+
call $printHeading;
33+
34+
loop {
35+
input = (call $recieveInput $currentLine);
36+
if ($input != "") {
37+
if ($input == "/edit") {
38+
println "EDIT LINE?";
39+
line = (input);
40+
call $printLinesUntil ($line + 1);
41+
print "NEW: ";
42+
newLine = (input);
43+
if ($newLine != "") {
44+
$newLine === $lines $line;
45+
exec cls;
46+
call $printAll;
47+
} {pop $lines $line;currentLine = ($currentLine - 1)};
48+
} {
49+
if ($input == "/list") {
50+
exec cls;
51+
call $printAll;
52+
} {
53+
if ($input == "/run") {
54+
whole = "";
55+
for i (length $lines) {
56+
whole = ($whole + $lines[$i]);
57+
};
58+
println "";
59+
exec cls;
60+
call $printAll;
61+
println "";
62+
println "+++EXECUTING+++";
63+
println "";
64+
script $whole;
65+
println "";
66+
print "Done. Press Enter...";
67+
input;
68+
exec cls;
69+
call $printAll;
70+
71+
} {
72+
if ($input == /help) {
73+
println "Available commands:";
74+
println "/help, /run, /edit, /list, /new, /save, /load";
75+
println "Fun fact: This program is written in the devscript language! Take a look into the Editor.txt file!";
76+
} {
77+
if ($input == /new) {
78+
lines = [];
79+
currentLine = 0;
80+
exec cls;
81+
call $printAll;
82+
} {
83+
if ($input == "/save") {
84+
println "SAFE FILE TO? (Use */ for current path)";
85+
file = (getFile (input));
86+
for i (length $lines) {
87+
writeFileLine $file $lines[$i];
88+
};
89+
println "FILE SAVED TO" $file;
90+
} {
91+
if ($input == /load) {
92+
println "LOAD FILE FROM? (Use */ for current path)";
93+
file = (getFile (input));
94+
fl = (readFileLines $file);
95+
lines = $fl;
96+
currentLine = ((length $fl) + 1);
97+
println "FILE LOADED";
98+
} {
99+
push $input $lines;
100+
currentLine = ($currentLine + 1);
101+
};
102+
};
103+
};
104+
};
105+
};
106+
};
107+
};
108+
} {exec cls;call $printAll};
109+
};

Examples/demos/Calculator

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#Simple calculator with input#
2+
#Should also be an example for functions#
3+
4+
calculate = {
5+
num1 = $0; #Better names#
6+
num2 = $1;
7+
operator = $2;
8+
9+
ifnot (($num1 typeof num) or ($num2 typeof num))
10+
{
11+
println "Error";
12+
return;
13+
};
14+
15+
if ($operator == +)
16+
{
17+
return ($num1 + $num2);
18+
};
19+
if ($operator == -)
20+
{
21+
return ($num1 - $num2);
22+
};
23+
println "Error, unknown operator: " $operator;
24+
};
25+
26+
print "Enter first number: ";
27+
num1 = (input);
28+
print "Enter second number: ";
29+
num2 = (input);
30+
print "Enter operator (+, -): ";
31+
operator = (input);
32+
33+
println "Calculating...";
34+
println (call $calculate $num1 $num2 $operator);

Examples/demos/Selection Sort

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#Selection sort example by DevKev for version 1.9.10#
2+
3+
unsorted = [];
4+
sorted = [];
5+
record = 99999;
6+
index = -1;
7+
8+
for i 200 {
9+
unsorted[$i] = (int ((random) * 1000));
10+
};
11+
12+
println $unsorted;
13+
14+
loop
15+
{
16+
for i (length $unsorted)
17+
{
18+
if ($unsorted[$i] lt $record)
19+
{
20+
record = $unsorted[$i];
21+
index = $i;
22+
};
23+
};
24+
25+
push $unsorted[$index] $sorted;
26+
pop $unsorted $index;
27+
record = 99999;
28+
29+
if ((length $unsorted) == 0)
30+
{
31+
break;
32+
};
33+
};
34+
35+
println "Done";
36+
println $sorted;

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;

0 commit comments

Comments
 (0)