Script Call Equivalent of Events

Status
Not open for further replies.

Petite Elite

Veteran
Veteran
Joined
Jan 1, 2013
Messages
128
Reaction score
91
First Language
English
Primarily Uses
Oh, sorry. This is a screenshot:



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

Here is the event:

 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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?
 
Last edited by a moderator:

Petite Elite

Veteran
Veteran
Joined
Jan 1, 2013
Messages
128
Reaction score
91
First Language
English
Primarily Uses
Oh, I see. So what would I replace @actor with to select the nth party member?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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?
 

Petite Elite

Veteran
Veteran
Joined
Jan 1, 2013
Messages
128
Reaction score
91
First Language
English
Primarily Uses
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
$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
 

Petite Elite

Veteran
Veteran
Joined
Jan 1, 2013
Messages
128
Reaction score
91
First Language
English
Primarily Uses
$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.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

Petite Elite

Veteran
Veteran
Joined
Jan 1, 2013
Messages
128
Reaction score
91
First Language
English
Primarily Uses
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 part)



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 = 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 = 1, I got this error:



When = 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.)

 

Archeia

Level 99 Demi-fiend
Developer
Joined
Mar 1, 2012
Messages
15,141
Reaction score
15,473
First Language
Filipino
Primarily Uses
RMMZ
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
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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
 
Last edited by a moderator:

Petite Elite

Veteran
Veteran
Joined
Jan 1, 2013
Messages
128
Reaction score
91
First Language
English
Primarily Uses
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 :)
 

Futuristic

Villager
Member
Joined
Jan 27, 2014
Messages
5
Reaction score
0
First Language
English
Primarily Uses
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?
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
$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
 
Last edited by a moderator:

Futuristic

Villager
Member
Joined
Jan 27, 2014
Messages
5
Reaction score
0
First Language
English
Primarily Uses
Thanks for responding. I inputted your suggestion like this: 



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. 



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)



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



Thanks for your help! And sorry for these large images (I can't find the 'spoiler' function to minimize things like on other forums)
 
Last edited by a moderator:

Yato

(aka Racheal)
Veteran
Joined
Mar 17, 2012
Messages
825
Reaction score
346
Primarily Uses
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.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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]
 

Futuristic

Villager
Member
Joined
Jan 27, 2014
Messages
5
Reaction score
0
First Language
English
Primarily Uses
Thanks guys, it's working great
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top