jakjus / ts-haxball

TypeScript Template for Haxball Servers
MIT License
0 stars 2 forks source link

File is not defined #1

Closed byoxygen closed 2 years ago

byoxygen commented 2 years ago

Hi mate,

**form.append(null, new File([room.stopRecording()], `HBReplay-${RecSistem.getCustomDate()}.hbr2`, { type: "text/plain" }));
                                  ^
ReferenceError: File is not defined**

Why i am getting this error in your browser?

Please solve it.

jakjus commented 2 years ago

Is the room script written in TypeScript? I do not recognize .append method and File in TypeScript.

What extension this file has?

byoxygen commented 2 years ago

Is the room script written in TypeScript? I do not recognize .append method and File in TypeScript.

What extension this file has?

Hi @jakjus, I want to get .hbr files from DC but my code isn't work on haxball.js. I don't know how to run it.

Original code is here: https://github.com/hbenormous/haxball-headless-help/blob/main/scripts/enviar-rec.js

jakjus commented 2 years ago

This repository is not using haxball.js.

But as I know haxball.js - it is not using browser JavaScript, but NodeJS. So, some browser functions might be missing. To migrate these "missing" functions, try to Google it, like: "NodeJS File is not defined" or "NodeJS Xmlhttprequest" or whatever you need.

Here is what I found for File is not defined: https://stackoverflow.com/questions/48237766/file-is-not-defined-error-in-javascript-while-executing-from-node-js-command-p Here is what I found for XmlHttpRequest: https://stackoverflow.com/questions/34514363/how-to-use-xhr-api-in-node-js

You would have to use different ways to create and send this data from NodeJS script, it seems.

That's all I can help you with. Good luck 🎉

byoxygen commented 2 years ago

Hi @jakjus,

Many thanks for your helps. I tried these steps before but unfortunately it didn't work so.

I guess it is not possible to run with TS.

jakjus commented 2 years ago

Ah, so I thought that you have an issue with haxball.js. But, if it's an issue with this repo, I'll research it further.

jakjus commented 2 years ago

File interface is implemented in TypeScript's library: WebWorker

Trying to reproduce it, I have added function, that you have provided, to src/room.ts (in onPlayerChat - for fast debug purposes). It does not show any in-editor error. It has compiled successfully. It worked in a browser environment.

Screenshot from editor: Screenshot 2022-09-01 at 11 45 50

jakjus commented 2 years ago

Second question - what steps did you take in order to run this script and where did you run it? If you ran it in the browser on https://haxball.com/headless website (correct), what browser are you using?

jakjus commented 2 years ago

Closing (inactive and can't reproduce).