본문으로 이동
  • 이 서버는 리버티게임의 개발용 베타 서버로, 게임 플레이 용도로 제작된 사이트가 아닙니다.
  • 리버티게임의 자동 인증된 사용자라면 개발에 필요한 관리자 권한을 신청할 수 있습니다.
  • 틀 및 기능별 소도구를 필요한 문서에만 선택적으로 로딩하는 테스트를 진행하고 있습니다. 작동하지 않는 문서가 있다면 담당자에게 알려주세요.

미디어위키:Gadget-godot3.js

리버티게임(개발), 모두가 만들어가는 자유로운 게임
Senouis (토론 | 기여)님의 2023년 10월 28일 (토) 20:20 판

참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.

  • 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
  • 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
  • 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
/**
 * 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);
    }
	});
}

function Godot3_loadElement() {
	try {
		// Game canvas
		var canvas = document.createElement("canvas");
		canvas.id = "canvas";
		var canvasparent = document.getElementById("libertygame-godot3"); // first element of emscripten-border
		canvasparent.appendChild(canvas);
		// now load js files from external server
		new mw.loader.load("https://libertyga.me/wiki/사용자:Senouis/Godot3/supplement.js", "text/javascript")
		.then(function (data) {
			var uri2 = new mw.Uri(document.URL);
			godot3_asyncJSLoader(uri2.query.scriptpath, "text/javascript")
			.then(function (data) {
				console.log("Godot OK!");
			});
		});
		
	} catch (e){
		console.log("initiating Godot 3 for libertygame failed, stop loading elements...");
	}
}
$(Godot3_loadElement);