my pluginCommand dont get args[0] why ???

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
hi guys


I have error undefined in my plugin


When i use this script in Rmmv CommontEvent for call command plugin


// command, args
this.pluginCommand('GenerateMenueItem', PageNumber);


The plugin work and he calling the commandPlugin GenerateMenueItem, but he dont get the , args[0] ?


The args[0], get undefined ?


Why my variable after the 'GenerateMenueItem', dont give the value to args[0] ?


So i try console.log just before. to see if the var have a valur


console.log('pagenumber= ' + PageNumber);
this.pluginCommand('GenerateMenueItem', PageNumber);


and PageNumber==2 ,so this is ok, but after in the plugin called its became undefined.


my syntaxe for call plugin command are ok ???


If this can help here where my args are calling. is at line 45

Code:
1: (function() { //1
2:         var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
3:         Game_Interpreter.prototype.pluginCommand = function(command, args) { //2
4:                 // to be overridden by plugins
5:                 _Game_Interpreter_pluginCommand.call(this, command, args);
6:                 // lorsque appelle pluginCommand, vous pouvez ajouté des arguments ex: menuetext reste 4 (command, var1, var2)
7:                 var Arg1Plugincommand = args[0];
8:                 var Arg2Plugincommand = args[1];
9:                 //##################################################### GenerateMenueItem #####################################################|
10:                 if (command == 'GenerateMenueItem') {//1
11: 				    GlobalItemPoss = []; // initialise arrays
12:                     var PID = 100; // picture pid for all item per page start at 100 to 136. 
13:                     var MaxIPerPage = 36; // max item per par = 36 , and (3 line x 12 items) per page
14: 					var LinePage = 3; // nombre ligne par page
15:                     var InItemX = 88; // Initial X of menue item list
16:                     var InItemy = 226; // Initial Y of menue item list
17:                     var MargeX = 7; // Marge bettwenn 2 picture X
18:                     var MargeY = 7; // Marge bettwenn 2 picture Y
19:                     var ItemsSizeX = 82; // X size of picture item , see folder rmmv
20:                     var ItemsSizeY = 82; // X size of picture
21:                     Page = [];
22: 					console.log('Arg1Plugincommand= ' + args[0]);
23: 					PageNumber=Arg1Plugincommand;
24: 					console.log('pagenumber= ' + PageNumber);
25:                     // generate and create all array for menue item
26: 					// check all item poss, and create array for eatch
27:                     for (var i = 0; i <= $dataItems.length; i++) { //352 scan tout le database item 
28:                         if ($gameParty.hasItem($dataItems[i])) {
29:                             GlobalItemPoss.push(i); // si posed item, ajoute item id dans array GlobalItemPoss
30:                         } 
31:                     } //352
32: 					
33:                     
34: 					// Distribu les items a chaque page. 36 item par page
35: 					var k = Math.ceil(GlobalItemPoss.length / MaxIPerPage); // Math.ceil() arrondi les virguls au plus proche toujours Superieur (1.13=2) ( a cause de la division)
36: 					for (i = 1; i <= k; i++) { //5
37:                         Page[i] = GlobalItemPoss.slice(MaxIPerPage * (i - 1), (MaxIPerPage * i)); //page.length a toujours min 2 comme valeur, donc Page.length-1 ( car aussi jai choisi de utilise page[1] par default au lieux de page[0])
38:                     } //5
39: 
40: 
41:                     for (i = 100; i <= PID + (MaxIPerPage * 3); i++) { //7 dellette all befor show all new one (*3 a verifier)
42:                         $gameScreen.erasePicture(i);
43:                     } //7
44:                     // affiche les icons items   ( PageNumber est defeni dans event commun dans callcommand [GenerateMenueItem, args1]
45: 					for (i = 0; i < Page[PageNumber].length; i++) { //88
46: 					//si == 12 ou 24, on doit sauté une ligne pour affiché les items
47:                         if (i == 12 || i == (12 * 2)) {
48:                             InItemX = 88;
49:                             InItemy += (ItemsSizeY + MargeY);
50:                             LinePage += 3;
51:                         }
52:                         var TempID = Page[PageNumber][i]; // contien items dans la page actuelle (36 max)
53:                         // show picture item icon
54:                         $gameScreen.showPicture(PID, String(TempID), 1, InItemX, InItemy - ItemsSizeY, 100, 80, 150, 0);
55:                         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();
56:                         $gameScreen.setPictureCallCommon(PID, 94, 1); // lorsque click sur image prendra tous
57:                         // show quantity possed
58:                         $gameScreen.setDTextPicture('\\OW[3] ' + $gameParty.numItems($dataItems[TempID]) + ' ', 16);
59:                         $gameScreen.setFont('GameFont');
60:                         $gameScreen.dTextBackColor = 'rgba(0, 0, 0, 0.7)';
61:                         $gameScreen.showPicture(PID + Page[PageNumber].length, '', 1, InItemX + (ItemsSizeX / 2.5), InItemy + (ItemsSizeY / 2.5), 100, 100, 0, 0); // quantity possed
62:                         new IAVRA.ANIMATE.Tween($gameScreen.picture(PID + Page[PageNumber].length), { _opacity: 255 }).easing(IAVRA.EASING.cubic.inOut).duration(25).delay(2 + (i / 2)).start();
63:                         // show name of item
64:                         $gameScreen.setDTextPicture('\\OW[3] ' + $dataItems[TempID].name + ' ', 16);
65:                         $gameScreen.setFont('GameFont');
66:                         $gameScreen.dTextBackColor = 'rgba(0, 0, 0, 0.7)';
67:                         $gameScreen.showPicture(PID + (Page[PageNumber].length * 2), '', 1, InItemX, InItemy - ItemsSizeY, 100, 100, 0, 0); // show name
68:                         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();
69: 						// show page status x/x
70:                         $gameScreen.setDTextPicture('\\OW[8]\\} PAGE \\{' + PageNumber + '/' + (Page.length - 1) + ' ', 48);
71:                         $gameScreen.setFont('GameFont');
72:                         $gameScreen.showPicture(89, '', 0, 125, 475, 100, 100, 255, 0); // show name
73:                         new IAVRA.ANIMATE.Tween($gameScreen.picture(89), { _y: 475,_opacity: 255 }).easing(IAVRA.EASING.cubic.inOut).duration(10).delay(20).start();
74: 						// Si ces les premier foi ont initialise aussi les info fictif. ( grace a args[1]) dans le plugin call
75: 						if (Arg2Plugincommand=='initialise'){
76:                         // show total itemp for all page
77:                         $gameScreen.setDTextPicture('\\OW[5] TOTAL ITEM: ' + GlobalItemPoss.length + ' ', 23);
78:                         $gameScreen.setFont('GameFont');
79:                         $gameScreen.showPicture(90, '', 0, 125, 524, 100, 100, 255, 0);
80:                         // show WEIGHT total for all item
81:                         $gameScreen.setDTextPicture('\\OW[5] WEIGHT: ' + '1346/2467' + ' ', 23);
82:                         $gameScreen.setFont('GameFont');
83:                         $gameScreen.showPicture(91, '', 0, 125, 550, 100, 100, 255, 0);
84:                         var DistanceXforfilter = 95;
85:                         var DistanceYforfilter = 45;
86:                         // show filter for ALL
87:                         $gameScreen.setDTextPicture('\\OW[8] ALL ', 35);
88:                         $gameScreen.setFont('GameFont');
89:                         $gameScreen.showPicture(92, '', 0, 290, 490, 100, 100, 255, 0);
90:                         // show filter for dice
91:                         $gameScreen.setDTextPicture('\\OW[8] DICE ', 35);
92:                         $gameScreen.setFont('GameFont');
93:                         $gameScreen.showPicture(93, '', 0, 290 + DistanceXforfilter, 490, 100, 100, 255, 0);
94:                         // show filter for mask
95:                         $gameScreen.setDTextPicture('\\OW[8] MASK ', 35);
96:                         $gameScreen.setFont('GameFont');
97:                         $gameScreen.showPicture(94, '', 0, 290 + (DistanceXforfilter * 2), 490, 100, 100, 255, 0);
98:                         // show filter for quest
99:                         $gameScreen.setDTextPicture('\\OW[8] QUEST ', 35);
100:                         $gameScreen.setFont('GameFont');
101:                         $gameScreen.showPicture(95, '', 0, 290 + (DistanceXforfilter * 3), 490, 100, 100, 255, 0);
102:                         // show filter for seed ----------+ y line
103:                         $gameScreen.setDTextPicture('\\OW[8] SEED ', 35);
104:                         $gameScreen.setFont('GameFont');
105:                         $gameScreen.showPicture(96, '', 0, 290, 490 + DistanceYforfilter, 100, 100, 255, 0);
106:                         // show filter for build
107:                         $gameScreen.setDTextPicture('\\OW[8] BUILD ', 35);
108:                         $gameScreen.setFont('GameFont');
109:                         $gameScreen.showPicture(97, '', 0, 290 + DistanceXforfilter, 490 + DistanceYforfilter, 100, 100, 255, 0);
110:                         // show filter for FOOD
111:                         $gameScreen.setDTextPicture('\\OW[8] FOOD ', 35);
112:                         $gameScreen.setFont('GameFont');
113:                         $gameScreen.showPicture(98, '', 0, 290 + (DistanceXforfilter * 2), 490 + DistanceYforfilter, 100, 100, 255, 0);
114:                         // show filter for POWER
115:                         $gameScreen.setDTextPicture('\\OW[8] POWER ', 35);
116:                         $gameScreen.setFont('GameFont');
117:                         $gameScreen.showPicture(99, '', 0, 290 + (DistanceXforfilter * 3), 490 + DistanceYforfilter, 100, 100, 255, 0);
118: 						}
119:                         InItemX += (ItemsSizeX + MargeX);
120:                         PID++;
121:                     } //88
122: 
123:                 } //1
124:                 
125:                 //=============================================================================
126:                 // end Game_Interpreter 
127:                 //=============================================================================
128:             } //2;
129:             //=============================================================================
130:             // end Game_Interpreter 
131:             //=============================================================================
132:     } //1
133: )();
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
because you're calling the pluginCommand function directly and giving a number for the value of args. Args is an array, not a number. Make it an array and you should be fine, because otherwise you're trying to get index 0 of a number, and that's not defined.
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
because you're calling the pluginCommand function directly and giving a number for the value of args. Args is an array, not a number. Make it an array and you should be fine, because otherwise you're trying to get index 0 of a number, and that's not defined.


Tank you friend.


So this is work now with.

Code:
this.pluginCommand('GenerateMenueItem', [PageNumber]);
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top