Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

c#2Bot

scripting tutorial
[Video/Text Tutorials] From java basics to writing simple scripts [Eclipse]

37 posts in this topic

Why am i making this tutorial?

 

  • The main aim of this tutorial is to introduce you to the basics of java and get you around understanding Tribot's API.
  • Additionally, through this tutorial i hope to aid people who are trying to learn scripting, and by that increase the number of free scripts.

___________________________________________________________________________________________________________________________________________

"Basic" Introduction To Java

Lesson 1: Classes

Quote

1.1 What is a class?

A class can be referred to as the template where objects can be created such as variables, methods, constructors or block.

df1b84480d.png

An empty class.

1.2 What are constructors?

Constructors are instance methods that allows you to create an instance of a certain class and setting objects values of that class to the values specified in its parameters.

451eb1e7b5.png

The constructor will set the private variable age value to the value of its parameter when a new Variable class instance is created.

6707a3620b.png

The constructor on the right side assignment is passing the value 20 to the new instance of the Variables class.

Lesson 2: Variables

Quote

2.1 What are variables?

A variable can be described as a name given to specific defined portion allocated within the memory. To elaborate:

385bb920ca.png

The image above illustrates data stored within the memory, all 6 objects are variables of the type Integer, to make those variables accessible it is necessary for us to name them, as all variables in the image are of the same type, naming them will make them unique and hence accessible.

8a0515f47f.png

2.2 What are the types of variables?

There are 3 types of variables: local, instance and static.

- Local Variables:

Local variables are the variables declared inside a method, constructor or blocks. Access modifiers cannot be used on local variables, and once they are declared, they cannot be accessed from another region other than where it has been declared. 

f098e18024.png

Error displayed when applying a modified to a local variable.

a5238f2fc3.png

Method copy shows the variable one is not used, and method print shows that variable one does not exist.

 

- Instance Variables:

Instance variables are the opposite of local variables, they are created inside a class but outside a method, constructor and block. Access modifiers can be applied to instance variables  however it cannot be declared as static.

beff0c1751.png

Methods copy and print can access the variable ten and twenty.

 

- Static Variables:

Similar to instance variables in terms of being declared inside a class but outside a method,constructor and block. Static variables can be access from outside class without creating an instance of its parent class.

7102f66e2e.png

A static variable has been declared in the Variables class.

b8a1ed7058.png

The static variable seventy is accessed by the method check in the class Methods without creating an instance of Variables class

Lesson 3: Access Modifiers

Quote

1.1 What are access modifiers?

Access modifiers define the level of accessibility of a variable,method,constructor and a class.

1.2 What are the types access modifiers?

There are four types of access modifiers: default,public,private and protected.

- Default Access Modifier

When you do not specify whether your object is public,private or protected, it is set to the default access modifier by default. For instance, if a variable is given a default access modifier, it will only be available for access only in classes in the same package as the parent class.

9a323d7f99.png7d64d40adf.png

variable test accessed from Variables class in the same package as Methods class.

645533fa35.png

variable test cannot be accessed from another package due to it having a default access modifier.

- Public Access Modifier

Allows your object to be accessible from anywhere.

 afd56b2d03.png5960a0dc68.png

variable test accessed from another package due to it having public access modifier.

- Private Access Modifier

Allows your object to be accessible only in its parent class.

46aa0df163.png5f94d228be.png

variable test cannot be accessed anywhere but in the parent class.

- Protected Access Modifier

Allows your object to be accessible in and out of parent class package only through inheritance.

2566179e30.png5161634562.png

method msg() can only be accessed through inheritance and by calling super. 

Lesson 4: Arrays

Quote

4.1 What are arrays?

An array can be considered as a collection of objects that are of the same type. Consider:

7286734814.png

