A
Arrogant
Guest
So yesterday to add to my wiring system in my game, I created logic gates for it (NOT, AND, XOR and OR). These worked perfectly up until I opened gms today and found randomly that some of them just didn't work.
Full adder I put into my game not working anymore(when all inputs are 1, the outputs should both be 1):
https://gyazo.com/e360722406d19c855e403c8219eac222
2 of these 3 AND gates work, yet I see no reason the third one doesn't work:
https://gyazo.com/39d1efd9121aa10a457a8d9ba8642575
Example of a gate working (XOR):
https://gyazo.com/f15be6e1bfe0b59be04e67c73f27f6d6
The adder, AND gates and others were working yesterday, thus i'm extremely confused why they are not working today. I'll post as much as I think you would need to about the AND gate to save time and because gates such as OR are very similar.
Wire object:
AND gate:
Connector object:
As for the "buttons" they just activate the event user 0 of the wire object.
The XOR gate which is seen working is completely the same apart from this:
if(left == 1 or right == 1)
{
if(left = 0 or right = 0)
{}
}
(Note that even though the XOR in the gyazo is working, there are other instances of it not working
The way it works is it looks for two wire objects on either side of it, then sees if their "powered" variable = 1, then if both wires on either side of it are powered, it will output to the event user of the connector obj which outputs to any wire object around it. (The reason I created the connector object was so the signal didn't back track (couldn't think of another way to do it))
If you need any more information please ask.
Sorry for the long post and thanks in advance.
Full adder I put into my game not working anymore(when all inputs are 1, the outputs should both be 1):
https://gyazo.com/e360722406d19c855e403c8219eac222
2 of these 3 AND gates work, yet I see no reason the third one doesn't work:
https://gyazo.com/39d1efd9121aa10a457a8d9ba8642575
Example of a gate working (XOR):
https://gyazo.com/f15be6e1bfe0b59be04e67c73f27f6d6
The adder, AND gates and others were working yesterday, thus i'm extremely confused why they are not working today. I'll post as much as I think you would need to about the AND gate to save time and because gates such as OR are very similar.
Wire object:
Wire object create:
Wire object begin step:
Wire object step:
Wire object event user 0:
Code:
image_speed = 0;
powered = 0;
Code:
image_index = 0;
Code:
powered = 0;
Code:
powered = 1;
if image_index == 0 {
image_index = 1;
for(var i = 0; i < 360; i += 90)
with obj_wire
if place_meeting(x + lengthdir_x(1, i), y + lengthdir_y(1, i), other)
{
event_user(0);
}
for(var i = 0; i < 360; i += 90)
with instance_place(x + lengthdir_x(1, i), y + lengthdir_y(1, i), obj_notGate)
{
event_user(0);
}
}
AND gate:
AND gate create:
And gate step:
AND gate begin step:
Code:
image_speed = 0;
right = 0;
left = 0;
Code:
with instance_place(x+1, y, obj_wire)
{
if(powered == 1)
{
other.right = 1;
}
else
{
other.right = 0;
}
}
with instance_place(x-1, y, obj_wire)
{
if(powered == 1)
{
other.left = 1;
}
else
{
other.left = 0;
}
}
if(left == 1 and right == 1)
{
image_index = 1;
for(var i = 0; i < 360; i += 90)
with instance_place(x + lengthdir_x(1, i), y + lengthdir_y(1, i), obj_connector)
{
event_user(0);
}
}
Code:
image_index = 0;
Connector object:
Connector object create:
Connector object begin step:
Connector user event 0:
Code:
image_speed = 0;
Code:
image_index = 0;
Code:
if image_index == 0 {
image_index = 1;
for(var i = 0; i < 360; i += 90)
with instance_place(x + lengthdir_x(1, i), y + lengthdir_y(1, i), obj_wire)
{
event_user(0);
}
The XOR gate which is seen working is completely the same apart from this:
if(left == 1 or right == 1)
{
if(left = 0 or right = 0)
{}
}
(Note that even though the XOR in the gyazo is working, there are other instances of it not working
The way it works is it looks for two wire objects on either side of it, then sees if their "powered" variable = 1, then if both wires on either side of it are powered, it will output to the event user of the connector obj which outputs to any wire object around it. (The reason I created the connector object was so the signal didn't back track (couldn't think of another way to do it))
If you need any more information please ask.
Sorry for the long post and thanks in advance.