Script Call Equivalent of Events

Oh, sorry. This is a screenshot:

rOSBUWi.png


I'm getting exactly the same error in a new project as well.

Here is the event:

7qgjqdE.png
Yep, it's not saying equips is undefined - it's saying @actor is a nil class. And it makes sense. @actor is just a placeholder which means "define your actor here". @actor has no meaning in a script call unless you actually define it. How are you deciding which actor to use? Is it the leader? Is it a certain party member? Is it someone in a certain position in the party?
Oh, I see. So what would I replace @actor with to select the nth party member?
Yes, but do you know how to define the nth party member in a script?


Is it a particular actor, or someone in a particular position in the lineup, or the leader? WHO do you want to check?
I think maybe you read my question wrong.

How do I select the nth party member?

As in, how do I select the actor in party position n?

e.g. if n = 0, then it selects the leader.
$game_party.members[n]


So the above would become:


$game_variables[3] = $game_party.members[n].equips[4].id


where n is the position of the actor you want to know about.


If it's the leader, then it gets easier than that:


$game_variables[3] = $game_party.leader.equips[4].id
$game_variables[3] = $game_party.members[n].equips[4].id

gives me exactly the same error message as before, and

$game_variables[3] = $game_party.leader.equips[4].id 

gives me the same error unless actor 1 is the party leader.

The event is laid out the same as before except for the change in script call.
You didn't actually USE $game_party.members[n].equips[4].id, did you? n is where you're supposed to put a number. Remember it starts at 0. So the second person in your party will be $game_party.members[1], not $game_party.members[2].


If you continue having problems, please actually show us EXACTLY what you typed into the script, and the EXACT error message you received.
I double checked in case I did accidentally leave n in.

Here is the event's layout (everything is word-for-word except for the n part)

gxWqHCo.png


I substituted n in for 0, 1, 2, 3 and 4 (I tested with party consisting of 4 members, in a new project with those script snippets you supplied before in the correct location.)

When n = 0, 2 and 3, The dialogue box read "Mithril Mace" (but no one had this weapon equipped) which is the 46th weapon in the database (I thought this might have something to do with the fact I was using the 47th variable, but changing the variable had no effect). 

when n = 1, I got this error:

5WBugTt.png


When n = 4, I got this error (presumably because I had four party members and, as the list started at 0, n = 4 would be trying to access a non-existent fifth party member.)

rGj29lh.png
I think this the wrong topic to ask this, I'll clean up this thread and make a new one later. The original purpose of this thread has disappeared XD
Arrays in ruby start at 0, not 1.


If your party has 4 members, they are 0, 1, 2 and 3. 4 will give you an error because there IS no $game_party.members[4] (that's where the nil class comes in).


The equips array also starts at 0. So equips[1] is the first ARMOR slot, unless you have a dual wielder. I bet your first, third and fourth party member had the same thing equipped in the first armor slot. Change \W[\V[47]] to \A[\V[47]] instead, and it'll tell you what armor they're all wearing.


If you want the weapon, use equips[0].id
Argh, that was so dumb -_- .

Sorry, Archeia I should've started a new thread.

Thanks for putting up with me Shaz, your help is really appreciated 🙂
Is there a script call for randomizing the value of a variable among the values of two other variables?

With the goal being to have variable X a random number generated between the values of variables Y and Z? Such as:

Control Variables: [x] = Random No. ([y]...[z]) if it were a regular event?
$game_variables[x] = $game_variables[y] + rand($game_variables[z] - $game_variables[y] + 1)rand(x) will give you a random number between 0 and x-1, which is why you have to do the +1 again at the end.So if y is 15 and z is 20 it would work like this:

Code:
$game_variables[y] + rand($game_variables[z] - $game_variables[y] + 1)15 + rand(20 - 15 + 1)15 + rand(6)
and the limits would be
Code:
15 + 0 to 15 + 515 to 20
It would be up to you to ensure y is less than z
Thanks for responding. I inputted your suggestion like this: 

[IMG]http://s27.postimg.org/8r9bv4cmb/PNG2.png[/IMG]

The Priority was set to Same As Character and Trigger as Action Button. I used the text as a check to see what the values were. 

[IMG]http://s16.postimg.org/ldhcyf7id/PNG1.png[/IMG]

I copy-pasted the script like this, with X = Variable 61 (which was left blank), and Y = 62 (set to equal 1) and Z = 63 (set to equal 7)

[IMG]http://s16.postimg.org/nkllmccsl/PNG3.png[/IMG]

However, I just get this error

EDIT*

I split the script with a line break like so

$game_variables[61] = $game_variables[62] + rand($game_variables[63] - 

$game_variables[62] + 1)

And got it to work

[IMG]http://s28.postimg.org/rnlhlu70t/PNG4.png[/IMG]

Thanks for your help! And sorry for these large images (I can't find the 'spoiler' function to minimize things like on other forums)
It's because of the line break. Change it so the line break is before that last $game_variables.

Code:
$game_variables[61] = $game_variables[62] + rand($game_variables[63] - $game_variables[62] + 1)
When you need to use a line break, it has to be in a spot that implies to the interpreter that there is more. For example, after an operator.
Or you could do this:

Code:
v = $game_variablesv[61] = v[62] + rand(v[63]-v[62]+1)
If that doesn't work, just change v[61] on the second line to be $game_variables[61]
Thanks guys, it's working great
This topic is now closed and will be replaced shortly!

Original thread: https://forums.rpgmakerweb.com/threads/script-call-equivalent-of-events.6248/