For the sake of demonstration, lets consider this box of cows above to be an RSNPC array of cows, in this array of cows, we have 4 cow RSNPC objects, naturally each object within this array of cows hold an index which identifies its position in the array, the indexing starts from 0.


	private RSNPC cow1;
	private RSNPC cow2;
	private RSNPC cow3;
	private RSNPC cow4;

	private RSNPC[] cows = new RSNPC[] { cow1, cow2, cow3, cow4 };

This is how the box of cows in the previous image is represented in java

Lesson 5: Enums

Quote

5.1 What are enums?

Enums are data types that can store constant information as it is by nature static and final. We talked previously about arrays, in an enum when enum.values()  method is called, it returns an array that contains all the elements in the enum, while each element in the enum can store multiple types of data and provides easy way to access them. Have a look:

bbd5f82695.png591c4f6096.png

  In the above enum Cows, we have two objects, COWS and COW_CALVES, and they hold three attributes id, name and alive, on the right is how they can be accessed from the different class.

Lesson 6: Interfaces

Quote

6.1 What are interfaces?

Interfaces are reference objects similar to a class, where methods can be collected at, however methods in an interface are all abstract, while abstract is a non access modifier that allows a method to be declared without any implementation. When a class implements an interface, all the methods in the interface will be inherited and defined into the class itself, lets have  look below:

9c4e6fdad7.pnge9e628b650.png

  In the interface Variables we have methods collect() and drop() declared, while in Methods class which implements the interface Variables has inherited those methods and defined them.

 

___________________________________________________________________________________________________________________________________________

"Basic" Introduction To Tribot API

Lesson 1: Skeleton Script

Quote

1.1 How does a tribot script structure look?

First of all to make your java program an executable tribot script you will need to extend the class Script which will allow your program to inherit the run() method and implement it, this method will contain a collection of instructions that will be converted by the client to actions.

2107699c00.png

Extending the class Script into your program.

1.2 What is a script manifest?

Applying a script manifest into your script will allow tribot's script loader to properly categorize your script, give it a name and an author.

9185eb1f79.png

Adding a script manifest to your script.

137b93f480.png

How will your script be categorized in the script manager.

1.3 What is an infinite loop?

An infinite loop is a loop that will constantly, endlessly execute a set of instructions defined inside it due to the fact that its condition is always met,  can never be met, or having no stopping condition in the first place.

0819cb3a61.png

Under the method run(), we are asking the client to print a welcoming message for us when we run the script.

ad012c9c60.png

When the script started, the welcome message was printed and the script terminated because all instructions in run() were executed.

8397d47816.png

An infinite loop was introduced, and the client is asked to print a welcome message and sleep for a random amount of ms.

2b32834e93.png

When the script started, the client continuously printed the welcome message and slept for few ms due to it being stuck in the loop.

c0c540e702.png

Now a condition has been set in the loop, so the instructions under it will continue executing only while the condition is true.

b288870321.png

When the script was started, the client printed 5 welcoming messages and stopped the script as the condition in the loop became false.

Lesson 2: Entities

Quote

2.1 Debugging Entities

To debug entities and display information about this simply do as shown below:

70436432ab.gif

2.2 RSObjects

Through your scripting, you will frequently find yourself in a position to interact with certain objects, and in this section we will discuss how can we define our target object and how can we interact with it. We have discussed before in section 4 what are arrays, to recap arrays are collections that will store objects of the same type.

83e878f552.png

We have created a array of the type RSObject were we will be storing objects that happened to be doors, the array is now empty.

So we have decided that we want to interact with doors as our RSObjects, so how do we go on and store doors in our RSObject array, well tribot api provides us with a method that returns an RSObject[] when provided with certain parameters, lets have a look:

d5dbb71149.png

Now the method Objects.findNearest needs an int value parameter called distance which will be the distance it will search for the objects needed that has the same name that is given in the String value parameter called ids.

dab4adeb9b.png

Now that we have specified the required parameters, the request sent to the client is please find all objects that has the name "Door" and are within a 10 tiles radius from my character, and then kindly store them in my RSObject[] doors.

ba4472832f.png

Now lets ask our client to attempt to find us some doors based on the conditions we have specified in the above image.

