L
Logan Bevans
Guest
So im trying to get power cables to work like transfer power from a generator to lets say a battery iv gotten most of it working but how i have it set up its triggering all the cables so if i have a cable connected to a generator to a battery and another separate cable (not connected to a generator) connected to a battery once i turn on the generator both cables are activated and both charge the battery im not quite sure how to fix this any help would be appreciated
Conduit Creation Code://////////////////
image_index = 0;
image_speed = 0;
breaking = false;
hardness = 1;
index = 0;
item = obj_conduit_item;
transferRate = 10;
outputPower = 20;
Generator Step Even: //////////////////////
if place_meeting(x+16,y,obj_conduit)
or place_meeting(x-16,y,obj_conduit)
or place_meeting(x,y+16,obj_conduit)
or place_meeting(x,y-16,obj_conduit){
if place_meeting(x,y-32,obj_cobble){
image_index = 1;
obj_conduit.outputPower = 20;
}
if !place_meeting(x,y-32,obj_cobble){
image_index = 0;
obj_conduit.outputPower = 0;
}
}
Battery Creation Code://///////////////
image_index = 0;
image_speed = 0;
breaking = false;
hardness = 0.75;
index = 0;
item = obj_leadstonecell_item;
batteryCapacity = 0;
powerTransfer = 10;
Timer = false;
maxCapacity = 1000;
transferRate = 10;
Battery Step Event:////////////////
///Charging
if instance_exists(obj_conduit){
if place_meeting(x+16,y,obj_conduit)
or place_meeting(x-16,y,obj_conduit)
or place_meeting(x,y+16,obj_conduit)
or place_meeting(x,y-16,obj_conduit){
if obj_conduit.outputPower > 0 {
Timer = true;
}
}
if Timer = true{
powerTransfer -=1;
}
if powerTransfer < 0 {
powerTransfer = transferRate;
batteryCapacity += obj_conduit.outputPower;
}
if batteryCapacity > maxCapacity {
Timer = false
batteryCapacity = maxCapacity;
powerTransfer = 0;
}
if obj_conduit.outputPower = 0{
Timer = false
powerTransfer = 0;
}
if batteryCapacity = 10{
image_index = 1;
}
if batteryCapacity = 160{
image_index = 2;
}
if batteryCapacity = 320{
image_index = 3;
}
if batteryCapacity = 480{
image_index = 4;
}
if batteryCapacity = 640{
image_index = 5;
}
if batteryCapacity = 800{
image_index = 6;
}
if batteryCapacity = 1000{
image_index = 7;
}
}
Just A visual of what i mean the red boxes are the batterys and they all charged up even though the once to the left arnt connected to a generator, im assuming its something to do with how i call the variable obj_conduit.outputpower from the battery or generator thats doing it.
Conduit Creation Code://////////////////
image_index = 0;
image_speed = 0;
breaking = false;
hardness = 1;
index = 0;
item = obj_conduit_item;
transferRate = 10;
outputPower = 20;
Generator Step Even: //////////////////////
if place_meeting(x+16,y,obj_conduit)
or place_meeting(x-16,y,obj_conduit)
or place_meeting(x,y+16,obj_conduit)
or place_meeting(x,y-16,obj_conduit){
if place_meeting(x,y-32,obj_cobble){
image_index = 1;
obj_conduit.outputPower = 20;
}
if !place_meeting(x,y-32,obj_cobble){
image_index = 0;
obj_conduit.outputPower = 0;
}
}
Battery Creation Code://///////////////
image_index = 0;
image_speed = 0;
breaking = false;
hardness = 0.75;
index = 0;
item = obj_leadstonecell_item;
batteryCapacity = 0;
powerTransfer = 10;
Timer = false;
maxCapacity = 1000;
transferRate = 10;
Battery Step Event:////////////////
///Charging
if instance_exists(obj_conduit){
if place_meeting(x+16,y,obj_conduit)
or place_meeting(x-16,y,obj_conduit)
or place_meeting(x,y+16,obj_conduit)
or place_meeting(x,y-16,obj_conduit){
if obj_conduit.outputPower > 0 {
Timer = true;
}
}
if Timer = true{
powerTransfer -=1;
}
if powerTransfer < 0 {
powerTransfer = transferRate;
batteryCapacity += obj_conduit.outputPower;
}
if batteryCapacity > maxCapacity {
Timer = false
batteryCapacity = maxCapacity;
powerTransfer = 0;
}
if obj_conduit.outputPower = 0{
Timer = false
powerTransfer = 0;
}
if batteryCapacity = 10{
image_index = 1;
}
if batteryCapacity = 160{
image_index = 2;
}
if batteryCapacity = 320{
image_index = 3;
}
if batteryCapacity = 480{
image_index = 4;
}
if batteryCapacity = 640{
image_index = 5;
}
if batteryCapacity = 800{
image_index = 6;
}
if batteryCapacity = 1000{
image_index = 7;
}
}