1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Trying To Get Power Cables And Batterys To Work

Discussion in 'Legacy GameMaker Community Tech Support' started by Logan Bevans, Jan 25, 2019.

Thread Status:
Not open for further replies.
  1. Logan Bevans

    Logan Bevans Member

    Joined:
    May 17, 2018
    Posts:
    27
    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;




    }
    }
     
  2. Logan Bevans

    Logan Bevans Member

    Joined:
    May 17, 2018
    Posts:
    27
    upload_2019-1-24_19-39-41.png Just A visual of what i mean
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice