Item Select Command

Guys

I am trying to use select item command and compare these 2 items using meta value (for example,, assigned as Value : 1)

after select item $gameMessage.setItemChoice(1, 1).

did the variable store anywhere from this script ? if not how can I store whatever selected item into new variable.

new variable = $gameMessage.setItemChoice(1, 1);

after that I can just compare variables
@Charles2020 I split your post into its own thread. In the future, please start a new thread with your question. Thanks.
Are you doing this via script or using event commands? The event command Select Item lets you specify what variable is going to contain the item number. Just do that twice, using different variables, followed by a conditional branch to see if the two variables are equal.
Hi @Shaz

I used command but it does not add up. Is there a syntax error below ?


Select item 1 ### assigned Value 1

Select item 2 ### assigned Value 2

If $dataItems[1].meta.Value <= $dataItems[2].meta.Value, do xxx
Please show a screenshot of what you're trying to do, as well as screenshots of the items.

I know what you're doing wrong, but I can only show you the correct way if I actually see what you've got, otherwise I'll give you a roundabout way and you'll make mistakes trying to implement it.
see the attached. This is kind of math puzzles I am playing around.

I tried to manipulate both dataitem ($dataItems[1].meta.Value) and variables ($gameVariables.value(1))

I think something wrong with my equation syntax here

$gameVariables.value(3) = $gameVariables.value(1) + $gameVariables.value(2);

$gameVariables.value(4) > 1;

Please advice
Please show a screenshot of what you're trying to do, as well as screenshots of the items.

I know what you're doing wrong, but I can only show you the correct way if I actually see what you've got, otherwise I'll give you a roundabout way and you'll make mistakes trying to implement it.
see the attached. This is kind of math puzzles I am playing around.

I tried to manipulate both dataitem ($dataItems[1].meta.Value) and variables ($gameVariables.value(1))

I think something wrong with my equation syntax here

$gameVariables.value(3) = $gameVariables.value(1) + $gameVariables.value(2);

$gameVariables.value(4) > 1;

Please advice
Why are you doing additions and subtractions on variable ids?

And where is the reference to the meta?

Can you explain, from the player's point of view, what you are trying to do here? What are the items (please give screenshots of your item settings so I can see the meta), and why does the player want to select them? What happens?
Why are you doing additions and subtractions on variable ids?

And where is the reference to the meta?

Can you explain, from the player's point of view, what you are trying to do here? What are the items (please give screenshots of your item settings so I can see the meta), and why does the player want to select them? What happens?

I tried to create math puzzle system.

Initially I assigned Value to items but you mentioned earlier that The event command Select Item lets you specify what variable is going to contain the item number. so I assumed that The event command Select Item would automatically assign meta value of items into selected variables.

If that is the case, so I just compare and do math using variables in stead of $dataItems[X].meta.Value

Please correct me if I am wrong
The Select Item command places the item id into the variable.

Sorry - I meant to say item ids, not variable ids. Why are you doing math using item ids?

I cannot correct you if you don't tell me what you are trying to achieve.

Can you explain, from the player's point of view, what you are trying to do here? What are the items (please give screenshots of your item settings so I can see the meta), and why does the player want to select them? What happens?
The Select Item command places the item id into the variable.

Sorry - I meant to say item ids, not variable ids. Why are you doing math using item ids?

Is there a way to place meta value into variable by select item command or some script after select item command ?

Because if select item command place item ID, there is nothing to do with meta value in item

Is there a way to place meta value into variable by select item command or some script after select item command ?

Because if select item command place item ID, there is nothing to do with meta value in item

Maybe something along this line ?

$gameMessage.setItemChoice.meta.Value (1, 1);

The Select Item command places the item id into the variable.

Sorry - I meant to say item ids, not variable ids. Why are you doing math using item ids?

I cannot correct you if you don't tell me what you are trying to achieve.

Maybe something along this line ?

$gameMessage.setItemChoice.meta.Value (1, 1);

I think it is feasible to create a short code plugin by modifying from

Code:
Game_Message.prototype.setItemChoice = function(variableId, itemType) {
    this._itemChoiceVariableId = variableId;
    this._itemChoiceItypeId = itemType;
};

to something like

Code:
Game_Message.prototype.setItemChoice = function(variableId, itemType, meta_Value) {
    this._itemChoiceVariableId = variableId;
    this._itemChoiceVariableId.meta.Value = variableId.meta.Value;
    this._itemChoiceItypeId = itemType;
};

The problem is I dont know how to call meta value in JS

Waiting for someone to shed light on this issue
You don't need to modify any code. I am still waiting for you to explain what exactly you are trying to achieve, and show me screenshots of your items. Then I can give you EXACTLY what you need to put.