11eef74d4c.png

Since my character did not have doors in 10 tiles radious, the client printed a notification that there are no doors available.

c6dba70370.jpg

Now that my character has two doors within 10 tiles radius, the client notified me that the length of my RSObject[] doors is 2, which means that i have two door objects stored in that array.

d24eac4838.png

Now that we have our doors stored in our RSObject[], before we start interacting, to avoid out of bounds exceptions and null pointer exceptions we check the RSObject[] doors length to be greater than 0, which basically means that check if out array is not empty or null, then if the length of the array is greater then 0 we cache the first object in the array that has an index of 0 in an RSObject named door, the task we want to perform is rotate the camera, however we cant rotate to the object if it is null, and we should only rotate when it is not on the screen.

ec105cf4d0.gif

This is what will the client do for the set of instructions in the previous image.

Now we know how to turn our camera to our desired door object, lets make things a little bit more complex, now let say we want the client to check if the door is on screen, then if it is on screen can we click it? if not wen walk closer to it, and all these tasks should be performed if the door is closed. Just to let you know in here i am going to introduce filters, but i will talk about those in depth in later sections.


	private RSObject[] grabAllDoors() {
		return Objects.findNearest(10, new Filter<RSObject>() {
			@Override
			public boolean accept(RSObject a) {
				RSObjectDefinition def =a.getDefinition(); // first we catch the object definition 
				if (def == null)//check if the object definitions exists
					return false;
				String[] actions = def.getActions();// cache the actions of the object
				if (actions.length == 0)//check if the actions exist
					return false;
				if (!Arrays.asList(actions).contains("Open"))// check if the object actions contains the action needed
					return false;
				return def.getName().equals("Door"); // return the objects with name Door after satisfying conditions above
			}

		});
	}

	private RSObject grabDoor() {
		RSObject[] objects = grabAllDoors();
		if (objects.length > 0) {
			return objects[0];// grab the first object from the array
		}
		return null;
	}

The method RSObject door() will grab our door object from the RSObject[] doors() method.


	@Override
	public void run() {
		while (true) {
			RSObject door = this.grabDoor();
			if (door == null)
				return;
			if (door.isOnScreen() && door.isClickable()) {
				door.click("Open");
			} else {
				Walking.walkTo(door);
			}
		}
	}

Now in our run() we will attempt to find any door that is closed and open it.

f376889986.gif

The client will execute the code in the run() method and this will be the result.

2.3 RSNPCs

Almost the same procedure is done with npcs compared to objects, lets say we want to kill a man, first we check if we are in combat, if not we find a man, then check if that man is in combat, if he is not, then we check if he is on screen, if not we walk to him, if he is then we kill him.


	private RSNPC[] grabNearMen() {
		return NPCs.findNearest(new Filter<RSNPC>() {
			@Override
			public boolean accept(RSNPC a) {
				RSNPCDefinition def = a.getDefinition();
				if (def == null)
					return false;
				return def.getName().equals("Man") && !a.isInCombat();
			}
		});
	}

	private RSNPC grabMan() {
		RSNPC[] objects = grabNearMen();
		if (objects.length > 0) {
			return objects[0];
		}
		return null;
	}

We grab out RSNPC man() from the RSNPC[] men() method.


	@Override
	public void run() {
		while (true) {
			RSNPC man = this.grabMan();
			if (!Combat.isUnderAttack()) {
				if (man == null)
					return;
				if (man.isOnScreen() && man.isClickable()) {
					man.click("Attack");
				} else {
					Walking.walkTo(man);
				}
			}
		}
	}

  We will attempt to kill the man based on the condition specified in the run() method.

a159731a5e.gif

The client will execute the code in the run() method and this will be the result.

2.3 Inventory items

