Results 1 to 4 of 4

Topic: Basic Guide to Editing Scripts

  1. #1
    LEGENDARY EAGLE MASTER

    User Info Menu

    Basic Guide to Editing Scripts

    Hello,

    In this guide we will teach you some basic GPC Programming.

    We will be using an example script, please follow steps 1 through 4 in this guide to obtain the macro - https://cronusmax.com/forums/showthread.php?t=143558

    First, lets explore the layout of this script;

    At the start of the script, you can see large amount of green text and each line has the prefix '//'. Any text with this prefix is purely for notes and is ignored by the CronusMax.



    Now lets look at the define section. Definitions must always be made before the main section so should be placed before the command 'main'.

    In this script we can see the following definitions being set;

    This means we are telling the CM that whenever the value turbofirespeed is referenced, its value is 80 and when turbobutton is stated, its value is 4,

    Next is the main script, where we find the following;


    Here we are telling the CM the if it receives any value(input) from the turbobutton, it must run the combo named turbofire.

    But, I hear you think, turbobutton equal 4 which isn't a button. So we are telling the CM that if it gets the value 4, run the combo. Where does it get 4 from?

    when we reference a number is this way, we are referring to the identifiers which are already built in to the CM. Here is a table of those identifiers;

    As you can see from the table, 4 identifies as R2 on the PS3 and PS4 Gamepads. It also identifies as Right Trigger on the Xbox One and 360 Gamepads.
    So we can either state that turbobutton=4 or we could use the identifiers in the above picture and say the turbobutton=XB360_RT. Both will press the same button.

    For more information on the identifiers, see this page - https://cronusmax.com/instructions/api-reference/

    So now we know that this;

    means we are telling the CM that if the right trigger is pressed, run the combo turbofire.

    Now lets look at that combo;

    The command 'combo turbofire' is identifying itself as that macro. Anything within the { after turbofire and the } at the end, is part of this combo and any commands within are sent to the CM when it is run.

    So, lets look at the commands.

    set_val(turbobutton,100); is telling the CM to full press the turbobutton as defined above. We know that turbobutton = 4 and 4 identifies at the right trigger so what is the 100?

    The value 100 after the comma, is the weight or how hard it is to press the button. In the case of digital buttons (Such as A,B X or O) their values are 0 when idle and 100 when pressed. Triggers are analouge so we can give them any value from 0 to 100. With 0 being idle and 100 being fully pressed. In this case, we are telling the CM to fully press whichever button is defined as the turbobutton.

    Next we have the command 'wait (turbofirespeed);' Here we are telling the CM to wait before processing the next line. All values for wait times are in milliseconds and we know that turbofirespeed=80 as it was defined above. So this command translates into wait (80); which tells the CM to wait 80 milliseconds before moving to the next command.

    Next we have 'set_val(turbobutton, 0); as you have probably worked out already, we are now telling the CM to set the button to idle or off.

    Next the wait command and set_val commands repeat.

    So, in this combo we have two wait commands of 80 milliseconds to each button press, therefore the CM will press the turbobutton every 160 milliseconds or 6.25 times a second (1000/160).

    So, lets test this script before we use it in game. Select Compiler from the menu at the top of Cronus Pro and then Build and Run or press F5 on your keyboard. This command will first compile the code and check for errors. If no errors are found it will load the macro into test slot 10 on your CM and run the Device Monitor. You screen should now look like this;

    On the left hand side of this window, you will see a box that contains the physical inputs from your connect controller and in the box to the right, you will see what the CM is sending to the console. So in that right hand box, select the Right trigger so we can monitor your xbox. In this case, I am using an Xbox 360 controller and outputting Xbox 360 controller commands so I would select XB360_RT.

    Clicking it will highlight to output in red and you will notice a red bar appear in the bottom box. This box is a monitor and will display the output history for you. Although you cannot see it right now, that red line is moving.

    Now press and hold the right trigger on you controller. You will notice that XB360_RT is highlited in yellow in the left box and flashing green in the right box.

    The monitor is telling you that although you have the right trigger physically held on your controller, the CM is quickly pressing and releasing the RT for you and sending those commands to your console. The speed can be observed in the graph at the bottom.


    Now we know that whenever this script is active, if we press the the right trigger the CM will turbo the button for us.

    6 times a second isn't particularly fast, so what if we want it to be quicker than that? We can easily change the speed.

    Close the device manager by clicking the X in the top right corner and we will adjust the speed.

    Locate 'define turbofirespeed=80'. We now know that this definition is the delay between commands within the combo. So, if we increase this value, we decrease the number of button presses per second but we want to increase them, so we decrease this number.

    Delete the value 80 and replace it with 40. You have now halved the delay in the wait times within the combo turbofire, so it will now press the button twice as fast!

    But what if we didn't want the RT turboed but instead wanted the LT (Left Trigger). We can change that too.

    Locate 'define turbofirebutton=4'. We know that 4=RT so looking at the identifiers table above, we can see that LT is 7. So replace 4 with 7.

    Now, lets test our edits. Build and Run the script again and click the LT in the output section of the device manager. It will highlight in blue.
    Press and hold the Left Trigger this time and you will see the same effect as the RT before only this time it is on the LT and twice as fast.


    But before when we were here, the right trigger turboed. How can we be sure it isn't any longer? Press and hold it now and the device monitor will show you this;

    As you can see, the output of your Right Trigger is no longer be altered by the CM.

    There you have it, you have edited and test a script. If you wish to test it in game, when you build and run, the macro is temporary loaded into your CM and is active.

    So while you have the device montior up, the signal you see within it are being sent live to your console if your CM is plugged into it.

    This allows us to edit and make tweaks to are combo while the game is loaded. Once you are happy the macro does what you want it to do, you can move on and follow steps 6 onwards in this guide - https://cronusmax.com/forums/showthread.php?t=143558 and the macro will be available to you whenever you need it via a simple press of the button on the CM.
    Attached Images Attached Images

  2. The Following 9 Users Say Thank You to KittyDawn For This Useful Post:


  3. #2
    SILVER I

    User Info Menu

    Re: Basic Guide to Editing Scripts

    Thanks for sharing the details. but when i run the following proggrame its showing error.

    int loop; // Initialize keyword for our switch to turn this script on and off at will.

    main {

    if (event_press(8)) {loop=!loop;} // Press LS/L3 (identifier 8) to enable/disable this combo.
    if (loop) {combo_run(switch);} // If the loop is active, run the combo 'switch'.
    if (!loop) {combo_stop(switch);} // If the loop is inactive, stop combo. Embarkup
    // Since this command resides in the MAIN area of the script, it is always running.
    // You can start and stop this at will by pressing LS/L3. embarkdaily

    }

    combo switch {

    if (get_val(button)) {combo_run (turbofire);} // This runs the combo whenever the button (RT/R2 in this case) is pressed.

    }

    combo turbofire { // Turbofire combo

    set_val(button,100); // This tells the Titan One to press the button.
    wait (speed); // This tells the Titan One to wait the amount of milliseconds defined by speed above.
    set_val(button,0); // This tells the Titan One to release the button.
    wait (speed); // ... and one more wait to pause between button presses

    }


  4. #3
    Senior Support Staff


    User Info Menu

    Re: Basic Guide to Editing Scripts

    Quote Originally Posted by austin112 View Post
    Thanks for sharing the details. but when i run the following proggrame its showing error.
    of course, lots of stuff are missing
    what do you want to achieve with combo 'switch'? a switch for rapidfire?

  5. #4
    SILVER II

    User Info Menu

    Re: Basic Guide to Editing Scripts

    Hey guys thanks for the tips. Unfortunately I can't make it work. I need a simple solution for pression A button on Xbox One Controler every 2-3 seconds. Is there anything pre-made on croxusmax plus I can use? Or does someone knows how to build that?

    Appreciate the help.

Posting Permissions

  • You may not post new topics
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •