Jump to content

States vs tasks?


Phaibooty

Recommended Posts

1 hour ago, liverare said:

Both have their pros and cons. You should look into trying all of them to understand them for yourself, where best they are applied and which you prefer to use.

Throughout my RS scripting life, I've gone through all the funky and wacky methods of doing stuff, but none of them have worked for me. What I've found works best for me is to just cut out all the bullshit:

spend_weekend.png

Don't program; just script.

Don't create dependencies; just duplicate them.

Can you provide some examples?

Link to comment
Share on other sites

6 minutes ago, Nugaex said:

Can you provide some examples?

This is something scruffy, but the logic's structured and easy to read:

if (isAtBank()) {
	
	if (isInventoryFull()) {
		
		if (isBankOpen()) {
			
			depositLoot();
			
		} else {
			
			openBank();
		}
		
	} else if (isLowOnSupplies()) {
		
		if (isBankOpen()) {
			
			withdrawSupplies();
			
		} else {
			
			openBank();
		}
		
	} else {
		
		if (isBankOpen()) {
			
			closeBank();
			
		} else {
			
			walkToMonsters();
		}
	}
	
} else if (isAtMonsters()) {
	
	// etc.
	
}

 

  • Like 1
Link to comment
Share on other sites

My first scripts were state based and then I discovered tasks.

 

As a noob who is shit at programming I find task based easier to troubleshoot, but really they are pretty much the same thing formatted differently.

 

Just my opinion, but I am bad at this so take it with a grain of salt.

 

 

11 minutes ago, Tom said:

tfw all these people are bragging about there 30 line onLoops while I'm sitting here with a 4 liner

Let me show you my Tut Island script and its 60+ classes, it would make you vomit!

Link to comment
Share on other sites

  • Alek locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...