I believe by now you understood the concept, if we wanted to interact with an item in the inventory, we will check if the item exists, and perform the necessary action like so:


	private RSItem[] grabAllInvItems(String item) {
		return Inventory.find(new Filter<RSItem>() {
			@Override
			public boolean accept(RSItem a) {
				RSItemDefinition def = a.getDefinition();
				if (def == null)
					return false;
				return def.getName().equals(item);
			}
		});
	}

	private RSItem grabInvItem(String item) {
		RSItem[] items = grabAllInvItems(item);
		if (items.length > 0) {
			return items[0];
		}
		return null;
	}

We are grabbing the bronzeSword() RSItem from the RSItem[] bronzeSwords() method.


	@Override
	public void run() {
			RSItem bronzeSword = this.grabInvItem("Bronze sword");
			if (bronzeSword != null)
				bronzeSword.click("Wield");
		}
	}

We null check the bronzeSword() item if it exists then we wield it.

48bc9498dc.gif

When we run the script, the client will perform the wield command and ends the script.

2.4 Ground items

Now all items will have the same procedure, its just that they of different types, lets consider some bones on the ground, how do we go on about looting them, what would be the steps? first we need to know if there are some bones around, if yes then are they on the screen? if not we walk to them, if they are then we loot them, so how do we do that in code? by now it should be very easy, lets have a look:


	private RSGroundItem[] grabNearGroundItems(String item) {
		return GroundItems.findNearest(new Filter<RSGroundItem>() {
			@Override
			public boolean accept(RSGroundItem a) {
				RSItemDefinition def = a.getDefinition();
				if (def == null)
					return false;
				return def.getName().equals(item);
			}
		});
	}

	private RSGroundItem grabGroundItem(String item) {
		RSGroundItem[] items = this.grabNearGroundItems(item);
		if (items.length == 0)
			return null;
		return items[0];
	}

We are grabbing the bone() RSGroundItem from the RSGroundItem[] bones() method.


	@Override
	public void run() {
		while (true) {
			RSGroundItem bones = this.grabGroundItem("Bones");
			if (bones == null)
				return;
			if (bones.isOnScreen() && bones.isClickable())
				bones.click("Take");
			else
				Walking.walkTo(bones);
		}
	}

We null check the bone()  grounditem if it exists then we take it.

fe6fc3b6c9.gif

When we run the script, the client will perform the take command and ends the script.

2.5 Bank items

The only difference with bank items is that we gotta be extra careful with those, we will have a bit more checks to perform, for instance lets say we want to grab some coins from the bank, so what should we do? yes first we check if the banking screen is open, if not we open the bank, if it is open we check if the bank items loaded because they take time to load, once they have loaded, we check if the coins actually exists in the bank, and if they do do we have the required amount, if we do we withdraw it, it not we stop the script. Now how do we put all these check into code, lets see how:


	private boolean withdraw(String item,int checkAmount,int withdrawAmount) {
		if (!this.itemAvailable(item,checkAmount))
			return false;
		return Banking.withdraw(withdrawAmount, item);
	}

	private boolean itemAvailable(String item,int amount) {
		RSItem[] coins = Banking.find(item);
		if (coins.length == 0)
			return false;
		return coins[0].getStack() >= amount;
	}

	private boolean bankItemLoaded() {
		RSItem[] items = Banking.getAll();
		if (items.length < 1)
			return false;
		return items.length >= 1;
	}

  With these methods we will check if the bank items has loaded, coins are available, and withdraw the coins


	@Override
	public void run() {
		while (true) {
		int withdrawAmount = 10;
		int checkAmount = 15;
		String coins = "Coins";

		if (Inventory.getCount(coins) < withdrawAmount) {
			if (Banking.isBankScreenOpen()) {
				if (this.bankItemLoaded())
					withdraw(coins, checkAmount, withdrawAmount);
				else
					sleep(50, 80);
			} else {
				Banking.openBank(); // this is a boolean method should be
									// checked if successful dw bout it for
									// nowfor now
			}
		}
		}
	}

In the run method, we will check whether or not we have 10 coins in our inventory, if not we check if the bank sreen is open, is not we open it, if yes we check if the bank items loaded, if they did then we withdraw.

