Jump to content

Passing inventory.getItems() into my gui class


Recommended Posts

Posted (edited)

I created a gui class for my script. The only problem is I have a button in the gui that uses an action listener class that when pressed calls inventory.getItems() .. but it tells me that inventory is not a defined variable.. how would I pass the items[] into the gui when my button is called... yes i know it is not supposed to say sout, it is used for a debug in the main .. yes i  will change it to log later

4yAuIIr.png

Edited by javant
Posted

GetInventory().

method is undefined

MyGUI g = new MyGUI(Script script);

 

put script as one of the parameters...

 

then just call script.inventory.getItems()

 

script.getInventory().getItems() worked will that complete the same task.? Thank you soo much!

Posted (edited)

You have to pass the script object to if you want to acces it's methods, since we are not using a static API here.

The only reason you don't have to do that in the main class is because you extended your mainclass with the Script object.

 

Khaleesi

 

Just do this in main class:

GUI gui = new GUI(this);
gui.setVisible(true);

At GUI:

script.inventory.getItem("APA's mom <3");

Enjoy!

Edited by Khaleesi

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.
×
×
  • Create New...