MixelAnomaly Posted October 21, 2019 Share Posted October 21, 2019 (edited) Hi everyone, it's me again, this time i want to know how to use IF AND, and IF OR, since i am needing to make if i kill an enemy, X things happens, for example: the red cone disappears from his head, i was wondering if you could lend a hand with it, the IF OR i'm not sure i will use it, but it's better to be safe than sorry. Edited October 21, 2019 by MixelAnomaly Link to comment Share on other sites More sharing options...
ZAZ Posted October 21, 2019 Share Posted October 21, 2019 (edited) Writing scripts needs to use conditional checks to can decide when specified code should be executed It's like questions, for example: "Has user the Spacebar_key pressed?" "if yes, then show a text message" It often needs to specify the situation, so 2 or more conditons are needed, for example: "Is CJ driving a vehicle AND has user the Spacebar_key pressed?" "if yes, then show a text message" Or give more options, for example: "Has user the Spacebar_key OR Enter_key pressed?" "if yes, then show a text message" Below two example scripts First script checks if OR Either TAB_key or Backspace_Key needs to be pressed to can pass the conditional check {$CLEO .cs} :Akt thread 'AKT' :Akt_01 wait 0 if 0256: player $PLAYER_CHAR defined jf @Akt_01 if or 0AB0: key_pressed 8//-----------------key = Backspace 0AB0: key_pressed 9//-----------------key = TAB jf @Akt_01 08B2: toggle_thermal_vision 1 wait 3000 08B2: toggle_thermal_vision 0 jump @Akt_01 Second script checks if AND Both keys must be pressed, TAB_key and Backspace_Key together, to can pass the conditional check {$CLEO .cs} :Akt thread 'AKT' :Akt_01 wait 0 if 0256: player $PLAYER_CHAR defined jf @Akt_01 if and 0AB0: key_pressed 8//-----------------key = Backspace 0AB0: key_pressed 9//-----------------key = TAB jf @Akt_01 08B2: toggle_thermal_vision 1 wait 3000 08B2: toggle_thermal_vision 0 jump @Akt_01 Edited October 21, 2019 by ZAZ RestractPrime and OrionSR 2 CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
007Ripper Posted October 22, 2019 Share Posted October 22, 2019 (edited) I always have this in mind sir, what is the different between using "JF" and "Else_Jump" ? Is there any different ? And if we already used all "Local" variable, is there a way to not use "Global" variable instead ? I see some cleo script have a hundred "Local" variable like [email protected] or [email protected] etc. All that i know is we can use from [email protected] - [email protected] where [email protected] and [email protected] is for time thing. How is that possible ? Edited October 22, 2019 by 007Ripper Link to comment Share on other sites More sharing options...
ZAZ Posted October 22, 2019 Share Posted October 22, 2019 (edited) 10 hours ago, 007Ripper said: "JF" and "Else_Jump" ? Is there any different ? No, it have same meaning, but several different variation to write Quote And if we already used all "Local" variable, is there a way to not use "Global" variable instead ? I see some cleo script have a hundred "Local" variable like [email protected] or [email protected] etc. Mission scripts can have 1000 locals, [email protected] till [email protected] This requires a correct installation of mission scripts inside main.scm For Cleo it needs to write the directive {$CLEO .cm} at beginning to compile the script as *.cm The other normal scripts are limited to [email protected] and [email protected] and [email protected] is for timer Having not enough locals is mostly a fallacy of unadvanced coders, because you can really do a lot with 32 locals because a part of the locals are just needed temporary Example: the codes below should make explosions infront of CJ as well behind of CJ 04C4: create_coordinate 11@ 12@ 13@ from_actor $PLAYER_ACTOR offset 0.0 15.0 0.0 04C4: create_coordinate 21@ 22@ 23@ from_actor $PLAYER_ACTOR offset 0.0 -15.0 0.0 020C: create_explosion_with_radius 6 at 11@ 12@ 13@ 0565: create_temporary_explosion_fire 11@ 12@ 13@ 6 020C: create_explosion_with_radius 6 at 21@ 22@ 23@ 0565: create_temporary_explosion_fire 21@ 22@ 23@ 6 But it needs to use only [email protected] [email protected] [email protected] in following case 04C4: create_coordinate 11@ 12@ 13@ from_actor $PLAYER_ACTOR offset 0.0 15.0 0.0 020C: create_explosion_with_radius 6 at 11@ 12@ 13@ 0565: create_temporary_explosion_fire 11@ 12@ 13@ 6 04C4: create_coordinate 11@ 12@ 13@ from_actor $PLAYER_ACTOR offset 0.0 -15.0 0.0 020C: create_explosion_with_radius 6 at 11@ 12@ 13@ 0565: create_temporary_explosion_fire 11@ 12@ 13@ 6 After first explosion, the coords locals [email protected] [email protected] [email protected] aren't needed anymore and [email protected] [email protected] [email protected] can be used again with new content If still not enough locals, there're some other methods 1. opcode 0AB1: call_scm_func @subscript [email protected] [email protected] [email protected] [email protected] (with cleo only) This code leads the reading process to a subscript or code block that have it's own scope This code allows to attach up to 32 parameter to can send as well receive data 2. starting a thread code for cleo: 0A92: create_custom_thread "MultiThread.cs" 1 2 3 4 code for main.scm: 004F: create_thread @AUDIOL [email protected] 0 1 1 0 This code allows to attach up to 32 parameter to can send data With create_thread is it possible to initialize the same script again, more times You can run same script in maybe hundred instances, started from same script that will be started again 3. Thread Memory (with cleo only) I never did it but read the posts of kosticn101 Edited October 22, 2019 by ZAZ CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
007Ripper Posted October 22, 2019 Share Posted October 22, 2019 Wow, it really open my mind i always make different locals for coordinat only what a waste. I have many things to ask but, thats it for now. Things that i like from cleo scripting is, we can do everything we want like adding powers etc, the only limit is our imagination. More wise today, Thank you sir. Link to comment Share on other sites More sharing options...
MixelAnomaly Posted October 23, 2019 Author Share Posted October 23, 2019 Thanks you bro! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now