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,149
Reaction score
7,802
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

I was doing forge runs on D2 with my wife last night, and singing like a leprechaun to annoy her XD. I was calling it 'The Farge'
Is i possible too make a weapon have a chance of using a skill?
Can the Eternal Dreamers finish off the final boss? We'll see!
Fekken kill me. I unknowingly swapped out two important events's codes and saved the game to test it. I'm just doing this for fun and the fun has now been replaced with excruciating torture.
Is this how game developers feel all the time?

EDIT:
WAIT HOLY S***
MY LAST POST ASKING FOR HELP ON AN EVENT ACTUALLY SAVED IT
OH MY GOD
Coffee + Silk Coconut Milk + Splenda Zero = Not ..... awful :/ .

Forum statistics

Threads
94,448
Messages
921,010
Members
124,272
Latest member
lymeish
Top