From 68b6af93385487f3b4a8571d931f9539a07aca27 Mon Sep 17 00:00:00 2001 From: Kaan Soral Date: Fri, 10 Nov 2023 15:22:18 +0300 Subject: [PATCH] scripts/functions.js import fix --- .DS_Store | Bin 32772 -> 32772 bytes design/drops.py | 4 +- design/precomputed.py | 2 +- scripts/deploy.js | 2 +- scripts/electron_bundle.js | 2 +- scripts/functions.js | 235 +++++++++++++++++++++++++++++++++++++ scripts/keep_alive.js | 2 +- scripts/list_commands.js | 2 +- scripts/list_servers.js | 2 +- scripts/precompute.js | 2 +- scripts/prepare_server.js | 2 +- scripts/process_gallery.js | 2 +- scripts/run_a_command.js | 2 +- scripts/run_servers.js | 2 +- scripts/test_iap.js | 2 +- scripts/update_machines.js | 2 +- 16 files changed, 250 insertions(+), 15 deletions(-) create mode 100644 scripts/functions.js diff --git a/.DS_Store b/.DS_Store index 55df46adb6c5d43b264dc05f491fdc75e54db0ba..9d665fb5205028b315b955bbcee349a7558f6cfa 100644 GIT binary patch delta 123 zcmZo^U}|Y#+Q1#aC^lKoOKh`Jz!#3mSpj=Cn?x5x;_TeK0zBNjypzugW=?)?tUCF>qGY&0 zEhh(OynsY?wUMQPj)I|?S*?yjwYj;0j)H}uMQtqyCntxjwpUnEW!vP{+YcW(cKpQ2 zCr_U-fB_>Tm||cMfzmMQ`Q(q0!kZsO&Sstb&|iy@d-CFVmC3vF1000) logs=logs.slice(4,1200); + storage.setItem("logs",logs); +} + +function report_logs(storage) +{ + logs=storage.getItem("logs"); + if(!logs) logs=[]; + for(var i=0;inum) return process.argv[num]; + return false; +} + +function is_production() +{ + if(in_args("live") || in_args("production")) return " production "; + return ""; +} + +function is_sdk(){ return !is_production(); } + +function ch(path) +{ + path=path.replace("~",process.env.HOME); + process.chdir(path); +} + +function read_file(path) +{ + path=path.replace("~",process.env.HOME); + return fs.readFileSync(path,{encoding:'utf-8'}); +} + +function write_file(path,content) +{ + path=path.replace("~",process.env.HOME); + fs.writeFileSync(path,content); +} + +function mssince(t,ref) +{ + if(!ref) ref=new Date(); + return ref.getTime() - t.getTime(); +} +function ssince(t,ref) { return mssince(t,ref)/1000.0; } +function msince(t,ref) { return mssince(t,ref)/60000.0; } +function hsince(t,ref) { return mssince(t,ref)/3600000.0; } + +module.exports={ + util:util, format:util.format, + execs:execs, + execso:execso, + minify_all:minify_all, + is_production:is_production, + is_sdk:is_sdk, + ch:ch, + in_args:in_args, + get_arg:get_arg, + read_file:read_file, + write_file:write_file, + color:color, + ccolor:ccolor, + fetch:fetch, + in_between_from_file:in_between_from_file, + lib_version:lib_version, + mssince:mssince,ssince:ssince,msince:msince,hsince:hsince, + add_log:add_log,report_logs:report_logs, + really_old:really_old, + download:download, + string_to_int:string_to_int, + cdate:cdate, + sleep:sleep, + replace_all:replace_all, +} \ No newline at end of file diff --git a/scripts/keep_alive.js b/scripts/keep_alive.js index 4ee66d3..83c4939 100644 --- a/scripts/keep_alive.js +++ b/scripts/keep_alive.js @@ -1,4 +1,4 @@ -var f=require(process.env.HOME+"/thegeobird/scripts/functions.js"); +var path=require("path"),f=require(path.resolve(__dirname, "functions.js")); require(process.env.HOME+"/thegame/scripts/data.js"); setInterval(function(){ diff --git a/scripts/list_commands.js b/scripts/list_commands.js index 8ea28b2..756296c 100644 --- a/scripts/list_commands.js +++ b/scripts/list_commands.js @@ -1,4 +1,4 @@ -var f=require(process.env.HOME+"/thegeobird/scripts/functions.js"); +var path=require("path"),f=require(path.resolve(__dirname, "functions.js")); require(process.env.HOME+"/thegame/scripts/data.js"); servers.forEach(function(server){ diff --git a/scripts/list_servers.js b/scripts/list_servers.js index 109a0f8..3712721 100644 --- a/scripts/list_servers.js +++ b/scripts/list_servers.js @@ -1,4 +1,4 @@ -var f=require(process.env.HOME+"/thegeobird/scripts/functions.js"); +var path=require("path"),f=require(path.resolve(__dirname, "functions.js")); require(process.env.HOME+"/thegame/scripts/data.js"); for(var id in machines) diff --git a/scripts/precompute.js b/scripts/precompute.js index b82c914..4d9acd5 100644 --- a/scripts/precompute.js +++ b/scripts/precompute.js @@ -1,5 +1,5 @@ var image_size=require('image-size'),fs=require('fs'); -var f=require(process.env.HOME+"/thegeobird/scripts/functions.js"); +var path=require("path"),f=require(path.resolve(__dirname, "functions.js")); var images={}; var data=f.read_file("~/thegame/design/sprites.py"); diff --git a/scripts/prepare_server.js b/scripts/prepare_server.js index d264427..a2bb55b 100644 --- a/scripts/prepare_server.js +++ b/scripts/prepare_server.js @@ -1,4 +1,4 @@ -var f=require(process.env.HOME+"/thegeobird/scripts/functions.js"); +var path=require("path"),f=require(path.resolve(__dirname, "functions.js")); f.execs("rm -rf ~/deploy/server"); f.execs("mkdir ~/deploy/server"); f.execs("cp -r ~/thegame/node/* ~/deploy/server"); diff --git a/scripts/process_gallery.js b/scripts/process_gallery.js index 15de243..56c6520 100644 --- a/scripts/process_gallery.js +++ b/scripts/process_gallery.js @@ -1,5 +1,5 @@ var image_size=require('image-size'),fs=require('fs'); -var f=require(process.env.HOME+"/thegeobird/scripts/functions.js"); +var path=require("path"),f=require(path.resolve(__dirname, "functions.js")); var images=[]; [["/images/tiles/monsters/","monsters",".png"],["/images/tiles/characters/","characters",".png"],["/images/tiles/characters/tribes/","tribes",".png"],["/images/tiles/characters/npcs/","npcs",".png"],["/images/tiles/map/","map",".png"],["/images/tiles/examples/","examples",".png"],["/images/tiles/examples/","examples_gif",".gif"],["/images/sprites/animations/","animations",".png"],["/images/sprites/emblems/","emblems",".png"],["/images/sprites/weather/","weather",".png"],["/images/tiles/animations/","new animations",".png"]].forEach(function(fext){ diff --git a/scripts/run_a_command.js b/scripts/run_a_command.js index e6c528f..286f3c2 100644 --- a/scripts/run_a_command.js +++ b/scripts/run_a_command.js @@ -1,4 +1,4 @@ -var f=require(process.env.HOME+"/thegeobird/scripts/functions.js"); +var path=require("path"),f=require(path.resolve(__dirname, "functions.js")); require(process.env.HOME+"/thegame/scripts/data.js"); for(var id in machines) diff --git a/scripts/run_servers.js b/scripts/run_servers.js index c160982..c237a0b 100644 --- a/scripts/run_servers.js +++ b/scripts/run_servers.js @@ -1,4 +1,4 @@ -var f=require(process.env.HOME+"/thegeobird/scripts/functions.js"); +var path=require("path"),f=require(path.resolve(__dirname, "functions.js")); require(process.env.HOME+"/thegame/scripts/data.js"); servers.forEach(function(server){ diff --git a/scripts/test_iap.js b/scripts/test_iap.js index 1e20844..7a4cc7b 100644 --- a/scripts/test_iap.js +++ b/scripts/test_iap.js @@ -1,5 +1,5 @@ var secret="ac2b8964dffd4a8a961f427d1257d8f7"; -var f=require(process.env.HOME+"/thegeobird/scripts/functions.js"); +var path=require("path"),f=require(path.resolve(__dirname, "functions.js")); var iap = require('in-app-purchase'); var receipt_file="/Applications/Adventure Land.app/Contents/_MASReceipt/receipt"; //var receipt_file="/Users/kaan/Downloads/receipt"; diff --git a/scripts/update_machines.js b/scripts/update_machines.js index 07c2df7..a43024a 100644 --- a/scripts/update_machines.js +++ b/scripts/update_machines.js @@ -1,4 +1,4 @@ -var f=require(process.env.HOME+"/thegeobird/scripts/functions.js"); +var path=require("path"),f=require(path.resolve(__dirname, "functions.js")); require(process.env.HOME+"/thegame/scripts/data.js"); f.execso("node ~/gscripts/prepare_server.js;");