list itemid inside an array

Status
Not open for further replies.

Xyonel

Indie Developer, All-in-one artist.
Veteran
Joined
Jul 22, 2018
Messages
140
Reaction score
28
First Language
Italian
Primarily Uses
RMMV
someone know how to insert ids of a list( item1, item2 item3) inside an array? not a simple text but cards id( in this case) previously created inside an array that I will configure as an album, I only need this tips, how to recall inside the array a variable ( i think)

otherwise I must insert manually the card ids.
Or I'm wrong?
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
583
Reaction score
150
First Language
Javascript
Primarily Uses
RMMV
someone know how to insert ids of a list( item1, item2 item3) inside an array? not a simple text but cards id( in this case) previously created inside an array that I will configure as an album, I only need this tips, how to recall inside the array a variable ( i think)

otherwise I must insert manually the card ids.
Or I'm wrong?
Mostly involving a "for" Loop Statement with the Array "splice()" Method.

Anyways... just wrote a plugin for this. See below :)

CT_Bolt's InsertValues Plugin:
Description:
Insert object values from an array of objects into an array.

Features:
Insert object values from an array of objects into an array.
Insert object value(s) to anywhere the array.
Insert any value from anywhere to any stopping point in object array.

How to Use:
Add plugin via Plugin Manager

Script Calls:
Code:
  insertValues(array, object, [insertAt], [objectValue], [insertFrom], [insertStop]);
  array.insertValues(object, [insertAt], [objectValue], [insertFrom], [insertStop]);
Note: Only "array", "object" are needed.
Optional Values Default to the following:
insertAt: 0
objectValue: "id"
insertFrom: 0
insertStop: Array Length Of Object Array

Examples:
Code:
  insertValues([4, 5, 6, 7, 8], [{id:1},{id:2},{id:3}], 2, "id", 1, 2);
    Before: [4, 5, 6, 7, 8]
    After:  [4, 5, 6, 2, 7, 8]
Code:
[4,5,6,7,8].insertValues([{id:1},{id:2},{id:3}], 2);
     Before: [4, 5, 6, 7, 8]
     After:  [4, 5, 1, 2, 3, 6, 7, 8]
Code:
  [4,5,6,7,8].insertValues([{id:1},{id:2},{id:3}]);
    Before: [4, 5, 6, 7, 8]
    After:  [1, 2, 3, 4, 5, 6, 7, 8]


Download:

So for your case something like this...
Code:
var cardId_list = [];
var cards = [{id:1, value: 5}, {id:3, value: 15}, {id:2, value: 10}, {id:4, value: 20}];
Code:
cardId_list.insertValues(cards); // Inserts all card IDs into the array at the beginning.
or
Code:
cardId_list.insertValues(cards,cardId_list.length); // Inserts all card IDs into the array at the end.

Is that what you needed? ...Hope that's what you meant. :cutesmile:

Let me know how it goes :):popcorn:
 
Last edited:

Xyonel

Indie Developer, All-in-one artist.
Veteran
Joined
Jul 22, 2018
Messages
140
Reaction score
28
First Language
Italian
Primarily Uses
RMMV
the cards have different values, not only one, it's a triple triad plugin made by raizen, I must insert these cards in album in row and columns and I do not know how to do, have you some tips?
at mouse click or keyboard selection, the cards chosen show a little info window at the right, I can do almost all about this, but i'm stuck with that kind of command list with more columns.
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
14,065
Reaction score
7,756
First Language
English
Primarily Uses
RMMV

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

"Got your game? Cause its time to duel!"

I'm so into YuGiOh these days...
(And of course the hand is awful)
Been working on this new character for the battle system It's BOSS time!
Happy Year of the Rat all! Wish everyone can achieve their dream this year
Please support my Lego Ideas Untitled Goose Game set, thanks in advance :) https://ideas.lego.com/projects/2bcb743a-1071-4f44-89f4-97ad6ec27b5d
Here we are....REMIND is out and what am I doing?
Still Playing Kingdom Hearts 3.....

Forum statistics

Threads
93,585
Messages
913,711
Members
123,127
Latest member
Bonesaw577
Top