Jump to content

NodeFragment and NodeLinking Systems


fixthissite

Recommended Posts

Seems I forgot to set the initial "currentNodeSet". I uploaded this without testing, which seems to always be a problem. I'll make sure to test anything I release in the future tongue.png

To fix this, you're going to need to find a set that best fits your bot when it starts. You can do this in a few different ways.

I recommend setting it in onStart, right before continuing to onLoop:

 

void onStart() {
    manager.add(...);
    manager.add(...);
    manager.initCurrentSet();
}
Within the Manager class, you would add

 

public void initCurrentSet() {
    for(Node node : allNodes.values()) {
        if(node.canProcess()) {
            currentNodeSet = nodeSets.get(node);
            break;
        }
    }
}
I'll be fixing this up shortly after my current project, which will make it easier for people to apply it to their scripts. Sorry for the inconvienence (wrote these systems from my phone :s)

Thanks for your time answering, and as always, the incredible detailed posts.

However, should I make a ArrayList to get all the current nodes? As you haven't defined AllNodes.

EDIT:

 

public void initCurrentSet() {
		for (Node node : NodeLinkerManager.allNodes.values()) {
			if (node.validate()) {
				NodeLinkerManager.currentNodeSet = NodeLinkerManager.nodeSet.get(node);
				break;
			}
		}
EDIT2:

I guess you ment the NodeLinkerManager, rather than the class Manager. smile.png

Edited by Psvxe
  • Like 1
Link to comment
Share on other sites

Still gives me a error.

 

[ERROR][Bot #1][06/30 09:08:10 PM]: Error in script executor!
java.lang.NullPointerException
	at fts.linked.NodeLinkerManager.run(NodeLinkerManager.java:49)
	at nl.psvxe.scripts.fightcave.Manager.onLoop(Manager.java:37)
	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(qh:114)
	at java.lang.Thread.run(Unknown Source)
Same codes, just did what you said. Edited by Psvxe
Link to comment
Share on other sites

 

After taking another look at the code, I've made a fatal mistake.

The nodeSet map is mapping class types to node:

Map<Class<? extends Node>, Node[]> nodeSet; //should be named nodeSetMap

But in initCurrentSet, I told you to do nodeSet.get(node), when node is an instance of the class, not the class type (since allNodes.values() returns a Set<Node> and not a Set<Class<? extends Node>>).

Map<Class<? extends Node>, Node> allNodes;

for(Node node : allNodes.values()) {
    if(node.canProcess()) {
        currentNodeSet = nodeSet.get(node);
        break;
    }
}

What I told you before (the code I just showed) should have actually generated a compiler error.

 

On top of that, I found a few little mistakes I didn't tend to (such as validating that you actually specified nodes in @Linked), so try this out:

 

 
It's still messy. The fixes I added were quick fixes (making the design look even messier), but I'm cleaning this up as we speak, since apparently a re-upload is much needed. Let me know if the new LinkerManager works for you! smile.png
 
And thank you for finding these problems for me. As I've said before, I've never actually ran this. I released it shortly after the person who requested it told me he got it working (with a few minor tweaks). Never release without testing X_X
Edited by fixthissite
  • Like 1
Link to comment
Share on other sites

After taking another look at the code, I've made a fatal mistake.

The nodeSet map is mapping class types to node:

Map<Class<? extends Node>, Node[]> nodeSet; //should be named nodeSetMap
But in initCurrentSet, I told you to do nodeSet.get(node), when node is an instance of the class, not the class type (since allNodes.values() returns a Set<Node> and not a Set<Class<? extends Node>>).

Map<Class<? extends Node>, Node> allNodes;

for(Node node : allNodes.values()) {
    if(node.canProcess()) {
        currentNodeSet = nodeSet.get(node);
        break;
    }
}
What I told you before (the code I just showed) should have actually generated a compiler error.

 

On top of that, I found a few little mistakes I didn't tend to (such as validating that you actually specified nodes in @Linked), so try this out:

 

http://pastebin.com/QHTEg53H

 

It's still messy. The fixes I added were quick fixes (making the design look even messier), but I'm cleaning this up as we speak, since apparently a re-upload is much needed. Let me know if the new LinkerManager works for you! smile.png

 

And thank you for finding these problems for me. As I've said before, I've never actually ran this. I released it shortly after the person who requested it told me he got it working (with a few minor tweaks). Never release without testing X_X

Well, it's impossible to had it fully running. Doubt the guy implemented it right, lewl.

The pastebin gives compile errors. At the moment I'm fixing them. Do you have way of talking outside the forums? Or could you enable your PM system?

Link to comment
Share on other sites

Well, it's impossible to had it fully running. Doubt the guy implemented it right, lewl.

The pastebin gives compile errors. At the moment I'm fixing them. Do you have way of talking outside the forums? Or could you enable your PM system?

Didn't realize my pm system was disabled. I'm not sure how to re-enable it. I'll send you a message (which hopefully you could reply to).

I couldn't run the final pastebin I uploaded (not at a computer, so I removed references of OSBot before testing), but I ran a mock version of it which worked fine. Hopefully I didn't mess anything up while re-implementing the OSBot stuff (the MethodProvider reference)

Link to comment
Share on other sites

Didn't realize my pm system was disabled. I'm not sure how to re-enable it. I'll send you a message (which hopefully you could reply to).

I couldn't run the final pastebin I uploaded (not at a computer, so I removed references of OSBot before testing), but I ran a mock version of it which worked fine. Hopefully I didn't mess anything up while re-implementing the OSBot stuff (the MethodProvider reference)

I kept the imports from the old file and replaced all the other with the pastebin version.

Compile error 1:

42b75c8f30.png

Fix:

69e5444a7f.png

Compile error 2:

e704aaeaae.png

Fix:

0b3a99264c.png

Compile error 3:

9eaf85ce45.png

Fix:

????

Link to comment
Share on other sites

I kept the imports from the old file and replaced all the other with the pastebin version.

Compile error 1:

42b75c8f30.png

Fix:

69e5444a7f.png

Compile error 2:

e704aaeaae.png

Fix:

0b3a99264c.png

Compile error 3:

9eaf85ce45.png

Fix:

????

True champ :) For the first one, we need to check if the array passed in (through the parameters) has at least 1 value. Change linkedNodes.length (in the original code, not the one you modified) to linkedNodeTypes.length.

The second one, you should actually be initializing the currentNodeSet variable with the value obtained from nodeSet.get(node). Change that line to

currentNodeSet = nodeSet.get(node);

For the last one, replace put(nodeType, linkNodes(...)) with put(node, linkNodes(...))

I promise these kinds difficulties will not appear in future guides/snippits. I'm not at home right now, so I can't do much when it comes to running the code I release on here, and if I only released these things while I was on a computer, I'd never get to it (too many other things to focus on while on a computer). But I will make sure others have tested before releasing anything in the future.

As for the other guy implementing it right, keep in mind that not everyone is at the same programming skill level. He probably saw the problems himself and fixed it up

Edited by fixthissite
  • Like 1
Link to comment
Share on other sites

True champ smile.png For the first one, we need to check if the array passed in (through the parameters) has at least 1 value. Change linkedNodes.length (in the original code, not the one you modified) to linkedNodeTypes.length.

The second one, you should actually be initializing the currentNodeSet variable with the value obtained from nodeSet.get(node). Change that line to

currentNodeSet = nodeSet.get(node);

For the last one, replace put(nodeType, linkNodes(...)) with put(node, linkNodes(...))

Error, once again. haha

[ERROR][Bot #1][06/30 11:11:11 PM]: Error in script executor!
java.lang.NullPointerException
	at fts.linked.NodeLinkerManager.run(NodeLinkerManager.java:64)
	at nl.psvxe.scripts.fightcave.Manager.onLoop(Manager.java:37)
	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(qh:114)
	at java.lang.Thread.run(Unknown Source)
 public void run() {
            for(Node node : currentNodeSet) { // <----- line of problem.
                    if(node.validate()) {
                            currentNodeSet = nodeSet.get(node.getClass());
                            node.execute();
                    }
            }
Link to comment
Share on other sites

Error, once again. haha

[ERROR][Bot #1][06/30 11:11:11 PM]: Error in script executor!java.lang.NullPointerException	at fts.linked.NodeLinkerManager.run(NodeLinkerManager.java:64)	at nl.psvxe.scripts.fightcave.Manager.onLoop(Manager.java:37)	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(qh:114)	at java.lang.Thread.run(Unknown Source)
public void run() {            for(Node node : currentNodeSet) { // <----- line of problem.                    if(node.validate()) {                            currentNodeSet = nodeSet.get(node.getClass());                            node.execute();                    }            }
This is the version I actually tested:

http://pastebin.com/ukJPBLhA

You're going to need to add the constructor which access the MethodProvider, then go down to getConstructor().newInstance() and pass it to the newInstace() method.

The previous pastebin I sent you was me trying to apply the changes from the version I actually tested to the version with the MethodProvider already implemented. This is the one I have ran, which I know works. You're going to have to fix up the imports, though.

The other version should have worked after the changes, though. Are you sure you called "initCurrentSettings" in onStart()? And you've change nodeSet.get(node) to currentNodeSet = nodeSet.get(node) in initCurrentSettings, yeah? currentNodeSet should not be null. If it is, that means the value isn't in the map, which I've added to the map in the add method [nodeSet.put(node, linkNodes(...))].

I tried messaging you, but it keeps on saying the site lost connection. Idk what's wrong, I'ma have to report it.

Edited by fixthissite
Link to comment
Share on other sites

This is the version I actually tested:

http://pastebin.com/ukJPBLhA

You're going to need to add the constructor which access the MethodProvider, then go down to getConstructor().newInstance() and pass it to the newInstace() method.

The previous pastebin I sent you was me trying to apply the changes from the version I actually tested to the version with the MethodProvider already implemented. This is the one I have ran, which I know works. You're going to have to fix up the imports, though.

The other version should have worked after the changes, though. Are you sure you called "initCurrentSettings" in onStart()? And you've change nodeSet.get(node) to currentNodeSet = nodeSet.get(node) in initCurrentSettings, yeah? currentNodeSet should not be null. If it is, that means the value isn't in the map, which I've added to the map in the add method [nodeSet.put(node, linkNodes(...))].

I tried messaging you, but it keeps on saying the site lost connection. Idk what's wrong, I'ma have to report it.

	@Override
	public void onStart() {
		manager = new NodeLinkerManager(this);
		try {
			manager.add(AttackHandler.class);
			manager.add(EatHandler.class);
		} catch (InstantiationException | IllegalAccessException | InvocationTargetException
				| NoSuchMethodException e) {
			e.printStackTrace();
		}
		manager.initCurrentSet();
	}
(tried both in the try catch block, and outside)

 public void initCurrentSet() {
        for(Node node : allNodes.values()) {
                if(node.validate()) {
                        currentNodeSet = nodeSet.get(node);
                        return;
                }
        }
       
        throw new IllegalStateException("No nodes can be processed");
}
Do you have teamviewer or skype?
Link to comment
Share on other sites

	@Override
	public void onStart() {
		manager = new NodeLinkerManager(this);
		try {
			manager.add(AttackHandler.class);
			manager.add(EatHandler.class);
		} catch (InstantiationException | IllegalAccessException | InvocationTargetException
				| NoSuchMethodException e) {
			e.printStackTrace();
		}
		manager.initCurrentSet();
	}
(tried both in the try catch block, and outside)

 public void initCurrentSet() {
        for(Node node : allNodes.values()) {
                if(node.validate()) {
                        currentNodeSet = nodeSet.get(node);
                        return;
                }
        }
       
        throw new IllegalStateException("No nodes can be processed");
}
Do you have teamviewer or skype?

 

Please meet me in the Chatbox and I'll give you my skype there

Link to comment
Share on other sites

Team view the poor guy

I did. We found out that

1. I forgot to set the retention policy for the annotations. For some reason, AIDE (my mobile IDE) doesn't care for the retention of annotations

2. He was attempting to use the two systems (link and fragment) as one, which I have mentioned does not work with the first release. I created an integrated version, but apparently I forgot to release it.

I'll be revamping this entire thread, with a working, cleaner version of these systems that wirk seemlessly together. Sorry for the inconvienence people.

Take this as an example of what not to do when releasing snippits :P

Edited by fixthissite
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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