0

I'm trying to write a script for an auto bet (bustabit.com)

they have a manual about this on github

I want to read the "bust" object in the engine.history for writing an if statement

but I have no idea how javascript objects work ( i have not any experience in programming much )

I tried this but it's not working

if (engine.history(game.bust)=1.37){log("bust is 1.37")};

can someone help?

3
  • So what is the problem? Commented Nov 7, 2021 at 10:32
  • the = sign should be an == sign. Yup I know how that feels when u miss on that especially when a program is large.. if (engine.history(game.bust)==1.37){log("bust is 1.37")}; Commented Nov 7, 2021 at 10:35
  • Or try engine.history.toArray().filter(game => game.bust === 1.37). Just guessing. Commented Nov 7, 2021 at 10:48

1 Answer 1

1

The equal character is for assignment.

You should use == for equality checks read this

if (engine.history(game.bust)==1.37){log("bust is 1.37")};

Then

history(game.bust) means that history is a function which is taking a param which is is the value of the property bust inside the game object

Reading what are you sharing history has a method in it, which is going to cast the history to an array.

engine.history.toArray()

After that you can use array methods in order to find the history item you are looking for, for instance

const engineHistory = engine.history.toArray()
const element = engineHistory.find(historyItem => historyItem.bust == 1.37)
Sign up to request clarification or add additional context in comments.

2 Comments

if i want to add an if statement to this: const engineHistory = engine.history.toArray(); if(const element = engineHistory.find(historyItem => historyItem.bust == 1.14)) { notify(its working); }; like this ?
@anoobprogrammer it won't work like that, you can do something like this: if(element) console.log('its working') Because of the truthiness of the result of the array's found element, read here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.