Sign in to follow this  
Xilanthus

Code Help Please

Recommended Posts

New to Modding here and I have a question:

How would I change the following code below to return "true" also if there was a Floor Above or you were under a bridge?

 

private boolean hasRoof(VolaTile tile)
{
    Floor[] floors = tile.getFloors();
    for (Floor floor : floors) {
        if (floor.isRoof()) {
            return true;
        }
    }
    return false;
}

Edited by Xilanthus

Share this post


Link to post
Share on other sites
 for (Floor floor : floors) {

What is this nightmare?

Share this post


Link to post
Share on other sites

--

Edited by kochinac
not reading carefully

Share this post


Link to post
Share on other sites

Make a method in your mod that does what you want and it can be written with Java. You'll likely only have access to the MyTile object. Although, there are static methods in WU that let you look up information for a tile or volatile zone. Then use Javassist expression editor to replace the return value from the wurm method with the return value from your new method. Javassist page has a tutorial on this.

 

You could use bytecode to change it also but that isn't the easists approach.

Share this post


Link to post
Share on other sites

what type is MyTile? if you can get a VolaTile out of it you can call vt.getStructure().isTypeBridge()

Share this post


Link to post
Share on other sites
5 minutes ago, joedobo said:

... there are static methods in WU that let you look up information for a tile or volatile zone...

 

 

I am looking for a list of the static methods and what information is available about a tile. Is there a list somewhere?

The code above is from an existing mod and I want to enhance it further.

Share this post


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

what type is MyTile? if you can get a VolaTile out of it you can call vt.getStructure().isTypeBridge()

 

It is a VolaTile - I corrected the code above.

Share this post


Link to post
Share on other sites
private boolean hasRoof(VolaTile tile)
{
	if (tile.getStructure().isTypeBridge()) return true;
    Floor[] floors = tile.getFloors();
    for (Floor floor : floors) {
        if (floor.isRoof()) {
            return true;
        }
    }
    return false;
}

 

Share this post


Link to post
Share on other sites

WU vanilla code is very lacking when it comes to java docs. If you askin specific question in modding Discord (or here too) we can probably help advise on what method(s) would be best to get object xyz.

Edited by joedobo

Share this post


Link to post
Share on other sites
7 hours ago, bdew said:

private boolean hasRoof(VolaTile tile)
{
	if (tile.getStructure().isTypeBridge()) return true;
    Floor[] floors = tile.getFloors();
    for (Floor floor : floors) {
        if (floor.isRoof()) {
            return true;
        }
    }
    return false;
}

 

 

This would return true if you were standing ON a bridge too. I only want it to return true if there is a bridge (or any structure for that matter (bridge, Roof, Upper Floor, etc)) above you.

Edited by Xilanthus

Share this post


Link to post
Share on other sites

Is there a way to get the height of a floor element within a VolaTile and then compare the floor height to the height the character is standing at to see if the floor is above or below them?

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
Sign in to follow this