미디어위키:Gadget-godot3.js: 두 판 사이의 차이

리버티게임(개발), 모두가 만들어가는 자유로운 게임
둘러보기로 이동 검색으로 이동
(일반 이름 공간으로 옮길 준비)
(일반 이름 공간으로 옮길 준비를 함)
27번째 줄: 27번째 줄:
});
});
}
}
 
var basegamepath = "";
function Godot3_loadElement() {
function Godot3_loadElement() {
// try {
try {
// Game canvas
// Game canvas
var canvas = document.createElement("canvas");
var canvas = document.createElement("canvas");
37번째 줄: 37번째 줄:
canvasparent.appendChild(canvas);
canvasparent.appendChild(canvas);
// now load js files from external server
// now load js files from external server
var uri2 = document.getElementById("libertygame-godot3-basegamepath").innerHTML;
basegamepath = document.getElementById("libertygame-godot3-basegamepath").innerText;
godot3_asyncJSLoader(uri2.query.scriptpath, "text/javascript")
godot3_asyncJSLoader(basegamepath+".js", "text/javascript")
.then(function (data) {
.then(function (data) {
mw.loader.getScript("https://libertyga.me/index.php?action=raw&title=틀:고도3/supplement.js")
mw.loader.getScript("https://libertyga.me/index.php?action=raw&title=틀:고도3/supplement.js")
46번째 줄: 46번째 줄:
});
});
// } catch (e){
} catch (e){
// console.log("initiating Godot 3 for libertygame failed, stop loading elements...");
console.log("initiating Godot 3 for libertygame failed, stop loading elements...");
// }
}
}
}
$(Godot3_loadElement);
$(Godot3_loadElement);

2023년 10월 29일 (일) 19:19 판

/**
 * Godot3  for Libertygame loader
 * 제작자: [[사용자:senouis]]
**/

function godot3_asyncJSLoader(url, type) {
	return new Promise(function (resolve, reject) {
	try {
		var scriptElement = document.createElement("script");
		scriptElement.src = url;
		scriptElement.async = true; // force asynchronous loading
		scriptElement.type = type;
		var contextsection = document.getElementById("mw-content-text");
		scriptElement.addEventListener("load", function (ev) {
	        resolve({ status: true });
	    });
	    scriptElement.addEventListener("error", function (ev) {
	        reject({
	            status: false,
	            message: "Failed to load the script"
	        });
	    });
	    contextsection.appendChild(scriptElement);
	} catch (e) {
        reject(e);
    }
	});
}
var basegamepath = "";
function Godot3_loadElement() {
	try {
		// Game canvas
		var canvas = document.createElement("canvas");
		canvas.id = "canvas";
		canvas.innerHTML = "로딩 중...";
		var canvasparent = document.getElementById("libertygame-godot3"); // first element of emscripten-border
		canvasparent.appendChild(canvas);
		// now load js files from external server
		basegamepath = document.getElementById("libertygame-godot3-basegamepath").innerText;
		godot3_asyncJSLoader(basegamepath+".js", "text/javascript")
		.then(function (data) {
			mw.loader.getScript("https://libertyga.me/index.php?action=raw&title=틀:고도3/supplement.js")
			.then(function (data) {
				console.log("Godot OK!");
			});
		});
		
	} catch (e){
		console.log("initiating Godot 3 for libertygame failed, stop loading elements...");
	}
}
$(Godot3_loadElement);