Jump to content

Gui & Area..


Supercharger

Recommended Posts

Hey Guys,

 

So haven't prorammed or scripted for a long time and excited to get back into it and learning it agian.

 

I want to implement a working GUI and I don't know how. I've made a good GUI with WindowsBuilder in eclipse but I don't know how to program it into make it work.. Would anybody be able to help me out?

 

Also,

 

http://osbot.org/forum/topic/60921-areapositionmyplayer/

 

I'm looking to add checking if the play is an area like this thread, but I'm curious to know how to I make the area like, what are the coordinates I see the Method as Area(Int, Int, Int, Int). How is that composed of? Like... What is the first, second, third, and fourth int?

Link to comment
Share on other sites

here is some more detail on area's

 

if you have a area you want to make imagine a square has four edges, you need to diagonally oppersite edges to make that square in your script. Look at the image below:

2f87bdeba1.png

 

I have wrote down two sets of X & Y co'ordinates. The top left and the top right. So top left you have X = 1318 and Y = 3238. Bottom right we have X = 1320 and Y = 3240. Now you have your box or area. We need to put this into our script.

We first need to declare the area. This can put put at the top of your script under:

public class YourScriptName extends Script
{
   // put area declaration here

so what code do we put? ok so look at the code below then i'l explain it.

Area areaName = new Area(1234,1234,1234,1234);

ok so look at the code above. We have Area which you should always put first, its saying you are going to declare a new area. then you see ' areaName ' this is going to be the name of your area so you could call it something like ' bankArea ' or ' cuttingArea ' just make sure its one word no spaces. You can use underscores if you wish. Use basic variable naming conventions. After the name of our area we have four co'ordinates 1234 1234 1234 1234 these are the X and Y co'ordinates. If we use the picture above i showed you as an example it would be:

Area areaName = new Area(1320,3240,1318,3238);

notice i put the bottom right set first, then the top right set. This is how i was told to do it when i learnt and its worked for me in all my scripts, there may be other ways as Josed said above. So now you have delcared your area at the top of your script you need to use that code. So lets have another example. Imagine if you will that you want to know if your player is in a bank. You can use something like this:

if(areaName.contains(myPlayer())
{
   // do something
}

I have used the same area name as before so not to confuse you but you put the name of your area. then a full stop and then you can test that area for players, variables, objects etc. I have chosen to use myPlayer() as we wanted to check if our player was within an area.

 

if you need any more help post back here smile.png

 

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

SECOND POST FOR YOU.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

 

also here is an example gui class is just whipped up for you, i tried to comment most of it so you can follow whats happening, any question post here.

 

  Reveal hidden contents
Edited by Pug
  • Like 3
Link to comment
Share on other sites

  On 10/22/2014 at 12:26 PM, Pug said:

here is some more detail on area's

if you have a area you want to make imagine a square has four edges, you need to diagonally oppersite edges to make that square in your script. Look at the image below:

2f87bdeba1.png

I have wrote down two sets of X & Y co'ordinates. The top left and the top right. So top left you have X = 1318 and Y = 3238. Bottom right we have X = 1320 and Y = 3240. Now you have your box or area. We need to put this into our script.

We first need to declare the area. This can put put at the top of your script under:

public class YourScriptName extends Script{   // put area declaration here

so what code do we put? ok so look at the code below then i'l explain it.

Area areaName = new Area(1234,1234,1234,1234);

ok so look at the code above. We have Area which you should always put first, its saying you are going to declare a new area. then you see ' areaName ' this is going to be the name of your area so you could call it something like ' bankArea ' or ' cuttingArea ' just make sure its one word no spaces. You can use underscores if you wish. Use basic variable naming conventions. After the name of our area we have four co'ordinates 1234 1234 1234 1234 these are the X and Y co'ordinates. If we use the picture above i showed you as an example it would be:

Area areaName = new Area(1320,3240,1318,3238);

notice i put the bottom right set first, then the top right set. This is how i was told to do it when i learnt and its worked for me in all my scripts, there may be other ways as Josed said above. So now you have delcared your area at the top of your script you need to use that code. So lets have another example. Imagine if you will that you want to know if your player is in a bank. You can use something like this:

if(areaName.contains(myPlayer()){   // do something}

I have used the same area name as before so not to confuse you but you put the name of your area. then a full stop and then you can test that area for players, variables, objects etc. I have chosen to use myPlayer() as we wanted to check if our player was within an area.

if you need any more help post back here smile.png

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

SECOND POST FOR YOU.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

also here is an example gui class is just whipped up for you, i tried to comment most of it so you can follow whats happening, any question post here.

  Reveal hidden contents

You should really be using a boolean to determine whether the start button has been pushed (with an accessor, I hate when people make things static "because it works"). Checking for if the GUI is visible is a terrible choice, as you should always make decisions based on the source of truth (in this case the start button).

Also, work on your variable names. "theSource" for an array of rune names makes no sense what so ever.

Link to comment
Share on other sites

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

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