Tapael

Veteran
Veteran
Joined
Oct 23, 2021
Messages
31
Reaction score
8
First Language
n
Primarily Uses
RMVXA
Hello, there was a problem at the common event this time.



I thought that the state given is different depending on the hp situation of the actor.


So I made this code.

[#spoiler]

actor = $game_actors[14]




actor.add_state(142) if (($game_actors[$game_variables[18]].hp/$game_actors
[$game_variable[18]].mhp))*100 >= 20





actor.add_state(143) if (($game_actors[$game_variables[18]].hp/$game_actors
[$game_variables[18]].mhp))*100 <= 20

[#/spoiler]

For variable number 18, the script was used to store the id of the actor targeted by the skill.


So I built and start it, but


The error game_actor can't be coerced by fixnum occurred.


So I subtracted game_variable[18] and tried to put the number (id of the actor to be skill target), but the same error occurred.

Why is it like this?
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
658
Reaction score
368
First Language
German
Primarily Uses
This is/was a common issue with script commands where your window size is limited:
If you break up a line in Ruby, make sure that the lines cannot be interpreted as separate statements, since line breaks are also used as a separator. Alternatively you can end a line with a backslash to indicate that the statement should be continued in the next line.

So instead of
$game_actors
[14]


you can use
$game_actors[
14]

or
$game_actors\
[14]
 

Tapael

Veteran
Veteran
Joined
Oct 23, 2021
Messages
31
Reaction score
8
First Language
n
Primarily Uses
RMVXA
This is/was a common issue with script commands where your window size is limited:
If you break up a line in Ruby, make sure that the lines cannot be interpreted as separate statements, since line breaks are also used as a separator. Alternatively you can end a line with a backslash to indicate that the statement should be continued in the next line.

So instead of
$game_actors
[14]


you can use
$game_actors[
14]

or
$game_actors\
[14]


As you said, I modified it like this.


1660619499747.png

But when I ran it, I got this error.

1660619797715.png

In this case, is there a problem with my code?
 

EntangledPear

Previously No Patience (now patient enough)
Veteran
Joined
Sep 12, 2018
Messages
122
Reaction score
54
First Language
Slovak
Primarily Uses
RMVXA
The code seems fine. Try to break the line after the division (end the line with .hp/ and put what follows on the next line).
 
Last edited:

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
455
Reaction score
184
First Language
English
Primarily Uses
RMXP
You have an extra opening square bracket on your first line. Also typo on game_variable (missing an 's'). Second line has typos too.

And it looks like you'll run into integer division problems. Do this instead
Code:
actor.add_state(142) if ($game_actors[$game_variables[18]].hp * 100 / $game_actors[
$game_variables[18]].mhp)) >= 20
Adjusting for correct line breaks as previously called out in the thread.
 
Last edited:

Tapael

Veteran
Veteran
Joined
Oct 23, 2021
Messages
31
Reaction score
8
First Language
n
Primarily Uses
RMVXA
You have an extra opening square bracket on your first line. Also typo on game_variable (missing an 's'). Second line has typos too.

And it looks like you'll run into integer division problems. Do this instead
Code:
actor.add_state(142) if ($game_actors[$game_variables[18]].hp * 100 / $game_actors[
$game_variables[18]].mhp)) >= 20
Adjusting for correct line breaks as previously called out in the thread.
Thank you, everyone.

So I modified it like this.

1660711461305.png


But this time, another problem has arisen.


It seemed to work normally if you put a number in the first line, but as shown in the picture above, the following error occurred when you put and run the variable.

1660711422956.png



In case the script didn't work, I thought the variable was not given the actor's number, so I checked it in the battle test using the Matton \v[18], but the variable was normally assigned the actor's number.



Here's how I've worked so far.


1. Insert the corresponding common event into Skill 1 and run it immediately.

But when it didn't work, I tried the following way.



2. First, put the function of storing the number of the actor in the variable in Skill 1. Using other scripts, change Skill 1 to 2.

After that, I put a common event in Skill No. 2 and designated the same actor as the target No. 1, but the following error occurred.


Why is it like this?
 

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
615
Reaction score
609
First Language
English
Primarily Uses
RMMZ
Thank you, everyone.

So I modified it like this.

View attachment 238030


But this time, another problem has arisen.


It seemed to work normally if you put a number in the first line, but as shown in the picture above, the following error occurred when you put and run the variable.

View attachment 238029



In case the script didn't work, I thought the variable was not given the actor's number, so I checked it in the battle test using the Matton \v[18], but the variable was normally assigned the actor's number.



Here's how I've worked so far.


1. Insert the corresponding common event into Skill 1 and run it immediately.

But when it didn't work, I tried the following way.



2. First, put the function of storing the number of the actor in the variable in Skill 1. Using other scripts, change Skill 1 to 2.

After that, I put a common event in Skill No. 2 and designated the same actor as the target No. 1, but the following error occurred.


Why is it like this?
The error message is telling you exactly what the problem is. game_variables isn't a thing. It's supposed to be $game_variables. For some reason, you're typing it inconsistently--half the time you're doing it right, and half the time you're doing it wrong.
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
512
Reaction score
219
First Language
English
Primarily Uses
RMXP
You should be using the actor variable instead of the $game_actors whatchamecallit starting at line 2.
 

Tapael

Veteran
Veteran
Joined
Oct 23, 2021
Messages
31
Reaction score
8
First Language
n
Primarily Uses
RMVXA
The error message is telling you exactly what the problem is. game_variables isn't a thing. It's supposed to be $game_variables. For some reason, you're typing it inconsistently--half the time you're doing it right, and half the time you're doing it wrong.
Thank you. I think I finally got what I wanted!
 

Latest Threads

Latest Posts

Latest Profile Posts

Tried something. Little sneak peak of Unity AD.
M42S7Us.gif

It's the little things. Lengthened the time the bar fades in and out to be a bit more comfortable.
3 days until release!

Forum statistics

Threads
125,736
Messages
1,173,113
Members
164,882
Latest member
thuthiemzeitriver1
Top