how exit commonevent ? in script ?

hi 


How exit commonevent with script ?


For call a commonevent the script is 


$gameTemp.reserveCommonEvent(n);


but for force to exit is what?


i try this 


$GameTemp.clearCommonEvent(n);


no work


tanks for help


my reason is this.
I need to force out if this variable are true
$gameVariables.value(2)==85;


My commonevent are


◆Régler Trajectoire Mouv.:Joueur
:                        :◇Attendre:5 trames
◆Commentaire:if click do this
◆Script:if ($gameVariables.value(2)==85) {
:      :$gameSwitches.setValue(19, false);
:      :$gameScreen.erasePicture(300);



$GameTemp.clearCommonEvent(n);
:      :}

◆Script:new IAVRA.ANIMATE.Tween($gameScreen.picture($gameVariables.value(2)), {_scaleX:130, _scaleY:130}).easing(IAVRA.EASING.quart.out).duration(3).chain
:      :( new IAVRA.ANIMATE.Tween($gameScreen.picture($gameVariables.value(2)), {_scaleX:100, _scaleY:100}).duration(7)).start();
◆Script:itemselected = $gameVariables.value(2)-99;
:      :var TempsXselected = $gameScreen.picture($gameVariables.value(2))._x;
:      :var TempsYselected = $gameScreen.picture($gameVariables.value(2))._y;
:      :$gameScreen.showPicture(300,  String(itemselected), 1, TouchInput.x, TouchInput.y, 100, 100, 50, 0);
◆Jouer SE:pop1 (90, 150, 0)
◆Contrôler les Interrupteurs:#0019 itemget = ON
If this is a common event, why are you doing all those things (in bold) as a script call?  Every one of them has an event command. 


Just use the event commands for Conditional Branch to check if variable 2 is 85.  If it is, use the event commands to set the switch, erase the picture, and Exit Event Processing.


Exit Event Processing will NOT work if the common event is set to parallel process or autorun, unless it's conditioned by switch 19.


Or you could just put a conditional branch around everything that happens after you want to exit, and only do it all if the variable is not 85.
@Shaz It's possible he is simply more comfortable with scripts than with events. But, to exit a common event, simply turn off the switch that activated it. 


As well, I'm going to go ahead and translate his event commands. 

Spoiler
◆Set Move Route:Player
:                        :◇Wait:5 frames
◆Comment:if click do this
◆Script:if ($gameVariables.value(2)==85) {
:      :$gameSwitches.setValue(19, false);
:      :$gameScreen.erasePicture(300);


$GameTemp.clearCommonEvent(n);
:      :}
◆Script:new IAVRA.ANIMATE.Tween($gameScreen.picture($gameVariables.value(2)), {_scaleX:130, _scaleY:130}).easing(IAVRA.EASING.quart.out).duration(3).chain
:      :( new IAVRA.ANIMATE.Tween($gameScreen.picture($gameVariables.value(2)), {_scaleX:100, _scaleY:100}).duration(7)).start();
◆Script:itemselected = $gameVariables.value(2)-99;
:      :var TempsXselected = $gameScreen.picture($gameVariables.value(2))._x;
:      :var TempsYselected = $gameScreen.picture($gameVariables.value(2))._y;
:      :$gameScreen.showPicture(300,  String(itemselected), 1, TouchInput.x, TouchInput.y, 100, 100, 50, 0);
◆Play SE:pop1 (90, 150, 0)
◆Control Switches:#0019 itemget = ON
@HexMozart88 except the code at the bottom IS an event.  He's got a common event that contains a script where every command in the script could be done with an event command.


Turning off the switch may not end it immediately.  It will stop it repeating, but it might run a few extra commands before it checks if it's meant to be active still.  Also, if it was triggered with a Call Common Event command, it won't be activated by a switch at all.
ok

If this is a common event, why are you doing all those things (in bold) as a scr.....................

i use it, but for this , i need script call, and conditional (IF).


And make spécifique IF in script.


I replace my code by this !


OLD

