Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
94d2d261aa | |
|
|
9a69f43f96 |
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2023 [fullname]
|
Copyright (c) 2023 cirroskais
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
||||||
14
example.env
14
example.env
|
|
@ -1,16 +1,16 @@
|
||||||
PORT=
|
PORT=
|
||||||
RCCSERVICE=
|
RCCSERVICE=
|
||||||
|
|
||||||
BASE_URL=https://kapish.fun
|
BASE_URL=https://sitetest.unexp.xyz
|
||||||
|
|
||||||
ARBITER_TOKEN=
|
ARBITER_TOKEN=
|
||||||
ARBITER_KEY=
|
ARBITER_KEY=
|
||||||
|
|
||||||
RENDER_USER_WIDTH=420
|
RENDER_USER_WIDTH=720
|
||||||
RENDER_USER_HEIGHT=420
|
RENDER_USER_HEIGHT=720
|
||||||
|
|
||||||
RENDER_ASSET_WIDTH=420
|
RENDER_ASSET_WIDTH=720
|
||||||
RENDER_ASSET_HEIGHT=420
|
RENDER_ASSET_HEIGHT=720
|
||||||
|
|
||||||
RENDER_PLACE_WIDTH=768
|
RENDER_PLACE_WIDTH=854
|
||||||
RENDER_PLACE_HEIGHT=432
|
RENDER_PLACE_HEIGHT=480
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@ app.use("/render/asset", require("./routes/render/asset.js"))
|
||||||
app.use("/render/game", require("./routes/render/game.js"))
|
app.use("/render/game", require("./routes/render/game.js"))
|
||||||
app.use("/render/texture", require("./routes/render/texture.js"))
|
app.use("/render/texture", require("./routes/render/texture.js"))
|
||||||
app.use("/render/user", require("./routes/render/user.js"))
|
app.use("/render/user", require("./routes/render/user.js"))
|
||||||
app.use("/render/clothing", require("./routes/render/clothing.js"))
|
app.use("/render/texture", require("./routes/render/texture.js"))
|
||||||
app.use("/render/mesh", require("./routes/render/mesh.js"))
|
|
||||||
|
|
||||||
app.use("*", require("./routes/index.js"))
|
app.use("*", require("./routes/index.js"))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,16 @@ const { readFile } = require("fs/promises")
|
||||||
|
|
||||||
const Job = require("./Job.js")
|
const Job = require("./Job.js")
|
||||||
const logger = require("../logger.js")
|
const logger = require("../logger.js")
|
||||||
|
const randport = require("../randport.js")
|
||||||
|
|
||||||
class GameJob extends Job {
|
class GameJob extends Job {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({ expirationInSeconds: 360 })
|
super({ expirationInSeconds: 360 })
|
||||||
}
|
}
|
||||||
|
|
||||||
StartGame(id, port, creatorId) {
|
StartGame(id) {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
this.placeId = id
|
this.placeId = id
|
||||||
this.port = port
|
|
||||||
this.id = id
|
|
||||||
|
|
||||||
const started = await this.Start()
|
const started = await this.Start()
|
||||||
if (!started) throw new Error("RCCService failed to start")
|
if (!started) throw new Error("RCCService failed to start")
|
||||||
|
|
@ -21,6 +20,8 @@ class GameJob extends Job {
|
||||||
|
|
||||||
logger.info(`[${this.id}] GameJob started for ${id}`)
|
logger.info(`[${this.id}] GameJob started for ${id}`)
|
||||||
|
|
||||||
|
const port = await randport.udp()
|
||||||
|
|
||||||
this.OpenJobEx({
|
this.OpenJobEx({
|
||||||
name: this.id,
|
name: this.id,
|
||||||
script: await readFile(__dirname + "/../../lua/gameserver.lua", { encoding: "utf-8" }),
|
script: await readFile(__dirname + "/../../lua/gameserver.lua", { encoding: "utf-8" }),
|
||||||
|
|
@ -33,13 +34,11 @@ class GameJob extends Job {
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: id },
|
{ type: "LUA_TNUMBER", value: id },
|
||||||
{ type: "LUA_TNUMBER", value: port },
|
{ type: "LUA_TNUMBER", value: port },
|
||||||
{ type: "LUA_TSTRING", value: process.env.ARBITER_TOKEN },
|
|
||||||
{ type: "LUA_TNUMBER", value: creatorId },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}).catch((e) => reject(e))
|
}).catch((e) => reject(e))
|
||||||
|
|
||||||
resolve()
|
resolve(port)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
const { readFile } = require("fs/promises")
|
const { readFile } = require("fs/promises")
|
||||||
const chalk = require("chalk")
|
const chalk = require("chalk")
|
||||||
const axios = require("axios")
|
|
||||||
|
|
||||||
const Job = require("./Job.js")
|
const Job = require("./Job.js")
|
||||||
const logger = require("../logger.js")
|
const logger = require("../logger.js")
|
||||||
|
|
@ -162,7 +161,7 @@ class RenderJob extends Job {
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
||||||
{ type: "LUA_TNUMBER", value: id },
|
{ type: "LUA_TNUMBER", value: id },
|
||||||
{ type: "LUA_TSTRING", value: "test" },
|
{ type: "LUA_TSTRING", value: process.env.ARBITER_TOKEN },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}).catch((e) => false)
|
}).catch((e) => false)
|
||||||
|
|
@ -214,91 +213,6 @@ class RenderJob extends Job {
|
||||||
if (!result) return false
|
if (!result) return false
|
||||||
return result[0]?.OpenJobExResult?.LuaValue[0]?.value
|
return result[0]?.OpenJobExResult?.LuaValue[0]?.value
|
||||||
}
|
}
|
||||||
|
|
||||||
async RenderClothing(id, three_d = false) {
|
|
||||||
this.id = randomUUID()
|
|
||||||
|
|
||||||
const running = this.started
|
|
||||||
if (!running) {
|
|
||||||
const started = await this.Start()
|
|
||||||
if (!started) throw new Error("RCCService failed to start")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.client) await this.CreateClient()
|
|
||||||
|
|
||||||
if (three_d) logger.info(`${chalk.gray(`${chalk.gray(`[${this.id}]`)}`)} 3D Asset RenderJob started for ${id}`)
|
|
||||||
else logger.info(`${chalk.gray(`${chalk.gray(`[${this.id}]`)}`)} Asset RenderJob started for ${id}`)
|
|
||||||
|
|
||||||
const result = await this.OpenJobEx({
|
|
||||||
name: this.id,
|
|
||||||
script: await readFile(__dirname + "/../../lua/clothing.lua", { encoding: "utf-8" }),
|
|
||||||
arguments: {
|
|
||||||
LuaValue: [
|
|
||||||
{ type: "LUA_TSTRING", value: this.id },
|
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: "Clothing" },
|
|
||||||
{ type: "LUA_TSTRING", value: three_d ? "OBJ" : "PNG" },
|
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_WIDTH },
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_HEIGHT },
|
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
|
||||||
{ type: "LUA_TNUMBER", value: id },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}).catch((e) => false)
|
|
||||||
|
|
||||||
if (three_d) logger.info(`${chalk.gray(`${chalk.gray(`[${this.id}]`)}`)} 3D Asset RenderJob finished for ${id}`)
|
|
||||||
else logger.info(`${chalk.gray(`${chalk.gray(`[${this.id}]`)}`)} Asset RenderJob finished for ${id}`)
|
|
||||||
|
|
||||||
this.Stop()
|
|
||||||
|
|
||||||
if (!result) return false
|
|
||||||
return result[0]?.OpenJobExResult?.LuaValue[0]?.value
|
|
||||||
}
|
|
||||||
|
|
||||||
async RenderMesh(id, three_d = false) {
|
|
||||||
this.id = randomUUID()
|
|
||||||
|
|
||||||
const running = this.started
|
|
||||||
if (!running) {
|
|
||||||
const started = await this.Start()
|
|
||||||
if (!started) throw new Error("RCCService failed to start")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.client) await this.CreateClient()
|
|
||||||
|
|
||||||
if (three_d) logger.info(`${chalk.gray(`${chalk.gray(`[${this.id}]`)}`)} 3D Mesh RenderJob started for ${id}`)
|
|
||||||
else logger.info(`${chalk.gray(`${chalk.gray(`[${this.id}]`)}`)} Mesh RenderJob started for ${id}`)
|
|
||||||
|
|
||||||
const result = await this.OpenJobEx({
|
|
||||||
name: this.id,
|
|
||||||
script: await readFile(__dirname + "/../../lua/mesh.lua", { encoding: "utf-8" }),
|
|
||||||
arguments: {
|
|
||||||
LuaValue: [
|
|
||||||
{ type: "LUA_TSTRING", value: this.id },
|
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: "Mesh" },
|
|
||||||
{ type: "LUA_TSTRING", value: three_d ? "OBJ" : "PNG" },
|
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_WIDTH },
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_HEIGHT },
|
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
|
||||||
{ type: "LUA_TNUMBER", value: id },
|
|
||||||
{ type: "LUA_TBOOLEAN", value: "true" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}).catch((e) => false)
|
|
||||||
|
|
||||||
if (three_d) logger.info(`${chalk.gray(`${chalk.gray(`[${this.id}]`)}`)} 3D Mesh RenderJob finished for ${id}`)
|
|
||||||
else logger.info(`${chalk.gray(`${chalk.gray(`[${this.id}]`)}`)} Mesh RenderJob finished for ${id}`)
|
|
||||||
|
|
||||||
this.Stop()
|
|
||||||
|
|
||||||
if (!result) return false
|
|
||||||
return result[0]?.OpenJobExResult?.LuaValue[0]?.value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = RenderJob
|
module.exports = RenderJob
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
|
|
||||||
local Player = game.Players:CreateLocalPlayer(0)
|
local Player = game.Players:CreateLocalPlayer(0)
|
||||||
Player.CharacterAppearance = ("%s/Asset/CharacterFetch.ashx?userId=%d"):format(baseUrl, assetId)
|
Player.CharacterAppearance = ("%s/Character?id=%d"):format(baseUrl, assetId)
|
||||||
Player:LoadCharacter(false)
|
Player:LoadCharacter(false)
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
local jobId, type, format, x, y, baseUrl, assetId = ...
|
|
||||||
|
|
||||||
print(("[%s] Started RenderJob for type '%s' with assetId %d"):format(jobId, type, assetId))
|
|
||||||
|
|
||||||
game:GetService("ScriptInformationProvider"):SetAssetUrl(baseUrl .. "/asset/")
|
|
||||||
game:GetService("InsertService"):SetAssetUrl(baseUrl .. "/asset/?id=%d")
|
|
||||||
game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetversionid=%d")
|
|
||||||
game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
|
||||||
|
|
||||||
local Player = game.Players:CreateLocalPlayer(0)
|
|
||||||
Player.CharacterAppearance = ("%s/thumbnail/clothingcharapp/%d"):format(baseUrl, assetId)
|
|
||||||
Player:LoadCharacter(false)
|
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
|
||||||
|
|
||||||
Player.Character.Animate.Disabled = true
|
|
||||||
Player.Character.Torso.Anchored = true
|
|
||||||
|
|
||||||
print(("[%s] Rendering ..."):format(jobId))
|
|
||||||
local result = game:GetService("ThumbnailGenerator"):Click(format, x, y, true)
|
|
||||||
print(("[%s] Done!"):format(jobId))
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
@ -1,15 +1,12 @@
|
||||||
local jobId, type, baseUrl, placeId, port, key, creatorId = ...
|
local jobId, type, baseUrl, placeId, port = ...
|
||||||
|
|
||||||
------------------- UTILITY FUNCTIONS --------------------------
|
------------------- UTILITY FUNCTIONS --------------------------
|
||||||
|
|
||||||
function waitForChild(parent, childName)
|
function waitForChild(parent, childName)
|
||||||
while true do
|
while true do
|
||||||
local child = parent:findFirstChild(childName)
|
local child = parent:findFirstChild(childName)
|
||||||
if child then
|
if child then return child end
|
||||||
return child
|
parent.ChildAdded:wait()
|
||||||
end
|
end
|
||||||
parent.ChildAdded:wait()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
||||||
|
|
@ -27,83 +24,53 @@ pcall(function() settings().Diagnostics:LegacyScriptMode() end)
|
||||||
|
|
||||||
-----------------------------------START GAME SHARED SCRIPT------------------------------
|
-----------------------------------START GAME SHARED SCRIPT------------------------------
|
||||||
|
|
||||||
local assetId = placeId
|
local scriptContext = game:GetService("ScriptContext")
|
||||||
|
|
||||||
local scriptContext = game:GetService('ScriptContext')
|
|
||||||
pcall(function() scriptContext:AddStarterScript(37801172) end)
|
pcall(function() scriptContext:AddStarterScript(37801172) end)
|
||||||
|
scriptContext.ScriptsDisabled = true
|
||||||
|
|
||||||
game:SetPlaceID(assetId, false)
|
game:SetPlaceID(placeId, false)
|
||||||
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
||||||
game:GetService("HttpService").HttpEnabled = true
|
|
||||||
|
|
||||||
local ns = game:GetService("NetworkServer")
|
local ns = game:GetService("NetworkServer")
|
||||||
|
|
||||||
if baseUrl ~= nil then
|
if baseUrl ~= nil then
|
||||||
pcall(function() game:GetService("Players"):SetAbuseReportUrl(baseUrl .. "/AbuseReport/InGameChatHandler.ashx") end)
|
pcall(function() game:GetService("Players"):SetAbuseReportUrl(baseUrl .. "/AbuseReport/InGameChatHandler.ashx") end)
|
||||||
pcall(function() game:GetService("ScriptInformationProvider"):SetAssetUrl(baseUrl .. "/Asset/") end)
|
pcall(function() game:GetService("ScriptInformationProvider"):SetAssetUrl(baseUrl .. "/Asset/") end)
|
||||||
pcall(function() game:GetService("ContentProvider"):SetBaseUrl(baseUrl .. "/") end)
|
pcall(function() game:GetService("ContentProvider"):SetBaseUrl(baseUrl .. "/") end)
|
||||||
|
pcall(function() game:GetService("Players"):SetChatFilterUrl(baseUrl .. "/Game/ChatFilter.ashx") end)
|
||||||
|
|
||||||
game:GetService("BadgeService"):SetPlaceId(placeId)
|
game:GetService("BadgeService"):SetPlaceId(placeId)
|
||||||
|
|
||||||
game:GetService("BadgeService"):SetAwardBadgeUrl(baseUrl .. "/assets/award-badge?userId=%d&badgeId=%d&placeId=%d")
|
|
||||||
game:GetService("BadgeService"):SetHasBadgeUrl(baseUrl .. "/Game/Badge/HasBadge.ashx?UserID=%d&BadgeID=%d")
|
|
||||||
game:GetService("BadgeService"):SetIsBadgeDisabledUrl(baseUrl .. "/Game/Badge/IsBadgeDisabled.ashx?BadgeID=%d&PlaceID=%d")
|
|
||||||
game:GetService("BadgeService"):SetIsBadgeLegalUrl("")
|
game:GetService("BadgeService"):SetIsBadgeLegalUrl("")
|
||||||
game:GetService("InsertService"):SetBaseSetsUrl(baseUrl .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
|
game:GetService("InsertService"):SetBaseSetsUrl(baseUrl .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
|
||||||
game:GetService("InsertService"):SetUserSetsUrl(baseUrl .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
|
game:GetService("InsertService"):SetUserSetsUrl(baseUrl .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
|
||||||
game:GetService("InsertService"):SetCollectionUrl(baseUrl .. "/Game/Tools/InsertAsset.ashx?sid=%d")
|
game:GetService("InsertService"):SetCollectionUrl(baseUrl .. "/Game/Tools/InsertAsset.ashx?sid=%d")
|
||||||
game:GetService("InsertService"):SetAssetUrl(baseUrl .. "/Asset/?id=%d")
|
game:GetService("InsertService"):SetAssetUrl(baseUrl .. "/Asset/?id=%d")
|
||||||
game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetversionid=%d")
|
game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetversionid=%d")
|
||||||
pcall(function() game:SetCreatorID(creatorId, Enum.CreatorType.User) end)
|
|
||||||
pcall(function() loadfile(baseUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
|
|
||||||
-- pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end)
|
|
||||||
game:GetService('Players'):SetSysStatsUrl('https://kapish.fun/Game/report-stats')
|
|
||||||
end
|
|
||||||
|
|
||||||
pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end)
|
pcall(function() loadfile(baseUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
|
||||||
|
pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end)
|
||||||
|
end
|
||||||
|
|
||||||
settings().Diagnostics.LuaRamLimit = 0
|
settings().Diagnostics.LuaRamLimit = 0
|
||||||
|
|
||||||
game:GetService("Players").PlayerAdded:connect(function(player)
|
game:GetService("Players").PlayerAdded:connect(function(player)
|
||||||
--print("Player " .. player.userId .. " added")
|
print("Player " .. player.userId .. " added")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:GetService("Players").PlayerRemoving:connect(function(player)
|
game:GetService("Players").PlayerRemoving:connect(function(player)
|
||||||
--print("Player " .. player.userId .. " leaving")
|
print("Player " .. player.userId .. " leaving")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if placeId~=nil and baseUrl~=nil then
|
if placeId ~= nil and baseUrl ~= nil then
|
||||||
wait()
|
wait()
|
||||||
game:Load("https://kapish.fun/asset/?id=" .. placeId .. "&placelol=true")
|
game:Load(baseUrl .. "/asset/?id=" .. placeId)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Now start the connection
|
ns:Start(port)
|
||||||
|
|
||||||
|
scriptContext:SetTimeout(10)
|
||||||
|
scriptContext.ScriptsDisabled = false
|
||||||
|
|
||||||
|
------------------------------END START GAME SHARED SCRIPT--------------------------
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
spawn(function()
|
|
||||||
while wait(5) do
|
|
||||||
local playerIds = ""
|
|
||||||
local players = game.Players:GetChildren()
|
|
||||||
for i, player in pairs(players) do
|
|
||||||
if player.ClassName == "Player" then
|
|
||||||
if i ~= #players then
|
|
||||||
playerIds = playerIds .. player.userId .. ","
|
|
||||||
else
|
|
||||||
playerIds = playerIds .. player.userId
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pcall(function() game:HttpGet('http://kapish.fun/server/ping/' .. placeId .. '?players=' .. playerIds) end)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
spawn(function()
|
|
||||||
while wait(60) do
|
|
||||||
if #game.Players:GetPlayers() == 0 then
|
|
||||||
pcall(function() game:HttpGet("https://kapish.fun/dielol/" .. placeId) end)
|
|
||||||
else
|
|
||||||
pcall(function() game:HttpGet("https://kapish.fun/renewlol/" .. placeId) end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
|
|
||||||
local Player = game.Players:CreateLocalPlayer(0)
|
local Player = game.Players:CreateLocalPlayer(0)
|
||||||
Player.CharacterAppearance = ("%s/Asset/CharacterFetch.ashx?userId=%d"):format(baseUrl, assetId)
|
Player.CharacterAppearance = ("%s/Character?id=%d"):format(baseUrl, assetId)
|
||||||
Player:LoadCharacter(false)
|
Player:LoadCharacter(false)
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
local jobId, type, format, x, y, baseUrl, assetId = ...
|
|
||||||
|
|
||||||
print(("[%s] Started RenderJob for type '%s' with assetId %d ..."):format(jobId, type, assetId))
|
|
||||||
|
|
||||||
game:GetService("ScriptInformationProvider"):SetAssetUrl(baseUrl .. "/asset/")
|
|
||||||
game:GetService("InsertService"):SetAssetUrl(baseUrl .. "/asset/?id=%d")
|
|
||||||
game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetversionid=%d")
|
|
||||||
game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
|
||||||
|
|
||||||
local meshPart = Instance.new("Part", workspace)
|
|
||||||
meshPart.Anchored = true
|
|
||||||
meshPart.Size = Vector3.new(1.5, 1.5, 1.5)
|
|
||||||
|
|
||||||
local mesh = Instance.new("SpecialMesh", meshPart)
|
|
||||||
mesh.MeshType = "FileMesh"
|
|
||||||
mesh.MeshId = ("%s/asset?id=%d"):format(baseUrl, assetId)
|
|
||||||
|
|
||||||
print(("[%s] Rendering ..."):format(jobId))
|
|
||||||
local result = game:GetService("ThumbnailGenerator"):Click(format, x, y, true)
|
|
||||||
print(("[%s] Done!"):format(jobId))
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
@ -11,7 +11,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
game:GetService("StarterGui").ShowDevelopmentGui = false
|
game:GetService("StarterGui").ShowDevelopmentGui = false
|
||||||
|
|
||||||
game:Load(("%s/asset/?id=%d&placelol=true"):format(baseUrl, assetId))
|
game:Load(("%s/asset/?id=%d"):format(baseUrl, assetId))
|
||||||
|
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
game:GetService("StarterGui").ShowDevelopmentGui = false
|
game:GetService("StarterGui").ShowDevelopmentGui = false
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ app.post("/:id", async (request, response) => {
|
||||||
if (!game) return response.status(404).json({ error: "Game is not running" })
|
if (!game) return response.status(404).json({ error: "Game is not running" })
|
||||||
|
|
||||||
const { script } = request.body
|
const { script } = request.body
|
||||||
const jobResponse = await game.Execute(randomUUID(), script).catch((_) => _)
|
const jobResponse = await game.Execute(randomUUID(), script)
|
||||||
|
|
||||||
return response.json({ response: jobResponse })
|
return response.json({ response: jobResponse })
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ app.get("/:id", async (request, response) => {
|
||||||
if (game) return response.status(400).json({ error: "Game is running" })
|
if (game) return response.status(400).json({ error: "Game is running" })
|
||||||
|
|
||||||
const job = new GameJob()
|
const job = new GameJob()
|
||||||
const result = await job.StartGame(request.params.id, request.query.port).catch((_) => _)
|
const result = await job.StartGame(request.params.id).catch((_) => _)
|
||||||
|
|
||||||
global.games.set(request.params.id, job)
|
global.games.set(request.params.id, job)
|
||||||
job.proc.once("exit", () => {
|
job.proc.once("exit", () => {
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
const express = require("express")
|
|
||||||
const app = express.Router()
|
|
||||||
|
|
||||||
const RenderJob = require("../../lib/classes/RenderJob.js")
|
|
||||||
|
|
||||||
app.get("/:id", async (request, response) => {
|
|
||||||
const { params, query } = request
|
|
||||||
const job = new RenderJob()
|
|
||||||
|
|
||||||
const asset = await job.RenderClothing(params.id).catch((_) => _)
|
|
||||||
if (asset?.message) return response.status(500).json({ error: asset.message })
|
|
||||||
|
|
||||||
return response.end(asset)
|
|
||||||
})
|
|
||||||
|
|
||||||
app.get("/:id/3d", async (request, response) => {
|
|
||||||
const { params, query } = request
|
|
||||||
const job = new RenderJob()
|
|
||||||
|
|
||||||
const three_d = await job.RenderClothing(params.id, true).catch((_) => _)
|
|
||||||
if (three_d?.message) return response.status(500).json({ error: three_d.message })
|
|
||||||
|
|
||||||
return response.json(JSON.parse(three_d))
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports = app
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
const express = require("express")
|
|
||||||
const app = express.Router()
|
|
||||||
|
|
||||||
const RenderJob = require("../../lib/classes/RenderJob.js")
|
|
||||||
|
|
||||||
app.get("/:id", async (request, response) => {
|
|
||||||
const { params, query } = request
|
|
||||||
const job = new RenderJob()
|
|
||||||
|
|
||||||
const asset = await job.RenderMesh(params.id).catch((_) => _)
|
|
||||||
if (asset?.message) return response.status(500).json({ error: asset.message })
|
|
||||||
|
|
||||||
return response.end(asset)
|
|
||||||
})
|
|
||||||
|
|
||||||
app.get("/:id/3d", async (request, response) => {
|
|
||||||
const { params, query } = request
|
|
||||||
const job = new RenderJob()
|
|
||||||
|
|
||||||
const three_d = await job.RenderMesh(params.id, true).catch((_) => _)
|
|
||||||
if (three_d?.message) return response.status(500).json({ error: three_d.message })
|
|
||||||
|
|
||||||
return response.json(JSON.parse(three_d))
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports = app
|
|
||||||
Loading…
Reference in New Issue