PDA

View Full Version : Couple of basic Q's before I start :)



KS212
7th May 17, 05:28
Hi all, new user of the product here looking to get started with scripting. I just have a couple of questions that don't seem to fly around a lot:

1) How is playback handled? Is it 'press button once to play entire script from start to finish' or 'hold button to play script'? If its the former, how do you STOP playback midway?(in case you miss, you don't want to be punching air and hung out to dry).

2) All the script samples I've seen are using 1 button to activate, is it possible to do multiple buttons such as 'hold R1 and press <face button>'? That will give you more keybinds basically as then one script can have say, hold R1 and press <face button> for 4 different combos, then hold R2 for another 4, etc. Is this possible or are we limited to 1 button per?

3) Direction, is there a way to script in 'direction handling' for facing left vs facing right (ie if you press the combo button, it will play as if facing left, but if you press the combo button + left it will flip the script to play as if facing right). Is something like this possible or do we simply have to duplicate the script for facing left vs facing right respectively?

That's pretty much all I'd need to know for now, thanks in advance.

Swizzy
7th May 17, 09:31
1. Scripts execute the main block over and over (every 10ms), you use combo blocks to define macros, these can be started using combo_run, stopped with combo_stop, the trigger is completely up to you, you can use almost any condition to trigger it...

2. Read above, advanced options are available, in the manual you'll find most of this, if statements can have multiple conditions... like if (get_val(PS4_R1) && get_val(PS4_CROSS)) { combo_run(cmb); } would run the combo named "cmb" on a loop as long as you hold R1 and X together, it will continue after you let go of the buttons until it has reached the end of the combo...

3. Sure, you can use variables for that, these are named values that can change during runtime... (defined using "int name;" or "int name = defaultValue;"

Here are some of the more important manual pages you should read, in regards to scripting:

http://cronusmax.com/manual/variables.htm <--- How to define/use variables

http://cronusmax.com/manual/main_section.htm <--- How the main function works

http://cronusmax.com/manual/combo_section.htm <--- How combos/macros work

http://cronusmax.com/manual/flow_control_commands.htm <--- How if etc. works

KS212
7th May 17, 19:47
Excellent resources, thanks! However, the manuals don't give me an example for what I'm after so I'll just ask a direct question:

Would the below work? The idea is to check if both R1 and a face button is pressed:

main {
if (event_press(PS4_R1)) && (event_press(PS4_SQUARE)) {
combo_run(mycomboA)
}
if (event_press(PS4_R1)) && (event_press(PS4_CIRCLE)) {
combo_run(mycomboB)
}

<rest of script here>

Your example is using get_val instead of event_press, what's the difference?

There are no examples in the manuals for checking for two buttons simultaneously except for where I have to define a variable (ie 'int press_R1;') and do a full check loop at the start for if that button is pressed... Please don't say I HAVE to do it that way... x.x

Swizzy
8th May 17, 00:55
get_val gets the current value, event_press returns 1 if the button just changed into a "pressed" state otherwise 0...

That code wouldn't compile as you don't match up the parenthesis, the if keyword needs it's condition wrapped within a set of parenthesis where as you've merely done that on each function call (totally useless btw)

If you read the information on flow control, you'll understand how to make multiple checks, it should have the explanations of &&, || and ^^ as to what they do... && = and - meaning both conditions on either side of the && should return true, || = or - meaning the condition on either side must be true, ^^ = xor or exclusive or - meaning only one of the conditions on either side must be true

All of these things above are basics, get_val/event_press aren't "common" but, how flow control works is exactly the same as any other programming/scripting language

KS212
8th May 17, 02:17
I am NOT a programmer/coder, I tried learning and AM MASSIV SUCK at it :( Though that flow control bit had what I wanted but I'm trying to understand how it would be written as code...

Can you please provide an example of how code would look if I wanted to have say PS4_R1 as a modifier button, ie if (or while?) R1 was pressed, check for PS4_SQUARE, TRIANGLE, CIRCLE or CROSS and then go to the relevant combo section. If R1 is let go = stop combo?

Maybe I'm trying to do too much at once but if I have a sample to work off of I'd probably be able to get somewhere.

Swizzy
8th May 17, 07:35
I am NOT a programmer/coder, I tried learning and AM MASSIV SUCK at it :( Though that flow control bit had what I wanted but I'm trying to understand how it would be written as code...

Can you please provide an example of how code would look if I wanted to have say PS4_R1 as a modifier button, ie if (or while?) R1 was pressed, check for PS4_SQUARE, TRIANGLE, CIRCLE or CROSS and then go to the relevant combo section. If R1 is let go = stop combo?

Maybe I'm trying to do too much at once but if I have a sample to work off of I'd probably be able to get somewhere.

Read the answer to 2. in this post: http://cronusmax.com/forums/showthread.php/172290-Couple-of-basic-Q-s-before-I-start-%29?p=1069936&viewfull=1#post1069936 i have an example there, just missing the main block and combo that it actually runs...