f6ac6faba1.gif

When we run the script, the client will perform the withdraw() command .

Lesson 3: Filters

Quote

3.1 What are filters?

By now it should be understood that the client iterates through objects and returns them back as an array which you cache based on certain parameters that you specify, for instance lets take RSObject[] as an example, lets say we want to get a door object that is closed and we want to open it, normally this is how we would do it:


			RSObject[] doors = Objects.findNearest(10, "Door");

Basically based on the parameters specified, the client will look for all objects with the name door within a 10 tiles radius and store them for us in the RSObject[] doors, through which we will be able to command the client to do tasks with regards to these objects stored in the array. There is nothing wrong with this approach, however by implementing this, we will cache all door objects within the 10 tiles radius regardless of them being opened, or closed or whether they are in a certain area or not. However, through using filters, we can actually command the client to grab only the closed doors, and disregard the open ones into our array, lets have a look on how to use the filter:

 


	/*
	 * so what we are asking the client here, please grab all objects
	 * within a 10 tiles radius, that satisfy the conditions stated in the
	 * boolean method accept(), and store them in the RSObject[] doors
	 * please notice that it is important to specify the object type in <> 
	 * just like in an arraylist you have to specify the type String/Integer etc..
	 * 
	 */
	RSObject[] doors = Objects.findNearest(10, new Filter<RSObject>(){
		@Override
		public boolean accept(RSObject door) {
			/*
			 * first we cache the object definition
			 */
			RSObjectDefinition def = door.getDefinition();
			/*
			 * now we need to check if the door's definition is null, so that when we check its name
			 * it doesnt throw a null pointer exception as well
			 */
			if (def == null)
				return false;
			/*
			 * now what we need to do is determine whether the door is open or closed, how do we do
			 * that? simply check its actions, if it is closed it wont have the open action
			 */
			String[] actions = def.getActions();
			/*
			 * if the actions array doesnt have any objects "actions" we return false
			 */
			if (actions.length ==0)
				return false;
			/*
			 * if the actions array doesnt contain the action open that means the door is closed
			 * which means we shouldnt store it in the array, because we only want closed doors,
			 * hence we return false
			 */
			if (Arrays.asList(actions).contains("Open"))
				return false;
			/*
			 * now that we finally cleared out all our conditions, we specify the objects 
			 * characteristics that we want to be stored in our array, we want all doors,
			 * so we return that the object name should be equal to door
			 */
			return def.getName().equals("Door");
		}		
	});

 

Lesson 4: Abc2 + Open Source scripts

Quote

To my understanding i implemented ABC2 in my pest control script, you can have a look at it and my open sourced scripts here

Lesson 5: Developing a simple fishing script

Quote

 

 

 

Edited by c#2Bot
3 people like this

Share this post


Link to post
Share on other sites
10 hours ago, c#2Bot said:

Potentially increase the amount of free scripts to be used by everyone in the tribot community.

appreciate it, nice idea. i'm looking forward to see your guide

Edit: Thanks, awesome video guide, will help so much to beginners

Edited by rvqx
1 person likes this

Share this post


Link to post
Share on other sites

Love the new text guide, great job. Definitely a nice resource for beginners.

Keep up the good work.

1 person likes this

Share this post


Link to post
Share on other sites
Just now, Final Calibur said:

Love the new text guide, great job. Definitely a nice resource for beginners.

Keep up the good work.

@Final Calibur thanks mate for the support, i intend to start with the basic fundamentals of java, then start making short progressive videos on scripting, will try to make each video 20 mins max, hope this helps out.

1 person likes this

Share this post


Link to post
Share on other sites
On 7/31/2016 at 10:54 AM, c#2Bot said:

@Final Calibur thanks mate for the support, i intend to start with the basic fundamentals of java, then start making short progressive videos on scripting, will try to make each video 20 mins max, hope this helps out.

 

 

I would recommend staying away from making videos w/o commentary in general, they're just extremely hard to follow.

