Page 1 of 1
debugDraw
Posted: Mon Feb 06, 2023 6:12 pm
by RayB
I have used debugDraw and it really helps but I can only get the debug box to show if used in the dungeon.
If I try to use it in an outside area the box does not show. Is there any way to get the debug box to show when used on a level that is outside ie. a forest level containing a forest_sky and heightmap?
Re: debugDraw
Posted: Mon Feb 06, 2023 7:24 pm
by 7Soul
It doesn't work if the map has water in it
Re: debugDraw
Posted: Thu Feb 09, 2023 7:30 pm
by RayB
I find the discord server much too difficult to use. Tried it. Tried to post a question but I don't think it worked. Gave up!
Re: debugDraw
Posted: Thu Feb 09, 2023 7:42 pm
by RayB
Thank you for the info.
Re: debugDraw
Posted: Tue Apr 18, 2023 12:25 am
by RayB
I have set up a receptor which accepts any entity and a script which checks for various poison bolts.
If it was a poison bolt that hit the receptor a spear door will open.
Everything worked fine until I placed a skeleton archer in the room. If I am standing by the receptor and
dodge one of his arrows and the arrow hits the receptor, an error saying 'bad object' is generated.
I thought that maybe the arrow was getting destroyed before the function was called but that doesn't
see tot be the case...
The function arguments are '( _, type )' and when I print(type) from within the function the print shows
that type' is a table yet if I print( type.name ) I get the bad object error.
Any other object I throw at the receptor works. I even shot an arrow at it printed that it was an arrow that
hit it. Only the arrow that the archer shoots gives the crash and 'bad object' error.
Any solution to this or should I simply not use a skeleton archer in this room.
Re: debugDraw
Posted: Tue Apr 18, 2023 5:10 am
by minmay
If you get an error saying "bad object", that means the object has already been destroyed, yes, and skeleton archer arrows (and medusa arrows, and trickster rocks) are indeed destroyed before a WallTriggerComponent's onActivate connector triggers. References to destroyed objects can still exist, but any attempt to index them other than indexing their class's methods, pass them to functions that expect an object, or assign keys to them will result in that error.
(In this context, "object" can mean a GameObject, like in this case, or a Component or other class like Champion or Map; they all have this in common).
There are a few workarounds you could use to ensure that the object hasn't been destroyed before sending it to your script. I think the easiest one would be to use this onActivate hook in the definitions of all your WallTriggerComponents:
Code: Select all
onActivate = function(self, entity)
-- Ensure the triggering entity is on the map, preventing already-destroyed objects (fragile ItemComponents, mainly) from triggering connectors.
for e in self.go.map:allEntities() do
if e == entity then
return true
end
end
return false -- Do not trigger connectors
end
(If you know your wall trigger can only be hit by projectiles in a few specific squares - most wall triggers can only be hit by projectiles in their own square unless you are using extreme projectile speeds, extreme time multipliers, or huge projectile colliders - then you can use one or a few entitiesAt() calls instead of allEntities() here, of course, which is faster in some circumstances, but as most dungeons will never have multiple wall triggers being triggered on the same frame, such an optimization is unlikely to be useful.)
Re: debugDraw
Posted: Sat Apr 22, 2023 12:25 am
by RayB
Once again. Thank you for the good advice.
Re: debugDraw
Posted: Wed Jan 17, 2024 6:58 pm
by RayB
I am trying to remove an item from my trickster monster. In the inspector window I gave him an iron key and set its id to 'trap_door_key'. If you kill him before he opens the door, he drops the key so the player can use it to open the door. but If he gets to the door and opens it himself I would like to remove the key from his inventory so he won't drop it when you kill him.
I tried - 'tomeRoomTrickster.monster:removeItem("iron_key")' and also 'tomeRoomTrickster.monster:removeItem("trap_door_key")' but both give an error saying item component expected got ???. I have tried indexing both of these with a '.item' added on but nothing works.
Could I please get the correct code for this.
Also, I have tried to print 'tomeRoomTrickster.monster:getLootDrop()' before killing him and after he is dead and drops the loot but it always prints nil.
Also, findEntity("trap_door_key") returns nil if the key is in the monsters inventory.
How can I access a monsters loot?
Re: debugDraw
Posted: Thu Jan 18, 2024 3:31 am
by Isaac
If you use the openLockWith() brain method, and include the key name, it will auto-destroy the key item after opening the lock.
Code: Select all
trickster_1.brain:openLockWith("lock_gold_1", "trickster_gold_key")
Code: Select all
--Placed inside script entity
trickster_1.monster:addItem(spawn("gold_key",nil,nil,nil,nil,nil,"trickster_gold_key").item)
trickster_1.brain:addConnector("onThink", self.go.id, "unlock")
function unlock()
if trickster_1.brain:here("lock_gold_1") and trickster_1.brain:carrying("trickster_gold_key") then
trickster_1.brain:openLockWith("lock_gold_1", "trickster_gold_key")
end
end
Re: debugDraw
Posted: Fri Jan 19, 2024 1:45 am
by RayB
Thank you!