Can you explain, from the player's point of view, what you are trying to do here? What are the items (please give screenshots of your item settings so I can see the meta), and why does the player want to select them? What happens?

Charles2020, please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.


I've merged your posts together.
Let's say you have the following note on your items:
<mynum:5>

and you use a Select Item command, placing the item id into variable 15.

You could get mynum from the selected item with the following script:

$dataItems[$gameVariables.value(15)].meta.mynum

Note that there should be no space between the : and the 5 (otherwise you'd have to trim it to be able to use it).

But again, because you won't tell me what you're actually trying to achieve here, and won't give me the screenshots I have requested several times, that is the best I can give to you, and hopefully you will be able to figure out how to turn that into something you can actually use, without making mistakes.
Let's say you have the following note on your items:
<mynum:5>

and you use a Select Item command, placing the item id into variable 15.

You could get mynum from the selected item with the following script:

$dataItems[$gameVariables.value(15)].meta.mynum

Note that there should be no space between the : and the 5 (otherwise you'd have to trim it to be able to use it).

But again, because you won't tell me what you're actually trying to achieve here, and won't give me the screenshots I have requested several times, that is the best I can give to you, and hopefully you will be able to figure out how to turn that into something you can actually use, without making mistakes.

Hi yes sorry for not being clear. I am essentially trying to implement numeric values in items and use simple math to manipulate items as a puzzle. Put in simple is that I want to perform math for items using simple math. Does it make sense ?

For example, I wanted to assign value (should numerical in order to do math late) into item (see attached)

Then I wanted to either compare, add, substract into new variables or under if condition

Here what I did
I assigned <mynum:5> into item 1
I assigned <mynum:3> into item 2

Then I wanted to use if condition to use simple math (+) and if condition
For example, first, if item 1 value + item 2 value > 10, do xxx
I used the following codes

If $dataItems[$gameVariables.value(1)].meta.mynum + $dataItems[$gameVariables.value(2)].meta.mynum > 10;

second, if item 1 value < item 2 value, do XXX
I used the following codes

If $dataItems[$gameVariables.value(1)].meta.mynum < $dataItems[$gameVariables.value(2)].meta.mynum;

Third, create new item using script or new variables using script and then use simple math (+) and if condition

$dataItems[$gameVariables.value(10)].meta.mynum= $dataItems[$gameVariables.value(1)].meta.mynum + $dataItems[$gameVariables.value(2)].meta.mynum;
Did it work?

If not, try doing this before the conditional branch:

Control Variables 3 = Script: $dataItems[$gameVariables.value(1)].meta.mynum
Control Variables 4 = Script: $dataItems[$gameVariables.value(2)].meta.mynum
Show Text: Var 3 is \v[3]
Var 4 is \v[4]

That will show you if it's getting the meta correctly.

I am assuming you selected variable 1 and variable 2 in your two Select Item commands.
Did it work?

If not, try doing this before the conditional branch:

Control Variables 3 = Script: $dataItems[$gameVariables.value(1)].meta.mynum
Control Variables 4 = Script: $dataItems[$gameVariables.value(2)].meta.mynum
Show Text: Var 3 is \v[3]
Var 4 is \v[4]

That will show you if it's getting the meta correctly.

I am assuming you selected variable 1 and variable 2 in your two Select Item commands.

Actually, after checking with
Show Text:
Var 3 is \v[3]
Var 4 is \v[4]

The value of variables 3 and 4 are correct now. But the math part is incorrect.

For example I tried to use either
If $gameVariables.value(3) + $gameVariables.value(4) == 5, do XXX

If $gameVariables.value(3) + $gameVariables.value(4) = 5, do XXX

both of them are wrong
The first one should work.

== is comparison
= is assignment

Try Number($dataItems[$gameVariables.value(1)].meta.mynum) in case it doesn't recognize they're numbers.
The first one should work.

== is comparison
= is assignment

Try Number($dataItems[$gameVariables.value(1)].meta.mynum) in case it doesn't recognize they're numbers.

Oh I see. I created new variable (Var 5) and checked in text.

So basically
$gameVariables.value(3) + $gameVariables.value(4)
mean attach 2 string/integer together

It turned out my new var = 34, so + syntax is invalid

Is there a way to operator math function for variable using +, - in JS
The first one should work.

== is comparison
= is assignment

Try Number($dataItems[$gameVariables.value(1)].meta.mynum) in case it doesn't recognize they're numbers.

When I tried

$dataItems[$gameVariables.value(1)].meta.mynum + $dataItems[$gameVariables.value(2)].meta.mynum

It turned out my new var = 0

something wrong with math syntax

Original thread: https://forums.rpgmakerweb.com/threads/item-select-command.125751/