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
653
Reaction score
188
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,145
Reaction score
7,801
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 Profile Posts

Coffee + Silk Coconut Milk + Splenda Zero = Not ..... awful :/ .
My new RPG Maker music pack, Emotional: Redemption, is now in progress and will be coming to RPG Maker soon. It is an album that focuses on emotional themes including the darker forms of sorrow and despair. Below is a demo of a composition from the album.

Please watch out for your hands when handling chests! XD Did this a few days ago, it was fun to animate

Apparently, it's illegal to be drunk on licensed premises: pubs, etc. It's illegal for keepers of public houses to permit drunkenness and disorderly conduct. lol.
Pillow Hero - A 16-bit arcade styled puzzle game, update 0.5 is live now on Itch.io! --> https://bifrost09.itch.io/pillow-hero

Forum statistics

Threads
94,436
Messages
920,904
Members
124,241
Latest member
toanbeokame
Top