Share this post


Link to post
Share on other sites
6 hours ago, Sphiinx said:

 

I would recommend staying away from making videos w/o commentary in general, they're just extremely hard to follow.

They are just there to elaborate on the text tutorial and made as short as possible

Edited by c#2Bot

Share this post


Link to post
Share on other sites
On 7/31/2016 at 0:50 PM, Final Calibur said:

Love the new text guide, great job. Definitely a nice resource for beginners.

Keep up the good work.

I think it's a good resource. I've studied Java, but I have had to learn about scripting for Tribot and these tutorials really help!

1 person likes this

Share this post


Link to post
Share on other sites
	private RSObject[] doors() {
		return Objects.findNearest(10, new Filter<RSObject>() {
			@Override
			public boolean accept(RSObject a) {
				if (a == null)// we check if the object exists
					return false;
				if (a.getDefinition() == null)//check if the object definitions exists
					return false;
				String[] actions = a.getDefinition().getActions();// cache the actions of the object
				if (actions.length == 0)//check if the actions exist
					return false;
				if (!Arrays.asList(actions).contains("Open"))// check if the object actions contains the action needed
					return false;
				return a.getDefinition().getName().equals("Door"); // return the objects with name Door after satisfying conditions above
			}

		});
	}

	private RSObject door() {
		RSObject[] objects = doors();
		if (objects.length > 0) {
			return objects[0];// grab the first object from the array
		}
		return null;
	}

 

	@Override
	public void run() {
		while (true) {
			if (door() == null)
				return;
			if (door().isOnScreen() && door().isClickable()) {
				door().click("Open");
			} else {
				Walking.walkTo(door());
			}
		}
	}

 

These snippets, along with every other example you provided that uses the same format are absolutely terrible examples of scripting.

 

Your "door" function should only be called once and cached and act opon that rsobject, not every single time you are doing something with it you call it. Just like in your scripter application, which people said MULTIPLE times that you should be caching variables before calling them, this is another simple example of why people should be voting no.

@Override
	public void run() {
		while (true) {
			RSObject door = door(); //still terrible imo
			if (door != null) { //returning stops the script what if we want it to continue to run while we walk around
				if (door.isOnScreen() && door.isClickable()) {
					door.click("Open");
				} else {
					Walking.walkTo(door);
				}
			}
		}
	}

 

Naming is also fairly bad and not descriptive of what the functions do.

door() or doors() might be better to name getDoor() or getDoors() as a scripter can expect that they are retrieving something from that function.

 

1 person likes this

Share this post


Link to post
Share on other sites

@Deluxes i appreciate your concerns, your points are valid and they are true, and i agree there are points where i need to improve, i never said i am the number 1 tribot scripter, i am a candidate here i improve based on practice, its okay if you feel my code is terrible, thats your right, but i dont agree with your comments, in the snippets your quoting you can clearly see that i am explaining how test and debug, whether your want to continue the script or do something else thats up to you and actually included in the video where i am actually "constructing" a script , not in single area of my tutorial did i claim in my tutorial that these snippets are the best practices to implement, however i mentioned where possible that we are only testing and debuging and problem solving to find out how to overcome things.

i respect your opinion, and people are free to vote no or yes both are welcomed by me, i am not here to make a war space with you, all in all i do have some areas that i should improve, but my code works. feel free to find me wherever i post to criticize me, however dont make me feel like this is personal, and your trying to get me denied on something because we are both grown ups here right :) the tile speaks for itself, i do not need to justify any further, thank you anyways for your input, i appreciate the fact that you are an individual that care enough to follow up my work and progress thanks for boosting myself esteem. :D

Edited by c#2Bot
1 person likes this

Share this post


Link to post
Share on other sites

I recommend that no one follow this tutorial. It will only hamper your learning.

Share this post


Link to post
Share on other sites
9 minutes ago, Assume said:

I recommend that no one follow this tutorial. It will only hamper your learning.

