View Full Version : Real bug to do with entities

07-12-2008, 04:41 AM
I created a new map called "HypnoMap" -- Then I copied the player entity to the new map. Changed it's name to EyeballTemplate and then proceeded to change the script to read eyeball.lua -- then edit, and it asked if i wanted to create it, so i said yes. Then, I saved the map and restarted the engine. Now when I went back to the HypnoMap, I noticed that the graphic for the idle animation for joe (because I copied his entity) still there, only when I click on it, it crashes novashell.

I'm attaching the world. Let me know what the deal is, I still could have just flubbed myself.

07-12-2008, 02:47 PM
For some reason right now it's not crashing, don't know why, but it's still using the idle "animation" from hypno-joe -- even though it uses a different script that doesn't load up a visual profile.

However when I tried to "edit" it's visual profile, it said there's no visual profile assigned, and that it needs to be done in script, then promptly crashed.

Double clicking EyeballTemplate (that i copied from the hypno-joe entity) actually causes it to crash.

Also the version I uploaded is the one that crashes, but I've since modified my project so it properly loads a visual profile.

07-13-2008, 12:39 AM
Ok, the crash part is a bug and I'll try to fix that in the next version, thanks.

But here what is really happening,

When you first started working on that character, you started with a tilepic image, not a visual profile.

Now that the visual profile (which overrides any tilepic settings) is gone, that tilepic image is being used instead. (See those little variables in its data members?

You can delete those to get rid of that tilepic info, which also would have probably fixed the weirdness)

07-13-2008, 02:08 AM
Just an update, the crash was because the tilepic that it was originally setup with was 96X96, but I'm thinking later HypnoIdle_right.png was changed to be 64X64. It tried to do the pixel accurate hit-test when you click it with 96X96 and this was.. well, bad. :)

I've fixed this, so the next version will automatically truncate a tilepic if this happens...

07-13-2008, 05:56 AM
I can't even select the thing. (legs, it has eyes next to it)

07-15-2008, 04:42 AM
Well apparently the new version has fixed *most* of the problems. But there is one more. Basically, if I delete all the extra eye entities, to where there's just the body, and restart, and play a new game, it works fine. However if I move it in game, it adds one set of eyes. Now if I continue to move it around it continues to delete and readd the eyes, which means no copies are on the screen, however, once I restart the game when the joe entity (player) has a set of eyes, it will have an extra set of eyes in the game (they just sort of sit on the map while joe's eyes are fine).

Could we also figure out what's causing this problem. Also I notice whenever I select the eyes in the editor (after it's created eyes by moving the player entity) I notice it has a letter after the name "JoesEyes" -- which of course is your way of making sure the program doesn't balk at having the same name. Usually it's like JoesEyesE or something. Can we find a way to make sure the name I give it stays that name and not with a letter? Because the eyeballs on the HypnoJoe map are named EyeballTemplate, then I name it JoesEyes when they are cloned.


07-16-2008, 11:06 AM
once I restart the game when the joe entity (player) has a set of eyes, it will have an extra set of eyes in the game

To fix this, do a this:SetPersistent(false); in the eye script. By default, any created entity is going to be saved with the map unless you explicitly tell it not to.

Can we find a way to make sure the name I give it stays that name and not with a letter? Because the eyeballs on the HypnoJoe map are named EyeballTemplate, then I name it JoesEyes when they are cloned.

Hrm.. this might be because of how 'attached' things sometimes usually kill themselves a frame AFTER the thing that they were attached to, I think this means the name is still 'in use' when the copy is created.

If it happens the first time you clone it (like, when you start the game) and not just during copy and paste in the editor, that would mean the above is wrong.

But if it's right, you could use SetName(""); to unname it when it's parent is killed to clear it.

Btw, to set a global so everybody could see which entity is the latest "eyes", you could do this:

_G.g_eyeID = this:GetID(); //in the eye script

Then, any entity in the game could do:

LogMsg("The eye ent is ",g_eyeID); and you could reference it without needing to know its exact name.

07-16-2008, 02:41 PM
First I'm mad at myself for not catching the mistake in the last message text. I meant in the editor, when you move joe, a set of eyes gets cloned onto him. Whenever you move him around of course the eyes just delete themselves and then re-create, so I have no more than one set of eyes on joe at any one time. However when I do this, and I restart the engine and play a game, there's an extra set of eyes on the map (because the game itself will also create a set of eyes).

If I delete the eyes on the map in the editor, and restart, then there's not an extra set of eyes anymore.

Secondly, when I set persistant to false, it effectively removed the EyeballTemplate from HypnoMap -- which means now the eyeball entity doesn't exist.

It is my fault for not being clear, however.

What I'm thinking about doing is putting Joe on the Hypno Map along with his eyes. using some script (maybe in game_start.lua) actually clone him out, or do something similar to what you did in beer invaders.

I'll probably have copies made in the editor of the baddies onto the main map, but Joe should probably be created and placed via script.

As far as naming goes, you can't access clone_ent during OnKill -- because presumably it's already been killed. It just gives an error that it's not defined.

Another weird thing is when I check the name of the cloned entity, you'd think it would read EyeballTemplateA -- since the entity itself is EyeballTemplate, but it's usually some other letter. Not really sure why, because as far as I can tell OnPostInit is only called once, and yet it acts like there are other clones.

I will attach the current incarnation so you can see what's going on. Make sure when you play you hit the backtick and look at the log. You'll see what the clone is named, and then what it is renamed.

07-16-2008, 10:28 PM
I will take a look later and figure out why you can't deal with attached things in your OnKill, I want that to work, could be a bug.

As for persistence - to make only the things you clone 'on the fly' persistent, set this right after you clone them, instead of in the eye script.

So in your joe script:

eyeClone = blahblah

07-17-2008, 03:49 AM
That seems to work, however, if I manage to select the eyeball clone along with the player, and move him, it creates copies of eyes (I think it's because it deals with the eyes seperately, ie it recreates them everytime) However if I just move around the Joe entity itself (the legs) the eyes move with him without creating more.

I think I want to do something similar to what you did in beer invaders. But I would like to get this name thing resolved first before I do that. (joe might be better off of the HypnoMap and cloned and placed via script).

I realize you might throw your hands up at this, but I was making sure that we got all the bugs out before doing the other method.