Ruby/RGSSx questions that don't deserve their own thread

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,930
Reaction score
13,567
First Language
English
Primarily Uses
RMMV
class Game_Actor < Game_Battler alias lithkast_level_up level_up def level_up lithkast_level_up $game_variables[@id + x] += 1 endendLet's assume your variables are all sequential. Change x in the code above to be one less than the first variable (if actor 1 has variable 1, just remove the + x altogether and leave it as $game_variables[@id]. If actor 1 is assigned to variable 18, make x 17.
 

lithkast

Quirky mini boss
Veteran
Joined
May 12, 2014
Messages
105
Reaction score
49
First Language
english
Primarily Uses
do I post that as its own script, or go under Game_Actor and add it in?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,930
Reaction score
13,567
First Language
English
Primarily Uses
RMMV
In its own script slot, under Materials
 

lithkast

Quirky mini boss
Veteran
Joined
May 12, 2014
Messages
105
Reaction score
49
First Language
english
Primarily Uses
It returned an error

Script 'Game_Variables' line 19: Typeerror Occurred

the offending section w​as this

  def [](variable_id)
    @data[variable_id] || 0
  end
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
And what is the code you had?

What was written below the error?

Give us the text of full error message.

Is it

undefined method += for nil:nilClassEDIT : Shaz's post below is why I'm asking what is the code you had.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,930
Reaction score
13,567
First Language
English
Primarily Uses
RMMV
Shouldn't be - nothing in there that would cause a problem for a saved game.


Did you change the x to a number? Try changing @id to @actor_id - that's probably it.
 
Last edited by a moderator:

lithkast

Quirky mini boss
Veteran
Joined
May 12, 2014
Messages
105
Reaction score
49
First Language
english
Primarily Uses
There was nothing before the error code I wrote.  I wrote that exactly as the error was mentioned to me. : /

As for the fix  Shaz was right.  it should be @actor_id.  That fixed it and its working fine now.  All that's left is to add in a way to display the variable on the characters status page, but I can tool around in luna engine and figure that out probably.  Shaz, how should I credit you?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,930
Reaction score
13,567
First Language
English
Primarily Uses
RMMV
I don't need credit for that.
 

Heathurr

Veteran
Veteran
Joined
Aug 10, 2015
Messages
38
Reaction score
2
First Language
English
This is just related to scripting in general, and not to anyone's particular scripts. 

Is there a way to make it so that using a normal attack can write a value to a variable based on what kind of weapon you have equipped?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,930
Reaction score
13,567
First Language
English
Primarily Uses
RMMV
what kind of variable based on the weapon equipped? Keeping in mind that enemies also use the normal attack and don't have weapons.


If it's one of the weapon parameters, you could possibly modify the skill formula to pop something into a variable, but I suspect the check to see if it's an actor and if there's a weapon equipped might make the formula too long to fit in the formula box.
 
Last edited by a moderator:

Heathurr

Veteran
Veteran
Joined
Aug 10, 2015
Messages
38
Reaction score
2
First Language
English
The monsters actually wont be using the normal attack in this game. There are more than enough skill slots for them to have their own moves.

It's actually not a weapon parameter. I'm talking about writing to a variable of my own creation. So like, for example, SwordEXPactor1 or BowEXPactor2. Is this possible?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,930
Reaction score
13,567
First Language
English
Primarily Uses
RMMV
Your description is very ambiguous. You're not talking about $game_variables? Where is this variable defined and where do you use it? What are you putting into it?


If you want a specific answer, you have to give a specific example. Say EXACTLY what you want it to do and we can show you how. "a value" and "a variable" are not specific enough.
 

Heathurr

Veteran
Veteran
Joined
Aug 10, 2015
Messages
38
Reaction score
2
First Language
English
I'm just talking about the variables that you can create as part of events with the control variable command. But, alright, let me start over. 

I am trying to construct a system where I can have attacks and skill usage add an exp value to a certain variable. so like there'd be two variables per skill. "sword exp actor1" and "sword level actor1"
 
Then I'd make a common event and set it to parallel process. Give it a conditional branch that says something like if "sword exp actor1" is greater than or equal to 100, then increase "sword level actor1" by 1 and subtract 100 from "sword exp actor 1". 

Is there a way to make a normal attack that's carried out by an actor add to that variable that I've described there, based on what weapon that actor is using. Is there any way to do that.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,704
Reaction score
7,364
First Language
German
Primarily Uses
RMMV
yes, you'll need to place the variable commands into the damage formula for that - there is an entire topic on how to use the damage formula box for additional effects and functions.


However, the place available in the damage formula is limited - writing $game_variables[33]+=1; for several variables might be too much, and then you'll need to define the changes as a regular script function and simply call that function in the damage formula box.


But I suggest not using a permanently running parallel process for checking that - if the experience can only gained in combat, then you only need to run the check once after each combat and can shut off the parallel event after running once.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,930
Reaction score
13,567
First Language
English
Primarily Uses
RMMV
Could you write v[33]+= 1? Since v = $game_variables in the damage method? Or is that a copy of the array only?


Anyway, this isn't really scripting, so if you want to do it via the damage formula, find the thread Andar is talkign about (I think it's pinned in the VX Ace Tutorials forum) and post there - also have a look through it for ideas.
 

Cristiander

Veteran
Veteran
Joined
Aug 13, 2015
Messages
41
Reaction score
1
First Language
Romanian
Primarily Uses
Can I set a variable in the script editor? If so, please tell me how :(

I'm new to sripting.

I tryed this code but it gave me an error.

$game_variables[1] = 0I need the variable to be set when the game starts
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
2,994
First Language
Tagalog
Primarily Uses
RMVXA
Where did you do that? And what error? Most probably you might have run it in a time where $game_variables is not yet defined
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
What Engr. Adiktuzmiko said :

$game_variables is defined after the Main Process has executed.

So maybe you wanted to add that line at the end of create_game_objects and extract_save_contents methods in the DataManager?

On the other note, I think that variables in $game_variables are automatically set to 0, or they are set to 0 when you for the first time access them.

Or I'm wrong.
 

Cristiander

Veteran
Veteran
Joined
Aug 13, 2015
Messages
41
Reaction score
1
First Language
Romanian
Primarily Uses
The error is :

Script: My Variable line 2 - NoMethodError occured

undefined method '[]=' for nil:NilClass

So if I can't place the script in the Materials section, where should I place it?
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
I think this will solve it :

class << DataManager  alias :some_random_alias_init  :init  def self.init    some_random_alias_init    $game_variables[1] = 0  endendOr change 1 to any other iD you want

Place this below Materials
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

Latest Profile Posts

Ami
--- Survival For RPGist Part 2 ---

Survivalist: Now,I going to Test you: Fishing with Spear
M.Spear Knight: Leave it to me.
(M.Spear Knight Spearing the Fish with His Battle Spear)
M.Spear Knight: How it is?
Survivalist: I know you did it,but...Is that the Spear for Battle,not for Fishing?
M.Spear Knight: But,is that same?
Survivalist: (Sigh)...Whatever
Hello I buyed RPG Maker VX Ace a long ago and I want to use it again but in the meantime I changed my pc but I lost the paper with my product key on so I can't use RPG maker again... someone can help me please ? or there is no hopes ?:'( ( I have a bad english I'm sorry )
I was away this days here in the forum but it was for a good cause!
The trailer of the demo of Luke Inn is on youtube and I am so happy!
I need to see the bugs of the game but I am happy that I have new content to show!

Forum statistics

Threads
102,941
Messages
996,149
Members
134,402
Latest member
Hazimiealiff46
Top