Régler Trajectoire Mouv.:Joueur
:                        :◇Attendre:5 trames
◆Commentaire:if click do this
◆Script:if ($gameVariables.value(2)==85) {
:      :$gameSwitches.setValue(19, false);
:      :$gameScreen.erasePicture(300);


$GameTemp.clearCommonEvent(n);
:      :}
◆Script:new IAVRA.ANIMATE.Tween($gameScreen.picture($gameVariables.value(2)), {_scaleX:130, _scaleY:130}).easing(IAVRA.EASING.quart.out).duration(3).chain
:      :( new IAVRA.ANIMATE.Tween($gameScreen.picture($gameVariables.value(2)), {_scaleX:100, _scaleY:100}).duration(7)).start();
◆Script:itemselected = $gameVariables.value(2)-99;
:      :var TempsXselected = $gameScreen.picture($gameVariables.value(2))._x;
:      :var TempsYselected = $gameScreen.picture($gameVariables.value(2))._y;
:      :$gameScreen.showPicture(300,  String(itemselected), 1, TouchInput.x, TouchInput.y, 100, 100, 50, 0);
◆Jouer SE:pop1 (90, 150, 0)
◆Contrôler les Interrupteurs:#0019 itemget = ON



NEW

◆Régler Trajectoire Mouv.:Joueur
:                        :◇Attendre:5 trames
◆Commentaire:if click and 
◆Si:Script:$gameVariables.value(2)==85
  ◆Script:$gameSwitches.setValue(19, false);
  :      :$gameScreen.erasePicture(300);
  ◆Sortir du Traitement de l'Év.
  ◆
:Fin
◆Script:new IAVRA.ANIMATE.Tween($gameScreen.picture($gameVariables.value(2)), {_scaleX:130, _scaleY:130}).easing(IAVRA.EASING.quart.out).duration(3).chain
:      :( new IAVRA.ANIMATE.Tween($gameScreen.picture($gameVariables.value(2)), {_scaleX:100, _scaleY:100}).duration(7)).start();
◆Script:itemselected = $gameVariables.value(2)-99;
:      :var TempsXselected = $gameScreen.picture($gameVariables.value(2))._x;
:      :var TempsYselected = $gameScreen.picture($gameVariables.value(2))._y;
:      :$gameScreen.showPicture(300,  String(itemselected), 1, TouchInput.x, TouchInput.y, 100, 100, 50, 0);
◆Jouer SE:pop1 (90, 150, 0)
◆Contrôler les Interrupteurs:#0019 itemget = ON







This is work but, i don't like this , how to call a function command like 


$GameTemp.clearCommonEvent(n);


but inside the script
You misunderstand what 'clear common event' does.  That is not the right command - it simply ensures there is no common event queued and ready to start when the map is shown.


Why do you need to do it inside a script call?

Code:
Conditional Branch: Variable 2 == 85
  Control Switches: 19 = false
  Script: $gameScreen.erasePicture(300)
  Exit Event Processing
End



You can do it using event commands that are already there.  By insisting on doing it all within a script call, you're just making it harder for yourself.
You misunderstand what 'clear common event' do............

@Shaz am noob in java but my full script are like this.


