Kay
Kay
Explore posts from servers
DDeno
Created by Kay on 6/3/2024 in #help
Emit with dynamic imports?
i was not talking about the deno compile command. i was talking abbout the deno emit package
4 replies
DDeno
Created by Kay on 4/4/2024 in #help
Log output from Deno.ChildProcess while its running
so id have smth like --allow-net=discord.com,gateway.discord.com,deno.land,0.0.0.0,someotherthing.net and so on
27 replies
DDeno
Created by Kay on 4/4/2024 in #help
Log output from Deno.ChildProcess while its running
i did. its just that a huge list of websites in the command is a pain to read and modify
27 replies
DDeno
Created by Kay on 4/4/2024 in #help
Log output from Deno.ChildProcess while its running
couse im pretty sure there is no other way to specify allows and denies other than in the tasks
27 replies
DDeno
Created by Kay on 4/4/2024 in #help
Log output from Deno.ChildProcess while its running
yhea im just using Deno.Command to easely generate the command. i want to limit it to only the apis it needs and nothing else and to create a huge list in the deno.json file is a bit cluttered so i wanted to just generate it and store it in a way that can be read and modified better
27 replies
DDeno
Created by Kay on 4/4/2024 in #help
Log output from Deno.ChildProcess while its running
ohh
27 replies
DDeno
Created by Kay on 4/4/2024 in #help
Log output from Deno.ChildProcess while its running
yhea the process im running is deno so that should be fine right?
27 replies
DDeno
Created by Kay on 4/4/2024 in #help
Log output from Deno.ChildProcess while its running
i did a quick search and stackoverflow said i also could use inherit for the stdout and stderr. whats the difference?
27 replies
DDeno
Created by Kay on 4/4/2024 in #help
Log output from Deno.ChildProcess while its running
whats that and how do i implement it?
27 replies
DDeno
Created by Kay on 4/4/2024 in #help
Log output from Deno.ChildProcess while its running
i do need to spawn it but i dont want to wait for the output. is there a way to get live output from the process?
27 replies
DDeno
Created by Kay on 4/1/2024 in #help
Interface with unknown amount of keys but all the same type
alrr thx
3 replies
DDeno
Created by Kay on 3/31/2024 in #help
Deno deploy running my code multiple times
alrr how do i run my bot in a singleton patern then?
4 replies
DDeno
Created by Kay on 3/1/2024 in #help
Get image from automated download
but thx for the help. still used part of your code to get the image from the data url
32 replies
DDeno
Created by Kay on 3/1/2024 in #help
Get image from automated download
sorry nvm its working. had to change the image size to a standard of 16 (the width of the crafting grid)
32 replies
DDeno
Created by Kay on 3/1/2024 in #help
Get image from automated download
the width of the stone image is also logging just fine so it clearly has the image. its just not putting it in
32 replies
DDeno
Created by Kay on 3/1/2024 in #help
Get image from automated download
No description
32 replies
DDeno
Created by Kay on 3/1/2024 in #help
Get image from automated download
and here it loads the image:
export default async function generateBlock(block: string): Promise<Image> {

if (!existsSync("./tmp/" + block + ".png")) {
if (!existsSync("./tmp")) Deno.mkdirSync("./tmp");
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("http://localhost:8000/renderer/index.html?material=" + block);
await sleep(100);
const data = await page.evaluate(() => document.body.textContent);

const dataResponse = await fetch(data);
const file = await Deno.open("./tmp/" + block + ".png", {create: true, write: true});
await dataResponse.body?.pipeTo(file.writable);
}

return await loadImage("./tmp/" + block + ".png");
}
export default async function generateBlock(block: string): Promise<Image> {

if (!existsSync("./tmp/" + block + ".png")) {
if (!existsSync("./tmp")) Deno.mkdirSync("./tmp");
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("http://localhost:8000/renderer/index.html?material=" + block);
await sleep(100);
const data = await page.evaluate(() => document.body.textContent);

const dataResponse = await fetch(data);
const file = await Deno.open("./tmp/" + block + ".png", {create: true, write: true});
await dataResponse.body?.pipeTo(file.writable);
}

return await loadImage("./tmp/" + block + ".png");
}
32 replies
DDeno
Created by Kay on 3/1/2024 in #help
Get image from automated download
got another problem now is that the image wont show. this is the code where it puts the items on the crafting grid:
let i = 0;
for (const item of recipe.items) {
if (item == null) {
i ++;
continue;
}
const itemTexture: Image = await getTexture(item);
console.log(itemTexture.width(), itemTexture.height());
ctx.drawImage(itemTexture, slots[i][0] * recipe.size_multiplier, slots[i][1] * recipe.size_multiplier, itemTexture.width() * recipe.size_multiplier, itemTexture.height() * recipe.size_multiplier);
i ++;
}
let i = 0;
for (const item of recipe.items) {
if (item == null) {
i ++;
continue;
}
const itemTexture: Image = await getTexture(item);
console.log(itemTexture.width(), itemTexture.height());
ctx.drawImage(itemTexture, slots[i][0] * recipe.size_multiplier, slots[i][1] * recipe.size_multiplier, itemTexture.width() * recipe.size_multiplier, itemTexture.height() * recipe.size_multiplier);
i ++;
}
getTexture function:
async function getTexture(item: string): Promise<Image> {
const itemModel: ItemModel = await import("./assets/minecraft/models/item/" + item + ".json", {with: {type: "json"}}).then(value => value.default);
if (itemModel.parent == "minecraft:item/generated") {
return await loadImage("./assets/minecraft/textures/" + itemModel.textures.layer0.substring(10) + ".png");
}
const parentModel: ItemModel = await import("./assets/minecraft/models/" + itemModel.parent.substring(10) + ".json", {with: {type: "json"}}).then(value => value.default);
if (parentModel.parent == "minecraft:block/cube_all") {
return await generateBlock(item);
}
throw `unsupported model format '${itemModel.parent}'`
}
async function getTexture(item: string): Promise<Image> {
const itemModel: ItemModel = await import("./assets/minecraft/models/item/" + item + ".json", {with: {type: "json"}}).then(value => value.default);
if (itemModel.parent == "minecraft:item/generated") {
return await loadImage("./assets/minecraft/textures/" + itemModel.textures.layer0.substring(10) + ".png");
}
const parentModel: ItemModel = await import("./assets/minecraft/models/" + itemModel.parent.substring(10) + ".json", {with: {type: "json"}}).then(value => value.default);
if (parentModel.parent == "minecraft:block/cube_all") {
return await generateBlock(item);
}
throw `unsupported model format '${itemModel.parent}'`
}
32 replies
DDeno
Created by Kay on 3/1/2024 in #help
Get image from automated download
ohh thats cool. already figured out another way tho. mabye a bit slower but idc abb speed. i made the renderer set the textContent to the dataUrl and use puppeteer to load the page, wait for the data to be put in the body and turn the data into an image.
32 replies
DDeno
Created by Kay on 3/1/2024 in #help
Get image from automated download
or mabye be able to export the threejs render in a different way so i can access it
32 replies