Maybe he could answer like Michelangelo (Charlton Heston) in the movie, The Agony and the Ecstasy. " When you pry it from my cold dead hand!"... Woops .. wrong advertisement... oh yeah... "When I'm Finished!"
Posts by angriff
A new update is now available, introducing seasons and more!
Latest hotfix: 0.8.0.2 (2024-12-30)
Latest hotfix: 0.8.0.2 (2024-12-30)
-
-
Is there an admin command to change ownership of tame animals? We're cleaning up after some banned users and would like to remove their tames.
No requires editting the database. Probably could write your own plug in to do it. The author of the ABM could do it seamlessly though.
-
I also would like to see veggie and tree growth while we sleep, as in single player it takes ages for trees to grow and I would like to see them grow after we sleep
How much do vegetables grow in one night sleep?
-
thanks Red I figured out the issue was with my video cable .. so I got it working on my remote system by fixing that.
I have been having allot of stutters lately so I am trying to figure out if it is the server service or my computers.
-
The event can only give you the internal ID of the GuiElement, that ID is unique to that element but it can change every time the server restarts so I don't think of it as a reasonable number to use for defining my GuiElements.
If you want every player to have their own Gui and be able to interact with it independently of what other players do with the same Gui then the Gui must be saved as attributes on the Player object. If you just need a generic box that every player can click and something happens only for the player who clicked it but the Gui doesn't change by that click then you could have your Gui instanced only once and registering all the clicks from all players without it being player specific.
For example if you wanted to implement a generic heal button them you could just put a GuiLabel always visible on all of the players' screens and when any one of them clicked it then that player got healed, in this scenario there is no point in having a separate GuiLabel saved to the player as the label is not altered by what the player does with it (i.e. click it).Yep I clicked
I am an old man and learn slow. But I get the logic just dont get the back and forth about it. So it is somewhat of an experimental process because the java routines you see in videos are not already interacting with a functioning game.. thanks for the tutorials and help.. really ..
-
Here you go Trevor -- Thanks Minos as ever.
/respond Yes puts all three click areas on one GUI. Yes. No closeme
the no was left sort of the same. for reference. you can build out from here like I will..
package guitrevor;import net.risingworld.api.Plugin;
import net.risingworld.api.events.EventMethod;
import net.risingworld.api.events.Listener;
import net.risingworld.api.events.player.PlayerCommandEvent;
import net.risingworld.api.events.player.PlayerSpawnEvent;
import net.risingworld.api.gui.GuiLabel;
import net.risingworld.api.gui.GuiPanel;
import net.risingworld.api.gui.GuiElement;
import net.risingworld.api.events.player.gui.PlayerGuiElementClickEvent;
//import net.risingworld.api.events.player.PlayerElementInteractionEvent;
import net.risingworld.api.gui.Font;
import net.risingworld.api.gui.PivotPosition;
import net.risingworld.api.utils.ImageInformation;
import net.risingworld.api.gui.GuiImage;
import net.risingworld.api.objects.Player;public class Guitrevor extends Plugin implements Listener {
// changed this to static
public static Plugin plugin;String[] splitCommand;
// moved GUI elements to setupGUI()
public Player player;
public static PlayerGuiElementClickEvent clkyes;
public static PlayerGuiElementClickEvent showme;
public GuiLabel closeme = new GuiLabel(0.1f,0.1f,true);
public GuiImage buttonYes = new GuiImage(0.5f,0.8f,true,178,68,false);
//put label and image here so they would be seen in click event left them
//in your static void mehods
@Override
public void onEnable()
{
plugin = this;
registerEventListener(this);
}
// added this method
@EventMethod
public static void onPlayerSpawn(PlayerSpawnEvent event)
{
Player player = event.getPlayer();
// Set up GUI
setupGUI(player);
// show GUI
showHideGUI(player, false);
}
public static void setupGUI(Player player)
{
// define a panel
GuiPanel panel = new GuiPanel(0.5f, 0.5f, true, 200, 200, false);
panel.setColor(1f, 0f, 0f, 0.8f);
panel.setPivot(PivotPosition.Center);
panel.setBorderThickness(4f, false);
panel.setBorderColor(0f, .74f, 1f, 1f);
panel.setClickable(false);
panel.setVisible(false);
// defind close label
GuiLabel closeme = new GuiLabel(0.1f,0.1f,true);
closeme.setText("close me");
closeme.setClickable(true);
closeme.setFont(Font.Default);
closeme.setFontColor(0xFFFF33);
closeme.setColor(192f,192f,192f,1);
closeme.setVisible(false);// define a button
GuiImage buttonYes = new GuiImage(0.5f,0.8f,true,178,68,false);
buttonYes.setImage(new ImageInformation(plugin, "/assets/singleyes.png"));
// these .png files must be in the /assets directory in the Source Package/assets
//and comiled into the .jar file
buttonYes.setClickable(true);
buttonYes.setPivot(PivotPosition.Center);
buttonYes.setVisible(false);
// define a button
GuiImage buttonNo = new GuiImage(0.5f,0.35f,true,178,68,false);
buttonNo.setImage(new ImageInformation(plugin,"/assets/singleno.png"));
buttonNo.setClickable(true);
buttonNo.setPivot(PivotPosition.Center);
buttonNo.setVisible(false);
// add buttons as children of panel
panel.addChild(buttonYes);
panel.addChild(buttonNo);
panel.addChild(closeme);
// assign GUI elements to player
// I don't know if it's necessary to do them individually, but that's the way I was taught
player.setAttribute("panel", panel);
player.setAttribute("buttonYes", buttonYes);
player.setAttribute("buttonNo", buttonNo);
player.setAttribute("closeme",closeme);
// add GUI elements to HUD
player.addGuiElement((GuiPanel) player.getAttribute("panel"));
player.addGuiElement((GuiImage) player.getAttribute("buttonYes"));
player.addGuiElement((GuiImage) player.getAttribute("buttonNo"));
player.addGuiElement((GuiLabel) player.getAttribute ("closeme"));
}
public static void showHideGUI(Player player, boolean visible)
{
GuiPanel myPanel = (GuiPanel) player.getAttribute("panel");
GuiImage myButtonYes = (GuiImage) player.getAttribute("buttonYes");
GuiImage myButtonNo = (GuiImage) player.getAttribute("buttonNo");
GuiLabel closeme =(GuiLabel) player.getAttribute("closeme");
// make close button
myPanel.setVisible(visible);
myButtonYes.setVisible(visible);
myButtonNo.setVisible(visible);
closeme.setVisible(visible);
}
public static void showButtonYes(Player player, boolean visible)
{
GuiPanel myPanel = (GuiPanel) player.getAttribute("panel");
GuiImage myButtonYes = (GuiImage) player.getAttribute("buttonYes");
GuiLabel closeme = (GuiLabel) player.getAttribute("closeme");
myPanel.setVisible(visible);
myButtonYes.setVisible(visible);
closeme.setVisible(visible);
}
public static void showButtonNo(Player player, boolean visible)
{
GuiPanel myPanel = (GuiPanel) player.getAttribute("panel");
GuiImage myButtonNo = (GuiImage) player.getAttribute("buttonNo");
GuiLabel closeme = (GuiLabel) player.getAttribute("closeme");
myPanel.setVisible(visible);
myButtonNo.setVisible(visible);
closeme.setVisible(visible);
}
@EventMethod
public void onPlayerCommand(PlayerCommandEvent event){
String command = event.getCommand();
String[] cmd = command.split(" ");
if (cmd.length >= 2 && cmd[0].equals("/respond")){
splitCommand = event.getCommand().split(" ");
if(splitCommand[0].equals("/respond")){
//3 in command line /antaz getArea areaID
if(splitCommand.length==2){
if(splitCommand[0].equals("/respond")){
{
String[] cmds = command.split(" ");
if (cmds.length == 2){
if(splitCommand[1].toLowerCase().equals("yes")){
String key = cmds[1];
Player player = event.getPlayer();
player.sendTextMessage("setting up GUI") ;
player.setMouseCursorVisible(true);
//GUI has both buttons
showHideGUI(player,false);
showButtonYes(player, true);
showButtonNo(player, true);}
if(splitCommand[1].toLowerCase().equals("no"))
{
// boolean push = ButtonNo.isDoubleClick();
Player player = event.getPlayer();
player.sendTextMessage("setting up GUI") ;
player.setMouseCursorVisible(true);
showHideGUI(player, false);
showButtonNo(player, true);}
}
if(splitCommand[1].toLowerCase().equals("off"))
{
Player player = event.getPlayer();
player.sendTextMessage("Turning off GUI");
showHideGUI(player, false);
player.setMouseCursorVisible(false);
}
}
}
}
}
}
}
@EventMethod
public void onPlayerGuiElementClickEvent(PlayerGuiElementClickEvent click){
// if (click.getGui{}
Player player = click.getPlayer();
String box = String.valueOf(click.getGuiElement());
GuiElement element = click.getGuiElement();
// String isbox = String.valueOf();
if (element == (GuiLabel)player.getAttribute("closeme"))
{
player.sendTextMessage("if worked true");
player.sendTextMessage("Turning off cursor");
player.setMouseCursorVisible(false);
player.sendTextMessage("closing Gui Window");
showHideGUI(player, false);
}
if (element == (GuiImage) player.getAttribute("buttonYes")){
player.sendTextMessage("you clicked Yes");
}
if (element == (GuiImage) player.getAttribute("buttonNo")){
player.sendTextMessage("you clicked No");
}
}
@Override
public void onDisable()
{
unregisterEventListener(this);
}
} -
Thanks Minos that works.. I was just not snapping that the player clicked on the event so he knows it and I can compare that object with the event object. I did not even have GUI Element attached ... wierd..
Thanks again for putting up with me.
Trevor you can see what I did with the PlayerGuiElementClickEvent though just test code mind you but it pulls the cursor out from the click event and you can capture what was clicked.. Then be sure to turn the cursor off in that routine or you will have to reload the plugins from the console to get rid of it. (Something I did on several occasions.
ps Trevor I turned the cursor on in the command lines you gave me
if(splitCommand[1].toLowerCase().equals("yes")){
String key = cmds[1];
Player player = event.getPlayer();
player.sendTextMessage("setting up GUI") ;
//turn on cursor for player to click- player cannot move with cursor on.
player.setMouseCursorVisible(true);
//GUI has both buttons
showHideGUI(player,false);
showButtonYes(player, true);}
-
ok attribute.. I was thinking of text but then I want to click on just pictures. That was probably from late night clipping and pasting looking that is how the element was defined so I just cut and put that there. I told you the if statement was not correct. I had just moved that down so I did not want to retype it all from another line of code. I guess I did not look at it fully before I posted it.
Since the player has the attribute you say we can get the definition it from him. I was initially looking for it to be defined in the event or something like comparing the text but get text is not available in PlayerGuiElementClickEvent just element. I am not sure I would have looked at the player having it.
Thanks .. I will look at that.
Still having trouble grasping why the player has to have it and I cant get it from the text or ID from the event but then only the single player has to see it. So thanks.
-
Hey minos I have the cursor event captured but I cannot get the GuiElementid from the event. I managed to get the event object into a string and can see the id but it is a long string net.RisingWorld.API.GUIlable@1F3. (or close). If the last bit is the ID I can stip that and compare the ID for If statements but that seems complicated. Is there a better way to identify the label? Keep in mind that Trevor's help has most of the labels in voids so I was trying to find it from the event and make sure it is the Close Button.
The routine event method turns off the cursor too so that part works. I can click on each element and get the Not the below If does not catch it. I was hoping not to have to redeclare all the void variables and really stir up the code.
}
@EventMethod
public void onPlayerGuiElementClickEvent(PlayerGuiElementClickEvent click){
// if (click.getGui{}
Player player = click.getPlayer();
String box = String.valueOf(click.getGuiElement());
if (box.equals(player.addGuiElement((GuiLabel) player.getAttribute ("closeme")))){
player.sendTextMessage("checked if worked true");
}
player.sendTextMessage("Box you clicked'"+box);
player.sendTextMessage("Turning off cursor");
player.setMouseCursorVisible(false); -
What is undecorrated. I was doing some remote programming with a laptop I dont use often and when I deslect undecorated it makes the remote HDMI screen go blank white but the Dell main screen can see it. How does this affect GUIs?
-
Thanks Minos.. yes Trevor helped allot I am not at my normal home now so I cannot recompile the simpler code with the pictures in the jar to see if it would work but I learned some albeit complicated ways of making a bunch of callable routines to do the trick. Trevor stuck with me through my total an complete frustration with the issues and made it work. He deserves something for that for sure.
I have been fooling around with GUIElementClickEvent and seems my server is giving me fits accessing it now so I not sure when I will be able to test this help but thanks I put it i my Notes notebook.
-
Anybody have some links to some good server services that run Rising World well. I am currently running PingPerfect and have continuing issues so I want to switch but worried I will lose everything everyone has done if I switch. I also dont want to just go to another poor service that cant run this program effectively.
-
I can't help there. I haven't done anything with the mouse yet At a quick glance at the API, it'll involve PlayerGuiElementClickEvent. That returns the element (e.g. button) and X/Y floats relative to the element
Yes it is is that is what the Red said in the post and is in the Javadoc. It is sort of hidden in the Player.GUI and hard to find. Do not turn on the cursor before you have the click event working or it will lock you out. The cursor being on will not allow you access to to the command line or RCON. Basically until you have the return to turn off the cursor it will lock you in cursor mode forever with no recourse but to log off.
-
Quick question now what API should I be looking at to release the mouse to select in the GUI. It just moves around with the n mouse now like a selector.
Oh I think I found it. Another visible thingie.. saw it in old post two years ago by Red player.setMouseCursorVisible(true); Boolean.
-
Well it loaded ok and seems to turn on and off the GUI exactly the same but seems I get the same exact issue. A white button rectangle in the middle of the red panel. There must be a compatibility issue in the .png or jpg. I will look for this issue. I left it up on my sever if you want to look. Maybe it needs to be in the main directory or in the script file when compiled. Not sure .
Well I should have read your original email closer as I was looking at the code. I fell into putting them in the jar then went back and read your post with the code.
So the good news is it works!!!!
Yes the directory has to be in the jar file which is sort of a problem if you want to keep to date pictures and a trick I did not see anyplace other than remembering something about that in a post for pnb plugin and the textures.
So in any case thank you verymuch. I left it on my server if you wish to go and look. I suspect my original code would have worked too. I might try it. Another small inside knowledge thing that I learned the hard way.
THANK YOU VERY MUCH. I am a bit of crab apple and was fully frustrated. I will study your code and see what I can learn.. on to the next phase now. THANK THANKS THANKS.
Hope somebody else reads this and gets inspired .. the community is great
-
Thanks Trevor more than I expected. I am not at my home computer right now but I will try to test it out.
wow took a minute to compile on this computer. You are using setVisible and player attributes which I would never have recognized that you had to assign it to a player as an attribute because I could turn it on and make it visible without that.
-
My project is not a project it is just an experiment to see how it works. It will have a mishmash of different stuff being experimented with. I turned off all the panel stuff. It is about the 5th interaction on the path so what you see is not necessarily what I have tried in the past.
The name of the file has been changed the location of the file has been changed. The type of picture has been both png and jpg. The size of the picture has been checked to be the same pixels as called so I dont think it is off to one side outside of hte box but who knows at this point.import net.risingworld.api.Plugin;
//import java.sql.ResultSet;
//import java.sql.Connection;
//import java.sql.SQLException;
//import net.risingworld.api.database.Database;
import net.risingworld.api.events.EventMethod;
import net.risingworld.api.events.Listener;
import net.risingworld.api.events.player.PlayerCommandEvent;
import net.risingworld.api.objects.Player;
import net.risingworld.api.gui.GuiElement;
import net.risingworld.api.gui.GuiLabel;
import net.risingworld.api.gui.GuiPanel;
import net.risingworld.api.gui.PivotPosition;
import net.risingworld.api.utils.ImageInformation;
import net.risingworld.api.gui.GuiImage;public class GUIreply extends Plugin implements Listener {
public Plugin plugin = this;
// public void setImage(y);
// public void setImage(n);
String[] splitCommand;
public ImageInformation singley = new ImageInformation(getPath() + "/assets/singleyes.jpg");
public ImageInformation n = new ImageInformation(getPath() + "/singleno");
// public GuiPanel panel = new GuiPanel(0.5f, 0.5f, true, 200, 200, false);
public GuiImage ybutton = new GuiImage(singley,0.5f,0.5f,true,178,68,false);
public Player player;
@Override@EventMethod
public void onPlayerCommand(PlayerCommandEvent event){
String command = event.getCommand();
String[] cmd = command.split(" ");
if (cmd.length >= 2 && cmd[0].equals("/respond")){
splitCommand = event.getCommand().split(" ");
if(splitCommand[0].equals("/respond")){
//3 in command line /antaz getArea areaID
if(splitCommand.length==2){
if(splitCommand[0].equals("/respond")){
{String[] cmds = command.split(" ");
if (cmds.length == 2){
if(splitCommand[1].equals("Yes")){
String key = cmds[1];
Player player = event.getPlayer();
player.sendTextMessage("setting up GUI") ;
// Set up GUI
//
// panel = new GuiPanel(0.5f, 0.5f, true, 200, 200, false);
// panel.setColor(1f, 0f, 0f, 0.8f);
// panel.setPivot(PivotPosition.Center);
// panel.setBorderThickness(4f, false);
// panel.setBorderColor(0f, .74f, 1f, 1f);
// panel.setClickable(false);
ybutton.setImage(singley);
ybutton.getImage();
ybutton.setClickable(true);
ybutton.setPivot(PivotPosition.Center);
// panel.addChild(ybutton);
Player p = event.getPlayer();
// p.addGuiElement(panel);
p.addGuiElement(ybutton);
// p.getAttribute("singley");
}
if(splitCommand[1].equals("remove")){
ybutton.destroy();
// panel.destroy(); -
Thanks Trevor.. I am trying to swim in the shallow end first. If I cannot get a pictures to be found all the coding the world to display it will not do me any good. I will review what you have shared and see if I can find out why my 6 line codes does not load the picture.
-
yes I want this too
is this a chest?
-
Cannot even recreate your example Trevor which is full of public void objects for something bigger. I am trying to simply turn on a picture and display it and the picture will not load PERIOD
I turned off the panel to see if it was covering even though it seems to be ontop and still a blank perfectly proportioned white rectangle. i am sure it is something as simple as the database read issue I had all the the examples everyone gave me did not have the "/" in front of the filename which was what was keeping it from being found. There is no examples in the JavaDoc that even remotely works for a picture other than turns on a blank rectangle. It would be nice if this system would use JAVAFX but it seems it wont display those either.public ImageInformation singley = new ImageInformation(getPath() + "/assets/singleyes.jpg");
public ImageInformation n = new ImageInformation(getPath() + "/singleno");
// public GuiPanel panel = new GuiPanel(0.5f, 0.5f, true, 200, 200, false);
public GuiImage ybutton = new GuiImage(singley,0.5f,0.5f,true,178,68,false);