I have a trigger made with a sensor, a player made with a body and a sensor in feet. When the player touches the trigger , it sends a message to 3 spawners, spawning 3 boxes in the map. Its all okey, but when a box (you can spawn making click) touches the trigger, it stops drawing. The "physic" body is there, still making collisions, but its not drawn. I cant manage to know how. Thanks you for reading.
So, Spawn a box making click up the first tile with a black thing inside. There its the trigger.
If you pass through it, 3 boxes will spawn. If you Spawn the box and touches them, it will disappear.
PD: This is my first time with lua, if you can give me some coding advices i would be really appreciated.
Objects disappearing
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Objects disappearing
- Attachments
-
- test.love
- (73.29 KiB) Downloaded 130 times
Re: Objects disappearing
Your code is pretty complex so I am not sure how to fix it exactly but I'm trying to trace your problem.
When your new block (from the mouse click) is spawned and collides with the sensor, it triggers beginContact.
You then have this code:
which inserts the objects data into the: table msg_manager.message_list
Then, as msg_manager:update() is called, you loop through the message_list table.
You then have this code:
Which takes us to multisource:read_msg(msg), which then calls:
aaah now I'm going in circles!
I don't know the reason behind the send_message function but that seems to be the root of the problem...
Why do you need this for a collision between two objects?
When your new block (from the mouse click) is spawned and collides with the sensor, it triggers beginContact.
You then have this code:
Code: Select all
msg_manager:send_message(b_name,a_name,{reason="c_start"})
Then, as msg_manager:update() is called, you loop through the message_list table.
You then have this code:
Code: Select all
object_manager.object_list[object_manager:getObjectByName(msg.to)]:read_msg(msg)
Code: Select all
msg_manager:send_message(self.name,self.args["source_"..i],{reason=1})
I don't know the reason behind the send_message function but that seems to be the root of the problem...
Why do you need this for a collision between two objects?
wat ya mean she's in another castle!?
Re: Objects disappearing
The object manager creates and updates the objects.
Objects sends messages between them to interact , and send information.
Its an easy and simple method, so i dont see wheres is the problem, beucase its exclusive with the boxes, beucase it doesnt happend with the player.
Im thinking of rewritting everything, if you could give me some advices it will be great. Im very used to program in a kind of Object Oriented (Im not so good designing).
The multisource inputs sends messages to all the objects listed in his arguments loaded from de Tiled Map (*.tmx). If you dont use it still happens.
Edit:
I removed the message system, and still happends. This is fucking my mind u.u.
I think the problem might be when it loops through all the objects to draw them, maybe it skip it, but i dont know where.
Edit2: I think i solved it, i changed ipars to pairs in the loop that updated them, and now its all ok. I will have to test it more. Thank you
Objects sends messages between them to interact , and send information.
Its an easy and simple method, so i dont see wheres is the problem, beucase its exclusive with the boxes, beucase it doesnt happend with the player.
Im thinking of rewritting everything, if you could give me some advices it will be great. Im very used to program in a kind of Object Oriented (Im not so good designing).
The multisource inputs sends messages to all the objects listed in his arguments loaded from de Tiled Map (*.tmx). If you dont use it still happens.
Edit:
I removed the message system, and still happends. This is fucking my mind u.u.
I think the problem might be when it loops through all the objects to draw them, maybe it skip it, but i dont know where.
Edit2: I think i solved it, i changed ipars to pairs in the loop that updated them, and now its all ok. I will have to test it more. Thank you
- Attachments
-
- new_test.love
- (73.49 KiB) Downloaded 120 times
Who is online
Users browsing this forum: Amazon [Bot] and 9 guests