Jump to content

Need help with a warping mod


dida55

Recommended Posts

Hey!

 

So this mod should warp you to a location where you clicked on the map. It can be enabled/disabled, so you won't have to always use it, only when you want to travel fast, without getting exhausted.

        player:setX(x);        player:setY(y);

I am using the functions of IsoMovingObject, this should update the coordinates of the player, however, every time I click somewhere this error appears: 

http://f.cl.ly/items/0K0U031A382e0T1l2b1x/Image%202013.08.12%2022%3A44%3A04.png

I think the map has to be updated while you move and other things like that, but I cannot figure out how to do that :(

 

Help is appreciated, thanks!

Link to comment
Share on other sites

I tried to do the same thing when I first started modding PZ and gave up after a few hours ^^  

 

Haha. Well, I've been reading the Javadocs and there are 4 functions I need to call somehow, I just don't know how:

  • IsoChunk update()
  • IsoChunkMap update()
  • IsoCell update()
  • IsoWorld update()

If I knew how to call these, it may be fixed, but I can't figure it out from the Javadocs... 

Link to comment
Share on other sites

I have tried adding 

        player:update();        zombie.iso.IsoCell:update();        zombie.iso.IsoChunk:update();        zombie.iso.IsoChunkMap:update();        zombie.iso.IsoWorld:update();

but it did nothing change to the error screen. 

 

I hope someone can help :C

Link to comment
Share on other sites

Packages in java work different than (tables) in lua. You can't simply call it with zombie.iso... I suggest that you look through all the getters in the Javadocs. There also is a list somewhere in the source (which I can't find now) which shows all global functions which can be simply called from lua. IIRC for example there should be a getCell() function.

 

Maybe you could say:

getCell():update()

 

(I'm not sure though.)

Link to comment
Share on other sites

Packages in java work different than (tables) in lua. You can't simply call it with zombie.iso... I suggest that you look through all the getters in the Javadocs. There also is a list somewhere in the source (which I can't find now) which shows all global functions which can be simply called from lua. IIRC for example there should be a getCell() function.

Maybe you could say:

getCell():update()

(I'm not sure though.)

Well, I didn't even know how to change a player's coordinates, until lemmy told me they are IsoMovingObjects.

If it wasn't him I'd still be trying IsoMovingObjects:setX/Y(), I couldn't have figured out that I need a player to call those functions on, since that is not mentioned in the javadocs.

The same applies to Chunks/Map.

Link to comment
Share on other sites

Hm ... maybe you should look for a more simple mod to start with. I suggest that you read through the modding tutorials and also start looking at some Java and Lua coding guides (especially the Inheritence & OOP stuff).

 

It's kind of hard to get a hang of modding if you don't know the basics about programming.

Link to comment
Share on other sites

Hm ... maybe you should look for a more simple mod to start with. I suggest that you read through the modding tutorials and also start looking at some Java and Lua coding guides (especially the Inheritence & OOP stuff).

 

It's kind of hard to get a hang of modding if you don't know the basics about programming.

 

I do and completely understand how OOP works, just never actually used it.

It's just that there are some basic things I'm missing out on and don't know how to use this Javadocs yet.

Come on IRC!

Link to comment
Share on other sites

Packages in java work different than (tables) in lua. You can't simply call it with zombie.iso... I suggest that you look through all the getters in the Javadocs. There also is a list somewhere in the source (which I can't find now) which shows all global functions which can be simply called from lua. IIRC for example there should be a getCell() function.

Is this the list you're talking about: http://theindiestone.com/zomboidjavadocs/zombie/Lua/LuaManager.GlobalObject.html ?

 

Will try to write a similar mod later. I need a way to warp through built doors which are bugged. Will post my results later.

Link to comment
Share on other sites

I've spent 4 hours on digging the old forum and the javadocs and found out how to grab the world and the current cell, but still cannot figure out what that error means. Slightest help is welcome!

The error shows in which java method an error occured (the method on the top) and shows which other methods are affected by it. So you don't have to call all these update() functions. That's already done.

If you start PZ via console.app you get the error message printed to your console. It shows another 2 rows then:

Aug 20, 2013 2:15:22 PM zombie.gameStates.IngameState updateSEVERE: nulljava.lang.NullPointerException	at zombie.iso.IsoChunk.update(IsoChunk.java:311)	at zombie.iso.IsoChunkMap.update(IsoChunkMap.java:62)	at zombie.iso.IsoCell.update(IsoCell.java:4803)	at zombie.iso.IsoWorld.update(IsoWorld.java:1673)	at zombie.gameStates.IngameState.update(IngameState.java:638)	at zombie.gameStates.GameStateMachine.update(GameStateMachine.java:87)	at zombie.GameWindow.logic(GameWindow.java:586)	at zombie.GameWindow.run(GameWindow.java:980)	at zombie.GameWindow.maina(GameWindow.java:856)	at zombie.core.LaunchDialog.main(LaunchDialog.java:208)

That means that an NullPointerException (basically a missing object/value) occured in zombie.iso.IsoChunk.update(), which is executed by zombie.iso.IsoChunkMap.update() and so on...

I'm completely new to PZ modding, but I guess you have to set some other values on you current chunkMap to get the right chunk. I couldn't figure it out yet. Maybe analysing the spawn process of the player or zombies could help.

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