PDA

View Full Version : Error with Autopackage



Pleng
05-17-2009, 06:35 PM
I have tried to package my world as a windows zip, but get an error when running the game.

Perhaps it's an issue with the paths. Some slashes appear to be in the wrong direction.



Original screensize detected as 1024.00 X 768.00
Command line parms received:
-res
800
600
-retail
DP_TreeWorld.novashell

Initializing GameLogic...
Clanlib Sound System Initialized
Mounting world path worlds/DP_TreeWorld.
Novashell V0.81 and Lua 5.13 RT Edition Initted.
Setting retail to true
Retail mode activated.
Initting world
Initting intro menu
Loaded map Intro at tick 0. 4 non-empty chunks, size is 1 by 1.
Toggling windowed mode
Resetting!
Clearing all maps
User profile path now C:\Documents and Settings\PlenGu\Desktop\DP_Treeworld/profiles/Player/DP_TreeWorld
Running our custom tree world game start code.
Setting game defaults
Map Inside not found
Map Main not found
CreateEntity (gui/interface.lua at 0 0) failed, a null map was specified, and no active map found as backup!
Found player in Ship at X:1996.50 Y: -851.93
Loaded map Ship at tick 0. 64 non-empty chunks, size is 15 by 5.
Player has 0 items.
Initializing the player entity.
---------------- Lua Error! Stack Dump ----------------

-1: no match for function call 'GetEntityByID' with the parameters (nil)
candidates are:
GetEntityByID(number)

Entity 141, function OnPostInit

Seth
05-17-2009, 08:13 PM
Hmm, the .zip you sent me before had these same errors, I had assumed it just wasn't in a playing state at the time of zipping but was for seeing the layer problem which it did help with.

So maybe it isn't the packager?

First, notice this from the error log:


Map Inside not found
Map Main not found
CreateEntity (gui/interface.lua at 0 0) failed, a null map was specified, and no active map found as backup!

These errors are generated by these commands from your game_start.lua:


GetMapManager:SetActiveMapByName("Inside"); //cause this to get preloaded
GetMapManager:SetActiveMapByName("Main"); //cause this to get preloaded

InterfaceInit("gui/interface.lua");

You are trying to init two maps that doesn't exist which generate warnings, and then InterfaceInit generates the error because it requires a map to exist to create the GUI interface.

So, instead, you should have something like:


GetMapManager:SetActiveMapByName("Ship");
InterfaceInit("gui/interface.lua");

After doing that I am able to get further, but then see a lot of these errors:

---------------- Lua Error! Stack Dump ----------------