What's a good alternative? 

Share this post


Link to post
Share on other sites
Just now, Germs said:

What's a good alternative? 

Derek Banas if you're trying to watch videos to learn.

2 people like this

Share this post


Link to post
Share on other sites
1 hour ago, Assume said:

I recommend that no one follow this tutorial. It will only hamper your learning.

You seem a little out to get this guy because he offended you on dischord... As your Bio suggests you're only making an ass out of yourself.

Share this post


Link to post
Share on other sites
13 minutes ago, HaydenTaylor said:

You seem a little out to get this guy because he offended you on dischord... As your Bio suggests you're only making an ass out of yourself.

I'm not out to get anyone. Just about everything in this tutorial is wrong and should not be followed. I'm not sure what assumptions you feel I am making here.

Share this post


Link to post
Share on other sites
14 minutes ago, Assume said:

I'm not out to get anyone. Just about everything in this tutorial is wrong and should not be followed. I'm not sure what assumptions you feel I am making here.

Lol everything here about java from a java book , apparantly oracle should start contracting with you. 

Share this post


Link to post
Share on other sites

Lesson 1:

1.1 Wrong. An object is a class.

1.2 Wrong. A Constructor is not an instance method. A constructor simply allows the constructing of an object. 

Lesson 2:

2.2 Wrong. There are many more than 3 types of variables. You wrote as if you were writing about scope. You are correct the 3 scopes are local, instances, and static. But those are not types of variables.

Lesson 4:

4.1 Wrong. You do not have 4 Cow objects. You have four string objects.

Lesson 5:

5.1 Wrong. Enums are not constant and final by default. The data stored in an enum is only constant and final if you so define the variables as constant and final. Also, constant an final are synonyms. There is no const or constant keyword in Java. Only final.

Lesson 6:

6.1 Not totally wrong but a terrible example to use.

Introduction to the API

2.2 You say a name is an ID. It is not. An ID is an ID. A name is a name. You don't even realize the API provides both find by ID and a find by name method.

An array returned by the Tribot API in relation to finding objects will NEVER contain a null object. Do not null check here.

 

When using a filter to find objects, you do not need to null check the passed object. It will never be null.

You grab the definition to check if it is null. You then grab the definition again if it is not null. There is no guarantee the second call will return a non-null object. Wrong.

You then repeat this once more. Wrong.

The same is all same for 2.2-2.4. All wrong.

 

For bankItemLoaded why would you write it like that. All you need is return Banking.getAll().length > 0. That's it. Done.

itemAvailable is terrible written. It does not convey what item it is looking for. Even if you knew what it is, available means >= 1 but you define it as >= 10. Why. Terrible. Wrong.

 

3.1 I already talked about how you did everything with filters wrong. 

 

 

 

So yeah. Most of it is wrong and no one should follow this.

Edited by Assume

Share this post


Link to post
Share on other sites
26 minutes ago, Assume said:

Lesson 1:

1.1 Wrong. An object is a class.

1.2 Wrong. A Constructor is not an instance method. A constructor simply allows the constructing of an object. 

Lesson 2:

2.2 Wrong. There are many more than 3 types of variables. You wrote as if you were writing about scope. You are correct the 3 scopes are local, instances, and static. But those are not types of variables.

Lesson 4:

4.1 Wrong. You do not have 4 Cow objects. You have four string objects.

Lesson 5:

5.1 Wrong. Enums are not constant and final by default. The data stored in an enum is only constant and final if you so define the variables as constant and final. Also, constant an final are synonyms. There is no const or constant keyword in Java. Only final.

Lesson 6:

6.1 Not totally wrong but a terrible example to use.

Introduction to the API

2.2 You say a name is an ID. It is not. An ID is an ID. A name is a name. You don't even realize the API provides both find by ID and a find by name method.

An array returned by the Tribot API in relation to finding objects will NEVER contain a null object. Do not null check here.

 

When using a filter to find objects, you do not need to null check the passed object. It will never be null.

