list itemid inside an array

Status
Not open for further replies.

Xyonel

Indie Developer, All-in-one artist.
Veteran
Joined
Jul 22, 2018
Messages
155
Reaction score
29
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
667
Reaction score
197
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
155
Reaction score
29
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,161
Reaction score
7,808
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

Hey people! What do you think about a core plugin? This will save some lines of code that I repeatedly use in all my plugins...
Wondering if I should make my enemies scale in my non-linear rpg. I'm leaning towards yes, but I don't want to use Yanfly's plugin...
French folk trying to pronounce English words. I loved how the man pronounced squirrel as 'square friend'.
Therapist: any questions? Me: Yeah, are there actually people who think Hotel California is about drugs and not fame or are people just trying to upset me?
Therapist: They WHAT?
It's interesting. There are no safety hazards in our country, but if you look at the shelves in supermarkets, you'd say there's a zombie apocalypse here.

Forum statistics

Threads
94,592
Messages
922,142
Members
124,461
Latest member
ppkvvet
Top