Page 1 of 4 1234 LastLast
Results 1 to 30 of 118

Topic: COMPLETE NOOBS GUIDE TO SCRIPTING???

  1. #1
    GOLD NOVA III

    User Info Menu

    COMPLETE NOOBS GUIDE TO SCRIPTING???

    Hi.
    I would like to start this thread and hopefully other more knowledgeable people my jump in to help build this up.
    I am the complete beginner here so I will be creating tutorials based on the knowledge of others. My hope is that by following other people I can learn and interpret the scripts for the beginner.
    I, and many other people look at the scripts on these pages and either want to combine multiple scripts together or want to adapt an existing script to their own needs, or even build one from scratch. And like me, have no idea how to go about it. So what do we do. We ask the clever scriptwriters on here to do it all for us, which they do and we learn nothing.
    So with my limited knowledge I would like to see if that could be changed by creating small scripts from scratch with every line commented to show what it does and grow on from there.
    Above all I want this to stay a beginners guide, for complete idiots like me.
    I would like to have some rules for this thread.

    1. Always keep it basic with explanations please.
    2. If mistakes are made with your own input then can you please correct it, otherwise it might get confusing.


    I am also going to start an index for the tutorials.

    1. Excaliburs great explanation of GPC scriping. #6
    2. Pressing Buttons #3
    3. Commenting #7
    4. Releasing buttons #14


    What do you think?
    Alan.

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


  3. #2
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    I support this idea. I began to prepare such lessons, the problem is that they are time consuming. But I will start working on them I hope you and others to get involved.

  4. The Following 6 Users Say Thank You to Excalibur For This Useful Post:


  5. #3
    GOLD NOVA III

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Thanks for your support on this. I am going to try and put in as much time as I can, and hopefully learn at the same time. I am looking at making a start from something simple. So straight out of the manual comes this!
    Tutorial 1

    Now all this does is to keep the PS4 X button pressed down. Simples.




    The "main" procedure is mandatory and every GPC script must have one. This procedure is called by VM before every report be sent to console, you can think in this procedure as a loop which only ends when the script is unloaded.
    The command set_val writes the value 100 into PS4_CROSS, which means press this button hard (100%). As the PS4_CROSS is not a variable, IE it is not like the triggers which are variable by the amount they are pressed,
    but a reference to a data structure, (which I assume means it can only have a value of 100, pressed or 0 released) you can NOT make direct assignments like PS4_CROSS = 100; (not sure what this means yet, will edit when I find out)

    When writing a statement, they must be enclosed by brackets { } (please confirm I have this right).

    To change this to suit a different console or button all you need to do is change the PS4_CROSS to something else IE.
    XB360_A (presses the Xbox 360 A button)
    PS3_TRIANGLE (presses the PS3 Triangle button)
    XB1_Y (presses the Xbox One Y button)

    So far so good.
    So for the questions, to the more knowledgeable out there.

    1. Why can I not use PS4_CROSS = 100 to do the same thing, and.
    2. What is a direct assignment?
    3. Why are brackets used to enclose (PS4_CROSS, 100)?

    NOOB answers only please.
    And if I have anything wrong please say, and I will make the changes.

    Alan.

  6. The Following User Says Thank You to datalore01 For This Useful Post:


  7. #4
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    The best would be to ask specific questions related to GPC scripting language! I already have a ready answer for the main parts of the script. Tonight I will try to write them and let them post as a theme here.

  8. #5
    GOLD NOVA III

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    That would be great.
    Alan.

  9. #6
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    We can divide a program into three main parts.
    Will call first - Declarations block.
    Second - Main block
    The third - Subroutines block.
    Now we just talk about two of them - Main and Subroutines.
    In GPC script language main block is always only ONE. You'll know where it begins, when we see the special word main.
    Its boundaries are described by two characters { and }. If you can not find them - the easier it will be when you load the script in the Script Manipulator.
    He will show you where the limits of the main part.

    You can think of the main block as the motor of your car.
    When you turn the key - the engine starts running.
    But the car remains stationary. So we can stand in the car until we run out of fuel, but the car will not move.
    Why - because we have to do something else to run the car.
    The car can not read our thoughts (thank God) to know where we want to go.
    All who drives a car knows that the next step is to shift gears. We give a clear command of the engine and it drives the wheels.
    The main block operates in the same manner. We need to give clear command what to run at a precise moment.
    If you do not give a clear command - nothing will change.
    What you need to know about main block is that every millisecond computer starts to read the text between the two characters { }, starting from the first.
    Computer reads the text and trying to understand it. If it is understandable for him commands he will fulfill them.
    You will see that most often to get the computer to do something, we use a special word - if.
    As with the example of a car and driver - there engine expected to occur some event. If the driver shifted into first gear ( this is event), the engine drives the wheels.
    Similarly proceed and in the programming. We describe event inside of the main block. The main block and subroutines ( combos) work independently of one another,
    Attachment 242
    For example - if I want when I press button to light and quenched the light on my joystick, I have to describe it as understandable commands for the computer in the main block.This is most often described with a special word - if. If the user presses a button A - do this.
    The actual performance of our desire is transmitted to the subcontractor ( in GPC we call them - combo).
    As with the car if you run the wipers, the car will not stop, this will transmited this activity to a subroutine (combo WIPERS).
    These subcontractors are called combo in the programs of GPC Scripting Language.
    Main engine is only one (main block), but we have many subroutines ( combos) -like in car( one main block-engine) and many subrutins (combos).

    GPC Scripting Language gives you all the parts to make your desired car, but you need to learn how to assemble these parts to make them work properly.
    Here in Bulgaria we say RFM (Read the F..cking Manuals )
    go to http://www.gamepadproxy.com/manual/k..._reference.htm
    - and lern how this parts work

  10. The Following 7 Users Say Thank You to Excalibur For This Useful Post:


  11. #7
    GOLD NOVA III

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Hi. This is going to be a very straightforward tutorial, but an important one.
    Tutorial 2.
    Comments.

    Now it is very important to comment parts of your script, so you do not loose track of things that are happening.
    Also it helps other people to know what is going on. Also it can be used to disable whole parts of a script for debugging purposes.
    There are 2 types of comments, 1 line and block
    So here is the above script with a 1 line comment.


    Note: you must use the double backslash to make a comment.



    And here is the same script completely disabled using a block type comment



    This comment will completely disable this script from functioning and starts with /* and ends in */ it can be used to disable large blocks of code or text. Be careful when using it on large scripts as it can easily cause problems if not set up right.
    Also note that comments or disabled blocks of script will show up as green in the compiler to show they are not executed.

    Alan.

  12. #8
    MASTER GUARDIAN ELITE

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    If no one mind I'll like to answer datalore01 first questions in case someone wants a followup. If you don't care about the first questions please ignore this one. Take note though that I only started GPC scripting 2 weeks ago so I think I still am a noob like everyone else but I think I can answer datalore01 questions in a noob friendly way.
    1. Why can I not use PS4_CROSS = 100 to do the same thing, and.
    2. What is a direct assignment?
    3. Why are brackets used to enclose (PS4_CROSS, 100)?
    1. This isn't really a answer but something you should remember. If you want PS4_CROSS equal to 100 do NOT use PS4_CROSS = 100. It will never work. See below why.

    2. Direct assignment just means you're assigning the variable a value(or changing the value if it already has one) but if it's not a variable you can't make a direct assignment. PS4_CROSS is NOT a variable so PS4_CROSS = 100 is wrong. Don't do it. You will get an error.

    3. This is also not really an answer but a rule. if you have something like PS4_CROSS, 100 it has to have brackets like this (PS4_CROSS, 100).
    Here's an example

    I made this using Combo Magick. See a pattern? They all have brackets. if you have something like XB360_A, 0 that also need to have brackets (XB360_A, 0).

    Also I would like to add I think a noob doesn't need to know the reason why it does this, they only need to know how to do it.

    So like If I want the script to push down the B button on the xbox controller I type set_val(XB360_B, 100). Why does set_val(XB360_B, 100) push down the B button? It doesn't matter. Only thing a noob should know is set_val(XB360_B, 100) push down the B button on the xbox controller. That way every time they go "Hey I don't know how to make my script push down the B button?" then they will go "Oh wait I remember, if I type set_val(XB360_B, 100) that will push down the B button!".

    Try the script datalore01 made everyone and replace the set_val(PS4_CROSS, 100) with any other button e.g set_val(PS4_SQUARE, 100) and it will push down a different button when the script is running.

    I hope this post is helpful. I tried my best to answer the questions noob friendly. If anything is wrong or misleading please let me know.

  13. The Following 5 Users Say Thank You to token For This Useful Post:


  14. #9
    GOLD NOVA III

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    This is why I started this thread. I just hope that people keep adding to it.
    Thanks Excalibur and Token, this is what we need.
    I think you may have missed a small detail from your post though Token.

    "So like If I want the script to press the B button on the xbox controller I type set_val(XB360, 100). Why does set_val(XB360, 100) press the B button? It doesn't matter. Only thing a noob should know is set_val(XB360, 100) press the B button on the xbox controller. That way every time they go "Hey I don't know how to make my script push down the B button?" then they will go "Oh wait I remember, if I type set_val(XB360, 100) that will push down the B button!". "

    Should it not be (XB360_B, 100).

    Alan

  15. #10
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by datalore01 View Post
    Thanks for your support on this. I am going to try and put in as much time as I can, and hopefully learn at the same time. I am looking at making a start from something simple. So straight out of the manual comes this!
    Tutorial 1

    Now all this does is to keep the PS4 X button pressed down. Simples.




    The "main" procedure is mandatory and every GPC script must have one. This procedure is called by VM before every report be sent to console, you can think in this procedure as a loop which only ends when the script is unloaded.
    The command set_val writes the value 100 into PS4_CROSS, which means press this button hard (100%). As the PS4_CROSS is not a variable, IE it is not like the triggers which are variable by the amount they are pressed,
    but a reference to a data structure, (which I assume means it can only have a value of 100, pressed or 0 released) you can NOT make direct assignments like PS4_CROSS = 100; (not sure what this means yet, will edit when I find out)

    When writing a statement, they must be enclosed by brackets { } (please confirm I have this right).

    To change this to suit a different console or button all you need to do is change the PS4_CROSS to something else IE.
    XB360_A (presses the Xbox 360 A button)
    PS3_TRIANGLE (presses the PS3 Triangle button)
    XB1_Y (presses the Xbox One Y button)

    So far so good.
    So for the questions, to the more knowledgeable out there.

    1. Why can I not use PS4_CROSS = 100 to do the same thing, and. Answerer :Because in every language there are rules of writing.
    2. What is a direct assignment?: Answerer :Must be understood what is this variable.
    3. Why are brackets used to enclose (PS4_CROSS, 100)? Answerer :To be clear about the computer who gets this value. set_val ( that means - gift the value ) then in brackets -must indicate who will receive this value ( in your example - PS4_CROSS) , then we write comma ( this means for the computer -after the comma next will be the value )

    NOOB answers only please.
    And if I have anything wrong please say, and I will make the changes.

    Alan.
    Sorry for my English!

  16. #11
    MASTER GUARDIAN ELITE

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Whoops. Thanks datalore01, I can't believe I didn't notice that lol. I'm still a noob so I make mistakes.

  17. #12
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by datalore01 View Post
    This is why I started this thread. I just hope that people keep adding to it.
    Thanks Excalibur and Token, this is what we need.
    I think you may have missed a small detail from your post though Token.

    "So like If I want the script to press the B button on the xbox controller I type set_val(XB360, 100). Why does set_val(XB360, 100) press the B button? It doesn't matter. Only thing a noob should know is set_val(XB360, 100) press the B button on the xbox controller. That way every time they go "Hey I don't know how to make my script push down the B button?" then they will go "Oh wait I remember, if I type set_val(XB360, 100) that will push down the B button!". "

    Should it not be (XB360_B, 100).

    Alan
    Should it not be (XB360_B, 100). - In order to understand the computer what you want to accomplish, you should write in their own language. If this was a man he could get out what you want, but when it comes to computer should be aware that he can not think. Computer performs only clear and precise commands that are understandable for him. If you write command like this (XB360_B, 100) he can not understend what you want from him. It is a machine and it can not think. Machine execute commands only if they are written in its language. ;-this is used to separate comands.

    Another problem. When you want the computer to press a button, you should tell him and how long to keep it pressed.
    For example:
    if we write like this:

    What this means for the computer - some may think that this means - press B button quickly three times.
    When the computer reads these words, he will understand them as follows:

    1. press B
    2. press B ( but the B button is already pressed - OK, then just hold B button pressed)
    3. press B ( but the B button is already pressed - OK, then just hold B button pressed


    And all this will happen in 2-3 milliseconds. User wanted to be pressed the B button three times in a very short time, but has not given a clear command of the computer. To accomplish what you wanted the user needs to write as follows:

    To push a button again, we must first release him - set_val(XB360,0) with this command we say to the computer - release button B ( when we gift the button value of zero - this means for the computer - release ) . It should also say how long will all this happen. With command wait( amount of time ) we say to the computer press and wait ( amount of time ), followed until the next command.- release button B for amount of time (wait(20); ) and so on.

    At line 1 I forgot to put separator for the commands and this is not a problem for the compiler, but good programing practice is to put separator because when somebody will read this script it is more easily to understand it.

  18. The Following 3 Users Say Thank You to Excalibur For This Useful Post:


  19. #13
    GOLD NOVA III

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    More good input. Thanks Excalibur.
    Your English is a lot better than my Bulgarian (I do not know a single word)

    I have a question with your basic script.
    At lines 3,7, and 11 you are not specifying Set_val(XB360_B,100) is this correct?
    Do you not need to tell the script to release Xbox B button or it surely would not know what button it needs to release.


    Thanks for putting it right Token, we don't want to confuse people.
    If anyone does make a mistake on their script can they please correct it for other people.
    Also I will still be going over the same ground as you just to put it into the tutorials which I would like to keep running, so it gives confused people like me knowledge of the syntax from different perspectives.
    Please keep them coming.
    Many thanks.
    Alan.

  20. #14
    MASTER GUARDIAN ELITE

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by Excalibur View Post
    explanation
    Thanks Excalibur. I want to say this. If you used Combo Magick and the combo is fine then skip Excalibur's instructions. You don't need to worry yourself with making or editing a combo if you don't need too.
    I hope this section is noob friendly enough. Please let me know if I'm wrong about something, made a typo, or caused any confusion.

    After you typed this combo or made it with Combo Magick, your combo should look like the following template combo magick{insert action}. Look below to see an example I made with Combo Magick and then I edited it.

    The word magick after the word combo is the name . It's the default name if you used Combo Magick. Change it if you wish.

    Once your combo is ready we have to execute the combo. Let's say I want to execute magick whenever I press and hold the B button on the 360 controller. We need to add this in the main section

    If you haven't figure it out yet the XB360_B in if(get_val(XB360_B)) is the button that executes the combo and magick in combo_run (magick); is which combo is executed. Change anything if you want too.


    Okay you read everything and it didn't help in making your script. Maybe you want to do something completely different or something more complicated than holding down a button? Ask a question and me or someone will answer in a noob friendly way.

    I'm sorry I forgot to add in the most important part. What it should look like when it's put together.


    Your script should look like the above. Have a question? Post it and me or someone will answer it.

  21. The Following 2 Users Say Thank You to token For This Useful Post:


  22. #15
    GOLD NOVA III

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Tutorial 4
    Button Releases.

    So pressing a button is one thing but we also need to tell the script how to release them.
    Don't forget to always start block statements with "main" and the 2 brackets that enclose the script.




    So when you press the Xbox 360 A button the Y button will also get pressed for 1 second and then released. As you can see this basic script will press the B button for 1 second and then release it.
    To do this we have used the if statement to start the combo IE, if we press the A button then run the combo called test.
    The Y button is pressed fully (100) and then after 1 second it is released (0)
    The wait time uses milliseconds so 1000 milliseconds is 1 second and 500 milliseconds is half a second.
    Most standard button presses and releases are done within 10 to 30 milliseconds.

    Alan.

  23. #16
    GOLD NOVA III

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Token,
    I assume you have answered my question but, can you please show me the whole script as it would look all together, so it would compile and run.
    I tried this but got an error.


    Alan

  24. #17
    MASTER GUARDIAN ELITE

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by datalore01 View Post
    Token,
    I assume you have answered my question but, can you please show me the whole script as it would look all together, so it would compile and run.
    I tried this but got an error.

    Alan
    I'm sorry I forgot to do that part. I updated my post with how it should look like.

  25. #18
    GOLD NOVA IV

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by datalore01 View Post
    Tutorial 4
    Button Releases.

    So pressing a button is one thing but we also need to tell the script how to release them.
    Don't forget to always start block statements with "main" and the 2 brackets that enclose the script.




    So as you can see this basic script will press the B button for 1 second and then release it.
    The button is pressed fully (100) and released (0)
    The wait time uses milliseconds so 1000 milliseconds is 1 second and 500 milliseconds is half a second.
    Most standard button presses and releases are done within 10 to 30 milliseconds.
    Question, why does this simple script not run in the compiler? Answered below.
    Alan.
    This is actually wrong. The "wait" statement cannot be used inside the main function. It must be used inside a combo function.

    Also, depending on the script, but most of the time, you do not need to set_val back to 0 because the script loops through and resets values on it's own. That's where your wait times come in, HOWEVER; in combos (killer instinct for example) will require the buttons being set back to 0. But for single button value changing...it mostly isn't required.

  26. #19
    MASTER GUARDIAN ELITE

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by datalore01 View Post
    Question, why does this simple script not run in the compiler?
    Just like what EODCM said, "wait" can't be used in the main function and If you get rid of " wait" then what you have left is the values 100 and 0 and that' won't do what we want. EODCM and Excalibur mentioned the main function and combo function. This is a good opportunity to talk about what they started.


    Quote Originally Posted by Excalibur View Post
    We can divide a program into three main parts.
    Will call first - Declarations block.
    Second - Main block
    The third - Subroutines block.
    If you read Excalibur's first post you should have a rough idea about the 3 blocks. If you don't mind Excalibur I'm going to repeat what you said for datalore01 but in my own way.
    First forget about the Declarations block. You don't need Declarations block for any simple scripts. Once we get to the more "advance" scripts, we will talk about it.
    That leaves the Main block and the Subroutines block . I'm not going to talk about why or what is the Main block and the Subroutines block but where do you put this and that.


    The Main block is where you put all your if statements e.g if(get_val(XB360_B)) combo_run (magick); goes in the Main block. A statement is an if statement if it starts with if.
    The Subroutines block is everything after the Main block and it's where all the combos go e.g combo magick{} goes in the Subroutines block. Look below
    If we apply what we learn from making our previous script, we can make a script where the B button is press and then release when this happens. For example (If I press XB360_UP then XB360_B will also be press and then release). To reiterate you need an if statement in the Main block to execute the combo in the Subroutines block.

    I hope this was noob friendly enough. Please let me know if I'm wrong about something, made a typo, or caused any confusion. If you have any questions post it and me or someone will answer.

  27. The Following User Says Thank You to token For This Useful Post:


  28. #20
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by datalore01 View Post
    More good input. Thanks Excalibur.
    Your English is a lot better than my Bulgarian (I do not know a single word)

    set_val(XB360_B,100) ;
    wait(20);
    set_val(XB360_B,0);
    wait(20);
    set_val(XB360_B,100);

    wait(20);
    ​set_val(XB360,0);
    wait(20);
    set_val(XB360_B,100);
    wait(20);
    ​set_val(XB360,0);
    wait(20);

    I have a question with your basic script.
    At lines 3,7, and 11 you are not specifying Set_val(XB360_B,100) is this correct?
    Do you not need to tell the script to release Xbox B button or it surely would not know what button it needs to release.


    Alan.


    You're right - I made ​​a mistake. If I tried to compile it I will get an error message. At line 3,7 and 11 must be set_val(XB360_B,0); instead set_val(XB360,0);
    If I try to compile this set_val(XB360,0) the compiler will say - ERROR line .. :'XB360' is not defined -
    our computer says I do not recognize thisComputer does not tolerate even a small error.

  29. #21
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???


    I think it's time to talk about variables. What is this 'animal'
    and how to use it.

    What Exactly is a Variable?:

    DEFENITION:
    A variable is the name for a place in the computer's memory where you store some data.
    This enables us to easily find this information and use it.

    A Real World Example of Variables:

    Imagine a very large warehouse with lots of storage bays, tables, shelves, special rooms etc.
    These are all places where you can store something.
    Lets imagine we have a crate of beer in the warehouse. Where exactly is it located?

    Let someone with good English to explain the different types of variables!

  30. The Following 2 Users Say Thank You to Excalibur For This Useful Post:


  31. #22
    MASTER GUARDIAN ELITE

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by Excalibur View Post

    I think it's time to talk about variables. What is this 'animal'
    and how to use it.

    What Exactly is a Variable?:

    DEFENITION:A variable is the name for a place in the computer's memory where you store some data.
    This enables us to easily find this information and use it.

    A Real World Example of Variables:

    Imagine a very large warehouse with lots of storage bays, tables, shelves, special rooms etc.
    These are all places where you can store something.
    Lets imagine we have a crate of beer in the warehouse. Where exactly is it located?

    Let someone with good English to explain the different types of variables!
    Excalibur gave us the definition and a real life example. I will show you variables in action. I will tell you where and when to use variables. I will try to keep this noob friendly. We will also talk about the Declarations block. Please let me know If I'm wrong about something, made a typo, or caused confusion.

    This is a simple rapidfire script that has variables in it. The variable's name can be anything so use whatever that makes sense in your script.
    Code:
    int rapidFireButton; // This is a variable we will use to determine which button will be the rapidfire button.
    
    int rapid_onoff = FALSE; /* This is also a variable. In this script if it's FALSE the script will be off and if it's TRUE the script will be on. This variable is optional. We don't need this variable but read this. 
    Noob said "I made PS4_CROSS the rapidfire button but it's really hard to navigate the game menu because the rapidfire script is always on! I sure wish I had a way to turn it off. Oh wait if I had the variable rapid_onoff in my script I can turn it off and on."
    
    
    Below is the Main block, everything above it is the Declarations block. There's a rule when using variables. You can only put variables in Declarations block. Don't put it in the Main block or Subroutines block. */
     main {
    
     if(get_val(PS4_SQUARE)) rapidFireButton = PS4_SQUARE; //using if statements the variable rapidFireButton will be PS4_SQUARE when you press the square button on the ps4 controller.
    /* if you want to you can add multiples if statement e.g when I press triangle, the variable rapidFireButton will be something. It does not have to be PS4_TRIANGLE e.g  if(get_val(PS4_CIRCLE)) rapidFireButton = PS4_TRIANGLE;  
    You're not limited to one if statement so use as many as you need. */
    
    
     if(event_press(PS4_SHARE)) rapid_onoff = !rapid_onoff; //sets variable to TRUE or FALSE if PS4_SHARE is pressed. It does that because we added the operator !. PS4_SHARE is the select button on a ps3 controller. Let's say you're using ps3 controller, change PS4_SHARE to PS3_SELECT. Same thing if you are using a xbox controller.
    
     if(get_val(rapidFireButton) && rapid_onoff) combo_run(RapidFire); /* The operator && means the word "and". So this statement says if the variable rapidFireButton is equal to PS4_SQUARE and the variable rapid_onoff is 
    TRUE then execute the combo RapidFire. */
    
    
    } // if you forgot, after Main block is the Subroutines block.
    
    // below is the combo the script will use
    combo RapidFire {
        set_val(rapidFireButton, 100);
        wait(20);
        set_val(rapidFireButton, 0);
    }
    I suggest copy/paste the above code first and try it out. Press the share button to turn it on and press square for rapidfire. If you have a different controller then modify the script to your controller. Afterwards try to apply or add your own changes. I hope you see why variables are useful. Without variables we couldn't make this script. The more you do gpc scripting the more ways you can utilize variables and everything else you learned.

    One more thing I have to say. This is a community gpc scripting guide for noobs so anyone is welcome to do it. If you have knowledge about a topic and you want to write a explanation then go ahead and write it up. If you have a question someone will answer.

    Please let me know if you like the script better using gpc code format.

  32. The Following 2 Users Say Thank You to token For This Useful Post:


  33. #23
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Thanks token !

    Let see what is write in GPC Reference :

    GPC supports only one primitive type: scalar integer.
    An integer is a number of the set Z = {..., -2, -1, 0, 1, 2, ...} which must be specified in decimal notation (base 10), optionally preceded by a sign ( - or + ). The integer type is represented by a 16 bits signed number, where the range is [-32768 ~ +32767]. The default initialized value is always zero.


    1. Declaring Variables

    A variable is just a place to store data in memory. Each variable has a name which start with a letter or underscore (_), followed by any number of letters, digits, or underscores. Uppercase is different from lowercase, so the names sam, Sam, and SAM specify three different variables. The scope of a variable is always global. Variables MUST be declared before the main procedure.

    Variables are always assigned by value. That is to say, after assigning one variable's value to another, changing one of those variables will have no effect on the other. GPC don't support assigning by reference.
    I'll give you an example of the use of variables.

    Look combo below. Now imagine that the time that we have defined as waiting must be changed. Currently it is 50, we want to try 60. Imagine now how change this value throughout the code. That's a lot of work. In this case it would be much better to use a variable instead of a specific value.
    We must declare this variable before main block.
    We have to tell the computer that will use the variable. This is done before the main block we record the following :

    int Delay_1=60;

    int - this is special word like $. When the computer read this word hi know that after it will be written the name of variables. In our case this is Delay_1 ( Delay_1 is the name of our variables ). Then you can see the sign = (this is an assignment statement). This means for the computer that we will give a specific value of this variable ( We are not obliged to give a specific value of the variable we declared. If we do not have a specific value, then the computer will automatically give zero). We want in this case to give for this variable a value of 60.
    Semicolon we use to separate this command from next command.



    Let's see how it looks code after this change. Instead of wait(50); now we have wait(Delay_1);
    When the computer reads the name of our variable it will replace it with its specific value ( in our case we gift the variable Delay_1 value of 60 ) . This means - when the computer read the line with code like this - wait(Delay_1); , hi will interprete like wait (60);. Now if this we want to change this value , we must change only in one place - in first line, where we declare our variable .

    int Delay_1=60; If we want to change this value to 70 ( for example) we just change replace value of 60 with new value 70. And our code will look like this:

    int Delay_1=70;




  34. The Following User Says Thank You to Excalibur For This Useful Post:


  35. #24
    MASTER GUARDIAN ELITE

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Good example Excalibur. I think I ramble in my post at the end. I will edit it out. I want to let you know your script has errors when compile.

    This is yours but with the variable Delay_1 added in and I fixed the Delay_10. I don't think you want Delay_10 right?
    *deleted*
    I will delete this when you update yours. Thank you Excalibur.

  36. #25
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by token View Post
    Good example Excalibur. I think I ramble in my post at the end. I will edit it out. I want to let you know your script has errors when compile.

    This is yours but with the variable Delay_1 added in and I fixed the Delay_10. I don't think you want Delay_10 right?

    I will delete this when you update yours.

    This is not related to your post but I like to know should I use PHP /PHP instead or does it look better with CODE /CODE?
    Thanks token you are right. After I post I sow this error and fixt it . When you use Script Manipulator is beter to replace whole word - wait(50); -> re please with - wait(Delay_1);

  37. #26
    MASTER GUARDIAN ELITE

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by Excalibur View Post
    Thanks token you are right. After I post I sow this error and fixt it . When you use Script Manipulator is beter to replace whole word - wait(50); -> re please with - wait(Delay_1);
    I use Notepad++ to replace words. I haven't had the time to learn how to use your Script Manipulator. I know other people find it useful. I will maybe look over it and ideas will pop in my head. Ideas about how to use it to it's max potential. In the end I stayed with CODE /CODE because it doesn't really matter right?

  38. #27
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by token View Post
    I use Notepad++ to replace words. I haven't had the time to learn how to use your Script Manipulator. I know other people find it useful. I will maybe look over it and ideas will pop in my head. Ideas about how to use it to it's max potential. In the end I stayed with CODE /CODE because it doesn't really matter right?
    I would appreciate if you try it and tell me what you think - what can improve it.

  39. #28
    GOLD NOVA IV

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    I have actually stopped using the specific identifiers for buttons/triggers (XB1_UP, PS3_UP etc) and now only use the data values. The code itself isn't that descriptive, but for general things like triggers, and sticks, very rarely do people change them up.

  40. #29
    Bulgaria's foremost expert on everything CM related!



    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Quote Originally Posted by EODCM View Post
    I have actually stopped using the specific identifiers for buttons/triggers (XB1_UP, PS3_UP etc) and now only use the data values. The code itself isn't that descriptive, but for general things like triggers, and sticks, very rarely do people change them up.
    Thanks for the inclusion in the discussion! Would you be so kind as to give some examples.

  41. #30
    GOLD NOVA IV

    User Info Menu

    Re: COMPLETE NOOBS GUIDE TO SCRIPTING???

    Check out the "Data Representation" page in the "GPC Language Reference". Notice the index column at the end. You'll understand it a bit better if you look at it after reading that page.

    So instead of this...which you have to change to XB360_LT, PS3_L2 etc etc.


    I use this...Same effect and no changing.

Page 1 of 4 1234 LastLast

Tags for this Topic

Posting Permissions

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