You grab the definition to check if it is null. You then grab the definition again if it is not null. There is no guarantee the second call will return a non-null object. Wrong.

You then repeat this once more. Wrong.

The same is all same for 2.2-2.4. All wrong.

 

For bankItemLoaded why would you write it like that. All you need is return Banking.getAll().length > 0. That's it. Done.

itemAvailable is terrible written. It does not convey what item it is looking for. Even if you knew what it is, available means >= 1 but you define it as >= 10. Why. Terrible. Wrong.

 

3.1 I already talked about how you did everything with filters wrong. 

 

 

 

So yeah. Most of it is wrong and no one should follow this.

can you not read? for major parts of your qoutes it says FOR THE SAKE OF DEMONSTRATION LETS CONSIDER, seriously you have issues reading, i never said a class is an object, i said a class is a template where objects can be stored, please, either read the commentary or just stop "ASSUMING".

Share this post


Link to post
Share on other sites
1 minute ago, c#2Bot said:

can you not read? for major parts of your qoutes it says FOR THE SAKE OF DEMONSTRATION LETS CONSIDER, seriously you have issues reading, i never said a class is an object, i said a class is a template where objects can be stored, please, either read the commentary or just stop "ASSUMING".

WHY WOULD YOU MAKE A TUTORIAL FOR DEMONSTRATION PURPOSES THAT IS WRONG. DON'T MAKE A TUTORIAL IF YOU'RE NOT GOING TO DO THINGS CORRECTLY.

1 person likes this

Share this post


Link to post
Share on other sites
2 minutes ago, Assume said:

WHY WOULD YOU MAKE A TUTORIAL FOR DEMONSTRATION PURPOSES THAT IS WRONG. DON'T MAKE A TUTORIAL IF YOU'RE NOT GOING TO DO THINGS CORRECTLY.

its not wrong, your just self centered and lack the imagination to see the point of the tutorial, you dont know everything, dont think you have achieved mastery, you are experienced thats all. go research and then come chat shit, as i said i did not bring this tutorial from my ass, i was using a JAVA BOOK as my reference.

Share this post


Link to post
Share on other sites
1 minute ago, c#2Bot said:

its not wrong, your just self centered and lack the imagination to see the point of the tutorial, you dont know everything, dont think you have achieved mastery, you are experienced thats all. go research and then come chat shit, as i said i did not bring this tutorial from my ass, i was using a JAVA BOOK as my reference.

And somehow, you managed to do almost everything wrong. I do see the point of the tutorial, it just so happens you missed the point by teaching nothing correctly. 

Share this post


Link to post
Share on other sites
3 minutes ago, Assume said:

And somehow, you managed to do almost everything wrong. I do see the point of the tutorial, it just so happens you missed the point by teaching nothing correctly. 

your barely humble opinion remains an opinion, that i could or could not accept, it just shows your intentions and feelings by stating that EVERYTHING in this tutorial is wrong, i know whats this all about, and so do you, as i said, this tutorial is basic, if you enjoy the drama your causing and its amusing be my guest and continue, as of myself, i would rather invest this 30 seconds im using to reply to u in something useful, rather than let it go waste for you immature playground.

Share this post


Link to post
Share on other sites

really enjoyed your tutorial.

good job!

5 people like this

Share this post


Link to post
Share on other sites
5 minutes ago, c#2Bot said:

your barely humble opinion remains an opinion, that i could or could not accept, it just shows your intentions and feelings by stating that EVERYTHING in this tutorial is wrong, i know whats this all about, and so do you, as i said, this tutorial is basic, if you enjoy the drama your causing and its amusing be my guest and continue, as of myself, i would rather invest this 30 seconds im using to reply to u in something useful, rather than let it go waste for you immature playground.

There's definitely some useful information that can help beginners, but you make some misstakes like stated earlier. If you want to improve you'll have to accept constructive feedback and improve on that, especially if your goal is to learn people how to code.

Edited by swagg
1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.