-1: ?:0: attempt to concatenate a nil value
Entity 179 (moneybag_zone) : Error while calling OnCollision(Vector2, Vector2, Vector2, number, number , Entity, number) (Entity's main script is zones/moneybag_zone.lua)
collision

I found some errors in moneybag_zone.lua:

local moneybag GetEntityByName("moneybag");

Should be:

local moneybag = GetEntityByName("moneybag");

And also: LogMsg(myent .. moneybag) is causes an error, as myent is a string and moneybag is an entity, it will convert the entity into a string on the fly but doesn't seem smart enough to realize it can be concatenated into a string.

So just do it this way instead:

LogMsg(myent .. moneybag:GetName() );

Ok no more errors - cool game, I can walk around and pickup things. Uh oh, after picking up the money bag more errors in about the same place.

It's because of this:

local moneybag = GetEntityByName("moneybag");

But you don't check to see if moneybag is valid or not when you use it. So I added:

if (moneybag == nil) then return; end;

Actually, this whole function could be better simpler as something like:


if (entity:GetName() == "moneybag") then
//collided with money bag
end

But now that I dropped it on the correct space, no collision is happening with it. But if I hit Ctrl-Q to show collisions I see why, take a look at the pic.

The collision areas aren't actually touching. If I drag it over to it, it works. Also, the moneybag_zone collision looks off, perhaps the centering needs to be changed.

Hope that helps! The jump looks really good btw.

Seth
05-17-2009, 08:34 PM
Btw,

You may want to add this in your moneybag_zone.lua's OnPostInit():

this:SetCollisionCategories(C_CATEGORIES_NONE);

This way, you can make its collision shape as large as you want and it won't interfere with dizzy. (But it still listens for collisions)

For the raised platform area, you could just use a normal level piece collision method.

(Alternatively, give items gravity so they will fall and touch things like that?)

Pleng
05-18-2009, 10:31 AM
Hi Seth

Thanks again for your help.

The zip I sent you was working on my system from the Novashell directory. I wonder why it didn't work on your system.

Anyway I have removed the incorrect maps and replaced with Ship, and now the autopackage works.

The issues you mention with moneybag_zone not checking for the existence of the moneybag was fixed between the time I sent you the the world, and the time I was trying to package the world. My solution was a lot more complex than yours though, so I've changed it.

I had also already increased the size of the entity and fixed the verts to make sure collisions definitely should be occurring. Still nothing.



MoneyBag Zone script

function OnInit() //run upon initialization

this:SetName("moneybag_zone");

end


function OnPostInit() //run after being placed on a map

this:SetCollisionCategories(C_CATEGORIES_NONE);
this:SetCollisionListenCategory(C_CATEGORY_ENTITY, true);
this:SetCollisionListenCategory(C_CATEGORY_PLAYER, false);

end

function OnCollision(vPosition, vVelocity, vNormal, depth, materialID, entity, state)

//put the NAME of the entity for of correct item
//here:
local item="moneybag"

LogMsg("entity name:");
LogMsg(entity:GetName());

if (entity:GetName() == item) then

//put the correct course of action here!
LogMsg("collision with moneybag");
local saidGold=(GetEntityByName("crewleader"):Data():Get("saidGold"));

if (saidGold=="true") then
//saidGold is text as entitys can't have (?) boolean data
GetEntityByName("crewleader"):RunScript("TakeGold");
end

end

end




Money Bag Script
function OnInit()
this:LoadCollisionInfo("~/moneybag.col");
this:Data():Set("overtext", "Bag of Gold");
this:SetVisualProfile("~/moneybag.xml", "standard");
this:SetScale(Vector2(0.3, 0.3));
this:SetName("moneybag");
end

function OnPostInit()
this:SetLayerByName("Detail 2");
this:SetDensity(1);
this:SetGravityOverride(0); //so we don't move
this:SetCollisionListenCategory(C_CATEGORY_PLAYER, true);
this:SetCollisionListenCategory(C_CATEGORY_ENTITY, true);
//Update every frame!
this:SetRunUpdateEveryFrame(true);
end

function OnKill()
if not (GetPlayer==nil) then
GetPlayer:Data():Set("overitem", "");
GetPlayer:RunFunction("UpdateGUI");
end
end

//this is run every logic tick
function Update(step)
if not (GetPlayer==nil) then
GetPlayer:Data():Set("overitem", "");
GetPlayer:RunFunction("UpdateGUI");
end
end

function OnCollision(vPosition, vVelocity, vNormal, depth, materialID, entity, state)
if (GetPlayer:GetID()==entity:GetID()) then
//The collision is with the player
local ME = this:GetID();
if (state < 2) then
//in case the a is implemented
//in NOVASHELL in a future update
g_overitem = true;
GetPlayer:Data():Set("overitem", GetEntityByID(ME):Data():Get("overtext"));
GetPlayer:RunFunction("UpdateGUI");
end
end
end

function OnAction()
this:SetDeleteFlag(true);
GetPlayer:RunFunction("GiveItem", "moneybag");
//DEBUG
this:Data():Set("cross", "yes");
OnItemMenu("_first_");
end


And when the collision should be happening, here's the log output:



Initializing GameLogic...
Clanlib Sound System Initialized
Mounting world path worlds/DP_TreeWorld.
Updated binary version of worlds/DP_TreeWorld/script/zones\moneybag_zone.lua
Novashell V0.81 and Lua 5.13 RT Edition Initted.
Initting world
Initting intro menu
Loaded map Intro at tick 209951. 4 non-empty chunks, size is 1 by 1.
Resetting!
Clearing all maps
User profile path now C:\Documents and Settings\PlenGu\My Documents\My Dropbox\Development\Novashell/profiles/Player/DP_TreeWorld
Running our custom tree world game start code.
Setting game defaults
Loaded map Ship at tick 0. 48 non-empty chunks, size is 7 by 5.
Initting interface
Setting up overlays..
Loaded map System Palette at tick 0. 4 non-empty chunks, size is 1 by 1.
Found player in Ship at X:1996.50 Y: -851.93
Switching world focus to ourself?
Player has 0 items.
Initializing the player entity.
Setting player to Entity 2622 (Player)
Setting camera tracking to player Entity 2622 (Player)
Editor opened up
Setting retail to false
Editor closed


I can't figure out why it's working for you and not for me, unless I've missed something! If you change this:SetCollisionListenCategory(C_CATEGORY_PLAYER, false); to true in moneybag_zone.lua then the LogMsgs do trigger.

The only think I can think of (and I know I'm just clutching at straws here!) is that there must be some small difference between our setups, as the previous world I sent you ran on mine but not on yours (without modification).

I've uploaded my latest version to the same url I sent you before, would you be so kind as to have a look at it and see if it works on your system?

I'm glad you like the jump, after all the hard work you put in to it! :)

Seth
05-19-2009, 03:50 AM
Ok, I just downloaded it and tried it but now the platform is missing??

You know, I think it's because you may have changed collision of a graphic in "base" accidentally, like if you took the "solid color block" and did your own collision on it, this wouldn't be in what you sent, because you didn't include your own "base" stuff.

Same problem if you had modified a base script, I wouldn't have that.

Maybe that could explain why I had errors and you didn't?

You may want to reinstall novashell to overwrite your current base directory to make sure it's in a 'clean' state.

Another solution is to send me a packaged version which will include your base directory so I should see exactly what you're seeing.

For reference, here is what I see in the freshly downloaded version (pic attached), I don't see a moneybag zone platform (although I am seeing messages in the log from it, so maybe that's it on the lower left or somewhere?) and I see some treeworld pieces scattered around which probably aren't supposed to be there.

Pleng
05-19-2009, 06:31 AM
OK This is weird.

The zone is definitely there on my system. It's in the same place in the 'hidden data' layer(it's not actually a platform, just a hidden zone designed to detect if the player has dropped anything). I did copy it from system palette, paste it into the Ship world and modify its collision data. I have been very careful NOT to modify the scrips in the base directory. Any changes made to base scrips have been saved in my world's own directory. And, of course, I did a reinstall of Novashell when you updated the layers system.

