mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-22 21:57:58 +07:00
Bugfixes / Tutorial cleanup
This commit is contained in:
@ -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}
|
||||
|
Reference in New Issue
Block a user