Bugfixes / Tutorial cleanup

This commit is contained in:
Anuken
2020-11-21 15:50:44 -05:00
parent 96b55c6b1c
commit b09dc47aad
8 changed files with 110 additions and 80 deletions
+15 -15
View File
@@ -19,28 +19,28 @@ let modName = "none"
const print = text => log(modName + "/" + scriptName, text);
// js 'extend(Base, ..., {})' = java 'new Base(...) {}'
function extend(/*Base, ..., def*/) {
const Base = arguments[0];
const def = arguments[arguments.length - 1];
// swap order from Base, def, ... to Base, ..., def
const args = [Base, def].concat(Array.from(arguments).splice(1, arguments.length - 2));
//js 'extend(Base, ..., {})' = java 'new Base(...) {}'
function extend(/*Base, ..., def*/){
const Base = arguments[0]
const def = arguments[arguments.length - 1]
//swap order from Base, def, ... to Base, ..., def
const args = [Base, def].concat(Array.from(arguments).splice(1, arguments.length - 2))
// forward constructor arguments to new JavaAdapter
const instance = JavaAdapter.apply(null, args);
// JavaAdapter only overrides functions; set fields too
for (var i in def) {
if (typeof(def[i]) != "function") {
instance[i] = def[i];
//forward constructor arguments to new JavaAdapter
const instance = JavaAdapter.apply(null, args)
//JavaAdapter only overrides functions; set fields too
for(var i in def){
if(typeof(def[i]) != "function"){
instance[i] = def[i]
}
}
return instance;
return instance
}
// For backwards compatibility, use extend instead
//For backwards compatibility, use extend instead
const extendContent = extend;
//these are not sctrictly necessary, but are kept for edge cases
//these are not strictly necessary, but are kept for edge cases
const run = method => new java.lang.Runnable(){run: method}
const boolf = method => new Boolf(){get: method}
const boolp = method => new Boolp(){get: method}
+25 -20
View File
@@ -3,13 +3,13 @@
"use strict";
function log(context, obj){
Vars.mods.getScripts().log(context, String(obj))
Vars.mods.scripts.log(context, String(obj))
}
const readString = path => Vars.mods.getScripts().readString(path)
const readBytes = path => Vars.mods.getScripts().readBytes(path)
const loadMusic = path => Vars.mods.getScripts().loadMusic(path)
const loadSound = path => Vars.mods.getScripts().loadSound(path)
const readString = path => Vars.mods.scripts.readString(path)
const readBytes = path => Vars.mods.scripts.readBytes(path)
const loadMusic = path => Vars.mods.scripts.loadMusic(path)
const loadSound = path => Vars.mods.scripts.loadSound(path)
const readFile = (purpose, ext, cons) => Vars.mods.scripts.readFile(purpose, ext, cons);
const readBinFile = (purpose, ext, cons) => Vars.mods.scripts.readBinFile(purpose, ext, cons);
@@ -21,28 +21,28 @@ let modName = "none"
const print = text => log(modName + "/" + scriptName, text);
// js 'extend(Base, ..., {})' = java 'new Base(...) {}'
function extend(/*Base, ..., def*/) {
const Base = arguments[0];
const def = arguments[arguments.length - 1];
// swap order from Base, def, ... to Base, ..., def
const args = [Base, def].concat(Array.from(arguments).splice(1, arguments.length - 2));
//js 'extend(Base, ..., {})' = java 'new Base(...) {}'
function extend(/*Base, ..., def*/){
const Base = arguments[0]
const def = arguments[arguments.length - 1]
//swap order from Base, def, ... to Base, ..., def
const args = [Base, def].concat(Array.from(arguments).splice(1, arguments.length - 2))
// forward constructor arguments to new JavaAdapter
const instance = JavaAdapter.apply(null, args);
// JavaAdapter only overrides functions; set fields too
for (var i in def) {
if (typeof(def[i]) != "function") {
instance[i] = def[i];
//forward constructor arguments to new JavaAdapter
const instance = JavaAdapter.apply(null, args)
//JavaAdapter only overrides functions; set fields too
for(var i in def){
if(typeof(def[i]) != "function"){
instance[i] = def[i]
}
}
return instance;
return instance
}
// For backwards compatibility, use extend instead
//For backwards compatibility, use extend instead
const extendContent = extend;
//these are not sctrictly necessary, but are kept for edge cases
//these are not strictly necessary, but are kept for edge cases
const run = method => new java.lang.Runnable(){run: method}
const boolf = method => new Boolf(){get: method}
const boolp = method => new Boolp(){get: method}
@@ -86,6 +86,7 @@ importPackage(Packages.mindustry.entities)
importPackage(Packages.mindustry.entities.abilities)
importPackage(Packages.mindustry.entities.bullet)
importPackage(Packages.mindustry.entities.comp)
importPackage(Packages.mindustry.entities.effect)
importPackage(Packages.mindustry.entities.units)
importPackage(Packages.mindustry.game)
importPackage(Packages.mindustry.gen)
@@ -147,6 +148,8 @@ const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent
const StateChangeEvent = Packages.mindustry.game.EventType.StateChangeEvent
const TileChangeEvent = Packages.mindustry.game.EventType.TileChangeEvent
const GameOverEvent = Packages.mindustry.game.EventType.GameOverEvent
const UnitControlEvent = Packages.mindustry.game.EventType.UnitControlEvent
const PickupEvent = Packages.mindustry.game.EventType.PickupEvent
const TapEvent = Packages.mindustry.game.EventType.TapEvent
const ConfigEvent = Packages.mindustry.game.EventType.ConfigEvent
const DepositEvent = Packages.mindustry.game.EventType.DepositEvent
@@ -155,6 +158,8 @@ const SectorCaptureEvent = Packages.mindustry.game.EventType.SectorCaptureEvent
const PlayerChatEvent = Packages.mindustry.game.EventType.PlayerChatEvent
const ClientPreConnectEvent = Packages.mindustry.game.EventType.ClientPreConnectEvent
const CommandIssueEvent = Packages.mindustry.game.EventType.CommandIssueEvent
const SchematicCreateEvent = Packages.mindustry.game.EventType.SchematicCreateEvent
const SectorLaunchEvent = Packages.mindustry.game.EventType.SectorLaunchEvent
const LaunchItemEvent = Packages.mindustry.game.EventType.LaunchItemEvent
const SectorInvasionEvent = Packages.mindustry.game.EventType.SectorInvasionEvent
const SectorLoseEvent = Packages.mindustry.game.EventType.SectorLoseEvent