Skip to content

Commit a4755ac

Browse files
Ihor01Ihor01
Ihor01
authored and
Ihor01
committed
Initial commit
0 parents  commit a4755ac

13 files changed

+220
-0
lines changed

InstantRunner.nproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
nide-api:3
2+
project-name:InstantRunner
3+
project-version:1.0.0
4+
project-type:INNERCORE
5+
settings-compress:false

build.config

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"resources":[
3+
{
4+
"path":"assets/",
5+
"resourceType":"resource"
6+
},
7+
{
8+
"path":"gui/",
9+
"resourceType":"gui"
10+
}
11+
],
12+
"defaultConfig":{
13+
"buildType":"develop",
14+
"api":"CoreEngine",
15+
"libraryDir":"lib/"
16+
},
17+
"buildDirs":[
18+
{
19+
"targetSource":"main.js",
20+
"dir":"dev/"
21+
}
22+
],
23+
"compile":[
24+
{
25+
"path":"main.js",
26+
"sourceType":"mod"
27+
},
28+
{
29+
"path":"launcher.js",
30+
"sourceType":"launcher"
31+
}
32+
]
33+
}

dev/.includes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
main.js
2+
readFile.js
3+
gui.js
4+
eval.js

dev/eval.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function runScript(filename){
2+
var code = readFile(__dir__ + "scripts/" + filename);
3+
eval("try {" + code + " ;Game.message('Successfully run file ' + filename);}" +
4+
"catch(e){Game.message('Some errors occured when running file ' + filename + ':');Game.message(e);}");
5+
6+
}

dev/gui.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
var AlertDialog = android.app.AlertDialog;
2+
var DialogInterface = android.content.DialogInterface;
3+
var ScrollView = android.widget.ScrollView;
4+
var LinearLayout = android.widget.LinearLayout;
5+
var Button = android.widget.Button;
6+
var OnClickListener = android.view.View.OnClickListener;
7+
var DialogInterface = android.content.DialogInterface;
8+
var File = java.io.File;
9+
10+
var ctx = UI.getContext();
11+
12+
13+
var window = new UI.Window({
14+
location: {
15+
x:950,
16+
y:0,
17+
width:60,
18+
height:60
19+
},
20+
elements: {
21+
"0": {type: "button", x: 0, y: 0, bitmap: "btnIR", scale: 60, clicker: {
22+
onClick: openAndroidUI
23+
}}
24+
},
25+
drawing: [
26+
{type: "background", color: android.graphics.Color.TRANSPARENT}
27+
]
28+
});
29+
window.setAsGameOverlay(true);
30+
var container = new UI.Container();
31+
32+
33+
34+
function openAndroidUI(){
35+
try{
36+
var builder = new AlertDialog.Builder(ctx);
37+
builder.setTitle("Instant Runner");
38+
var scroll = new ScrollView(ctx);
39+
var layout = new LinearLayout(ctx);
40+
layout.setOrientation(LinearLayout.VERTICAL);
41+
42+
var dir = new File(__dir__ + "scripts/");
43+
var files = dir.listFiles();
44+
45+
for(var i in files){
46+
let filename = files[i].getName();
47+
let btn = new Button(ctx);
48+
btn.setText(filename);
49+
btn.setOnClickListener(new OnClickListener({
50+
onClick: function(){
51+
dialog.dismiss();
52+
runScript(filename);
53+
}
54+
}));
55+
layout.addView(btn);
56+
}
57+
58+
scroll.addView(layout);
59+
builder.setView(scroll);
60+
var dialog = builder.show();
61+
} catch(e){
62+
Game.message(e);
63+
}
64+
}

dev/main.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var code;
2+
3+
4+
Callback.addCallback("PostLoaded", function(){
5+
code = readFile(__dir__ + "scripts/1.js");
6+
7+
});
8+
9+
10+
Callback.addCallback("NativeGuiChanged", function(screenName){
11+
if(screenName == "hud_screen" || screenName == "in_game_play_screen"){
12+
if(!container.isOpened()){
13+
container.openAs(window);
14+
}
15+
}
16+
else{
17+
container.close()
18+
}
19+
});

dev/readFile.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var BufferedReader = java.io.BufferedReader;
2+
var FileReader = java.io.FileReader;
3+
var StringBuilder = java.lang.StringBuilder;
4+
5+
function readFile(path){
6+
var reader = new BufferedReader(new FileReader(path));
7+
var builder = new StringBuilder();
8+
9+
try{
10+
var line = reader.readLine();
11+
while (line != null) {
12+
builder.append(line);
13+
line = reader.readLine();
14+
}
15+
return builder.toString();
16+
} catch(e){
17+
Game.message(e);
18+
}
19+
}

gui/btnIR.png

229 Bytes
Loading

launcher.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Launch();

mod.info

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"InstantRunner","author":"IchZerowan","version":"1.0","description":""}

scripts/1.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
IMPORT("dimensions");
3+
4+
5+
const SKY_COLOR = [0.2, 0.13, 0.2];
6+
const FOG_COLOR = [0.2, 0.16, 0.2];
7+
8+
var APOCity = new Dimension({
9+
name: "APOCity",
10+
11+
generation: {
12+
layers: [
13+
{
14+
range: [2, 80],
15+
noise: {
16+
octaves: {
17+
count: 4,
18+
weight: 0.5,
19+
scale: [1, 0.6, 1]
20+
}
21+
},
22+
23+
gradient: [[-1, 1], [0.2, 0.5], [0.4, 0.3], [0.6, 0.7], [1, 0.25]],
24+
25+
terrain: {
26+
cover: {
27+
height: 4,
28+
top: {id: 1, data: 5},
29+
block: 3
30+
}
31+
}
32+
},
33+
{
34+
range: [1,2],
35+
noise:{
36+
octaves:{
37+
count:8,
38+
weight: 0.4,
39+
scale: [.01,.02,.04,.08]
40+
}
41+
},
42+
gradient:[
43+
[0,1],
44+
[1,-1],
45+
[0.05,.4],
46+
[.2,-.8]
47+
],
48+
terrain:{
49+
base: 7
50+
}
51+
},
52+
],
53+
54+
decoration: {
55+
biome: 2,
56+
features: false
57+
}
58+
},
59+
60+
environment: {
61+
sky: SKY_COLOR,
62+
fog: FOG_COLOR
63+
},
64+
});
65+
66+
APOCity.debugTerrainSlice(128, 1, true);

scripts/2.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Game.message(3)

scripts/lelkek.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Game.message("keklel")

0 commit comments

Comments
 (0)