Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Advice on structuring large scripts?

Featured Replies

So im quite new to writing scripts, maybe 3 months i've been practicing.

First starting off like most, run everything in onLoop 😶, then i started with some bigger scripts and learned how to use task.

The problem i have is that still using task i find myself using dozens and dozens of booleans to trigger certain tasks to make sure nothing overlaps so that i don't have more than one task running at a time. 

 

Basically im just asking if anyone has any pointers for me on structure :)

Thank you.

It really depends on the type of script you are trying to make, but a general rule is to use Classes to instance major portions of the script that differ greatly from others.

Try and split everything up into smaller tasks, I currently do this for my minigame scripts I have a class for each activity in the script:

For my minigame scripts I use states so once you enter the craft runes state it will stay there until isAllowToLeave() is triggered, and I set each state manually in the onloop.

LY1ne5c.png

Ve5FrdP.png

4 hours ago, Czar said:

Try and split everything up into smaller tasks, I currently do this for my minigame scripts I have a class for each activity in the script:

For my minigame scripts I use states so once you enter the craft runes state it will stay there until isAllowToLeave() is triggered, and I set each state manually in the onloop.

LY1ne5c.png

Ve5FrdP.png

Ah brill thank you :) I have never tried using state so i will get learning thank you

 

Edit: Could you share an example please? 

Edited by shaba123

On 5/22/2023 at 10:00 PM, saintpaul1 said:

So im quite new to writing scripts, maybe 3 months i've been practicing.

First starting off like most, run everything in onLoop 😶, then i started with some bigger scripts and learned how to use task.

The problem i have is that still using task i find myself using dozens and dozens of booleans to trigger certain tasks to make sure nothing overlaps so that i don't have more than one task running at a time. 

 

Basically im just asking if anyone has any pointers for me on structure :)

Thank you.

  1. Use the Task system effectively: The Task system in OSBot is designed to handle different tasks independently. Instead of relying solely on booleans to control task execution, consider breaking down your script into smaller, modular tasks. Each task should have a clear purpose and be responsible for a specific action or set of actions. This approach can help you organize your code better and reduce the need for numerous flags.

  2. Utilize the sleepUntil condition: The sleepUntil condition is a powerful tool in OSBot that allows you to pause the script execution until a certain condition is met. Instead of using busy waiting loops with booleans, you can use sleepUntil to wait for specific conditions before proceeding to the next task. This can help you synchronize tasks and prevent overlapping.

  3. Implement task dependencies: If you have tasks that rely on the completion of other tasks, you can establish task dependencies. By setting up dependencies, you ensure that a task is only executed when its prerequisite tasks have finished. This can help you maintain a sequential flow and avoid conflicts between tasks.

  4. Consider using state machines: State machines provide a structured approach to handling different states and transitions within your script. You can define states that represent different phases or conditions of your script, and transitions that dictate when and how the script moves from one state to another. State machines can help you manage complex script logic and minimize the use of booleans.

  5. Plan and design your script beforehand: Before diving into writing code, spend some time planning and designing the structure of your script. Identify the different tasks, their dependencies, and the overall flow of your script. Having a clear plan in mind will make it easier to implement an organized structure from the beginning and avoid excessive use of booleans.

Remember, scripting is a learning process, and it's normal to iterate and refine your code as you gain experience. Don't be afraid to experiment with different approaches and techniques to find what works best for your specific script. Additionally, engaging with the OSBot community can provide valuable insights and feedback from experienced scripters who can offer further guidance.

22 hours ago, shaba123 said:

Ah brill thank you :) I have never tried using state so i will get learning thank you

 

Edit: Could you share an example please? 

 this might help you get started, PM with any questions

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.