Anyway, I have attached a zip of my base directory. Maybe that will shed some light?

As for Treeworld objects, all that should be there are 2 waypoints, some pathfinding nodes, a barrel and a crate.
There should also be a platform to the right hand side of the ship, and the treetop and treestump running underneath it (both of which have been streachd and are acting as placeholders for the sea) Have you found any other objects?

Thanks again for all your help!

Seth
05-21-2009, 12:17 AM
I did copy it from system palette, paste it into the Ship world and modify its collision data

Ok, that probably caused the problems... Should never change collision on a system palette piece as it is saved in base and globally shared with all worlds. (Could break many examples, for instance) Hmm, I need a way to show a warning if something in base is being edited.

Instead, cut a pixel out of one of your own tilepics and use that.

Pleng
05-21-2009, 07:47 AM
OK I have changed to using one of my own tilepics, and reinstalled Novashell to restore the base world.

Now, the moneybag_zone.lua's OnPostInit is as follows:



function OnPostInit() //run after being placed on a map

this:SetCollisionCategories(C_CATEGORIES_NONE);
this:SetCollisionListenCategory(C_CATEGORY_ENTITY, true);
this:SetCollisionListenCategory(C_CATEGORY_PLAYER, false);

//Setting density to 0 stops the moneybag colliding, even though
//it has a density of 1. Why?!
//this:SetDensity(0);

//even with Gravity Override set, the entity continues to
//fall slowly down the screen. Why?!
this:SetGravityOverride(0); //so we dont move

this:Stop();


end


When I have the zone set to a density of 0, it no longer registers collisions with the moneybag, even though the moneybag has a density of 1 (I gathe at least 1 item needs to have density higher than 0 for collisions to be listened to). Collisions with other

If I set the density to, for example 1 or 3, the collisions with moneybag are registered, but the zone will fall down the map and through the platforms, even with GravityOverride set.

Clearly there's something I'm doing wrong but I can't figure it out?

Any ideas?

Seth
05-24-2009, 10:37 PM
Because you have this:SetCollisionCategories(C_CATEGORIES_NONE); this means it will not collide with any of your platforms.

Maybe you wanted to turn off collisions with entities but not with tilepics, which your walls are probably made out of?

To do this add:


this:SetCollisionCategory(C_CATEGORY_TILEPIC, true);

and it will bump into the platform and stop.

However, I still don't understand what is causing it to move since you have the gravity override on it at 0, I will need to look into that part further, it seems like nothing would be touching it and it would simply be floating there.

About SetDensity(0) breaking collisions: Hmm - If you set BOTH entities to density 0, you are saying they are both immovable, and the engine doesn't bother checking for collisions between them. (It doesn't know you spawned one inside the other one)

To fix this, make sure at least one of the entities is not density 0. (Not sure if this is what is happening in your case but it's worth checking!)

Pleng
05-25-2009, 07:05 AM
Hi Seth

Thanks for your reply.

The collision zone is not a platform. It is in fact a hidden entity who's sole purpose is to detect if the player has dropped the money bag on top of it.

The moneybag's density is fixed at 1 so collisions should still occur, but they don't whilst the moneybag_zone's density is set to zero.

I suppose I could set the density of the moneybag_zone to 1, and collect the x and y coordinates in a variable on init, then move it back to that position every update, but it's not a terribly elegant solution!