else if (command === 'itemmenue2') {

// generate and creat all array for menue item
GlobalItemPoss = []; // check all item poss, and create array for eatch
var k = 0; // eatch item poss found, get k++;
for (var i = 0; i <= $dataItems.length; i++) {
if ($gameParty.hasItem($dataItems)) {
GlobalItemPoss.push();
GlobalItemPoss[k] = [ i,$gameParty.numItems($dataItems), $dataItems.name,$dataItems.description,$dataItems.note,$dataItems.iconIndex];
k++;
}
}
//delete no usefull picture

// max item per par = 36 , and 3 line of 12 item per page
var PID = 100; // picture pid for all item per page start at 100 to 136.
var MaxIPerPage = 36;
Page = [];
Page[1] = GlobalItemPoss.slice(0,MaxIPerPage);
Page[2] = GlobalItemPoss.slice(MaxIPerPage,(MaxIPerPage*2));
Page[3] = GlobalItemPoss.slice((MaxIPerPage*2),(MaxIPerPage*3));
Page[4] = GlobalItemPoss.slice((MaxIPerPage*3),(MaxIPerPage*4));
var LinePage = 3;
var InItemX = 88; // Initial X of menue item list
var InItemy = 226; // Initial Y of menue item list
var MargeX = 7; // Marge bettwenn 2 picture X
var MargeY = 7; // Marge bettwenn 2 picture Y
var ItemsSizeX = 82; // X size of picture item , see folder rmmv
var ItemsSizeY = 82; // X size of picture

for (i=100; i < PID+GlobalItemPoss.length; i++) { // dellette all befor show all new one
$gameScreen.erasePicture(i);
}
for (i=0; i < Page[PageNumber].length; i++) {
if (i==12 || i==(12*2)) {
InItemX =88;
InItemy += (ItemsSizeY+MargeY);
LinePage+=3;
}
// show picture icon
$gameScreen.showPicture(PID, String(Page[PageNumber][0]), 1, InItemX, InItemy-ItemsSizeY, 100, 80, 150, 0);
new IAVRA.ANIMATE.Tween($gameScreen.picture(PID), {_y:InItemy, _scaleY:100,_opacity:255}).easing(IAVRA.EASING.bounce.out).duration(15).delay(i/2.5).start();
$gameScreen.setPictureCallCommon(PID, 94., 1); // lorsque click sur image prendra tous
// quantity possed
$gameScreen.setDTextPicture('\\OW[3] ' + Page[PageNumber][1] + ' ', 16);
$gameScreen.setFont('GameFont');
$gameScreen.dTextBackColor = 'rgba(0, 0, 0, 0.7)';
$gameScreen.showPicture(PID+Page[PageNumber].length, '', 1, InItemX+(ItemsSizeX/2.5), InItemy+(ItemsSizeY/2.5), 100, 100, 0, 0); // quantity possed
new IAVRA.ANIMATE.Tween($gameScreen.picture(PID+Page[PageNumber].length), {_opacity:255}).easing(IAVRA.EASING.cubic.inOut).duration(25).delay(2+(i/2)).start();
// show name
$gameScreen.setDTextPicture('\\OW[3] ' + Page[PageNumber][2] + ' ', 16);
$gameScreen.setFont('GameFont');
$gameScreen.dTextBackColor = 'rgba(0, 0, 0, 0.7)';
$gameScreen.showPicture(PID+(Page[PageNumber].length*2), '', 1, InItemX, InItemy-ItemsSizeY, 100, 100, 0, 0); // show name
new IAVRA.ANIMATE.Tween($gameScreen.picture(PID+(Page[PageNumber].length*2)), {_y:InItemy-(ItemsSizeY/2)+5, _opacity:255}).easing(IAVRA.EASING.cubic.inOut).duration(35).delay(55+(i*0.5)).start();

// show page status x/x
$gameScreen.setDTextPicture('\\OW[8]\\} PAGE \\{' + PageNumber + '/'+ (Page.length-1) + ' ', 48);
$gameScreen.setFont('GameFont');
$gameScreen.showPicture(89, '', 0, 125, 475, 100, 100, 255, 0); // show name
new IAVRA.ANIMATE.Tween($gameScreen.picture(89), {_y:475, _opacity:255}).easing(IAVRA.EASING.cubic.inOut).duration(10).delay(20).start();
// show total itemp for all page
$gameScreen.setDTextPicture('\\OW[5] TOTAL ITEM: ' + GlobalItemPoss.length + ' ', 23);
$gameScreen.setFont('GameFont');
$gameScreen.showPicture(90, '', 0, 125, 524, 100, 100, 255, 0); // show name
// show total itemp for all page
$gameScreen.setDTextPicture('\\OW[5] WEIGHT: ' + '1346/2467' + ' ', 23);
$gameScreen.setFont('GameFont');
$gameScreen.showPicture(91, '', 0, 125, 550, 100, 100, 255, 0); // show name

if () {

}
InItemX += (ItemsSizeX+MargeX);
PID++;
}

}




The reason of my reasoning 🙂.
but may be I wrong mistaken!
I just two months of training in javascript, I learned a lot with your forum.
I try my best but tank to help me


need to break: the commonEvent,  if he is true 


if true.this is


($gameVariables.value(2)==85)


need break common event executed.

Original thread: https://forums.rpgmakerweb.com/threads/how-exit-commonevent-in-script.69697/