bitburner-official / bitburner-src

Bitburner source code.
Other
781 stars 257 forks source link

Script autocomplete should have more data types provided #581

Closed Phlarx closed 3 months ago

Phlarx commented 1 year ago

Some data from the ns object would be very useful for setting up autocomplete. For example, I have wanted to use:

Snarling commented 1 year ago

Autocomplete does not pay any ramcost. We cannot provide access to ns in autocomplete.

But the types of data provided could be expanded to include some of those things.

ABruel commented 1 year ago

ns.enums.CrimeType is literally an enum. Just hardcode the values.

ABruel commented 1 year ago

ns.getPlayer() has RAM cost, probably won't be added.

ns.stock.getSymbols() does have RAM cost, but it also returns values of a fixed object, just hardcode it.

ns.corporation doesn't have RAM cost.

Phlarx commented 1 year ago

Just hardcode the values.

Thanks, I hadn't thought of that.

In all seriousness, I don't consider manually duplicating lists of data, no matter the size or content, a good solution. It's a solution that works, sure, but it's a bad smell and should be avoided when possible.

I wouldn't expect to be able to circumvent RAM calcs, that's a valid reason for not providing certain functionality; the list I gave are things I have wanted, it's perfectly reasonable that not all of them would or should be accessible.

ABruel commented 1 year ago

You joke as if you know everything when in fact you don't know half the capabilities of what you have in your hands.

Here, I'll make it easier to understand

  1. On your terminal write nano crime-types.js and press enter
  2. Write
    export const crimeTypes = {
    assassination: "Assassination", 
    bondForgery: "Bond Forgery", 
    dealDrugs: "Deal Drugs", 
    grandTheftAuto: "Grand Theft Auto", 
    heist: "Heist", 
    homicide: "Homicide", 
    kidnap: "Kidnap", 
    larceny: "Larceny", 
    mug: "Mug", 
    robStore: "Rob Store", 
    shoplift: "Shoplift", 
    traffickArms: "Traffick Arms"
    };
  3. Save
  4. Go back to your terminal
  5. On your terminal input nano print-crime-types.js and press enter
  6. Write
    
    import { crimeTypes } from './crime-types.js'

export async function main(ns) { ns.tprint(Object.values(crimeTypes).join(', ')); }


7. Save
8. Go back to your terminal
9. On your terminal input `run print-crime-types.js` and press *enter*
ABruel commented 1 year ago

An, in case I still wasn't obvious enough, let me make it clear that you can also use your imports inside other functions, including autocomplete.

You can also write other things inside the main function apart from printing. 🙃

d0sboots commented 1 year ago

You joke as if you know everything when in fact you don't know half the capabilities of what you have in your hands.

Please be polite; there's no call to be this sarcastic.

There are perfectly valid reasons for not wanting to duplicate data that the game already provides.

Phlarx commented 1 year ago

In addition, he seems to have missed the point of the discussion. I'd stated "I would like to do X without Y", and he'd responded "Here's how you do Y".

For the record, it is already possible to do X without Y, by utilizing the new shared script module behavior with 2.3.0. It's imperfect because it requires running the script once to initialize a top-level variable with the required data, but afterward it works without requiring duplicate data, nor polluting document or any other global object.

ABruel commented 1 year ago

There's no x without y here.

  1. You have a problem, you want information that's not available to you.
  2. I give you a perfectly reasonable solution for part of your problem. Sure, not all of it, but you can either do what you can with what you have and wait for the api to change, or just wait for the api to change. I don't really understand how you'd prefer to wait for something that could take weeks or months to maybe happen to get 100% instead of getting 20% now and maybe the other 80% later.
  3. You joke as if I should have known you had already thought about it, but decided against it because it would involve copy pasting information.
  4. I give you a sarcastic but correct step-by-step tutorial on how to do my initial solution without having to copy paste a lot of information.
  5. You dismiss it as "that's not what I want".

Well, I don't know what else to tell you. You have the tools to do it. It's not hard. It doesn't involve bad smell. So sure, if you prefer to just wait until it gets handed to you, feel free to wait.

without requiring duplicate data, nor polluting document or any other global object

My solution does not involve global variables, neither on document or anywhere. It also doesn't require you to run the script. Sure, it also doesn't work for things that require RAM, but as Snarling has stated, you won't be getting access to those anyway.

To be clear at no point I meant to say your idea is bad. I'm saying part of it is already perfectly accessible and you should implement it while the api isn't updated.

Phlarx commented 1 year ago

In 2), you make the assumption that I'm not already using the workarounds that both you and I have suggested. I did not ask for a tutorial; rather I responded that the request was still valid despite any alternative strategies. Perhaps it was a bit flippant, but that does not make it untrue.

I am hopeful that this capability will be added, yes, but it is naive to presume that I've put the world on hold waiting for a feature to be added. Please refrain from talking down to others when you don't have the whole picture. As this is not a forum for discussing github etiquette, I'll stop there.

catloversg commented 3 months ago

@d0sboots What do you think about adding static data from ns.enums to autocomplete data? Snarling seems to agree with expanding autocomplete data to include some provided data.

d0sboots commented 3 months ago

Seems reasonable to me.