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

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,671
Reaction score
2,993
First Language
Tagalog
Primarily Uses
Youre gonna place it on materials section too, just that the code needs to run somewhere else, like as posted above...

If you place a code outside of any method, that would run during set up before any other scripts start running, which was the cause of your problem...
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,837
Reaction score
12,255
First Language
English
Primarily Uses
RMMV
What is it that you're actually trying to achieve? I get the feeling that you're just doing it in the wrong place - so rather than forcing a way to let you do it, it would be better to find out what you're actually trying to do (why are you setting a variable in script rather than in a startup event?) so you can do it the right way.
 

sokita

Crawling back to the surface
Veteran
Joined
Apr 27, 2014
Messages
198
Reaction score
29
First Language
Indonesian
Primarily Uses
Script call for self switches is $game_self_switches[[map_id,id,"letter"]] = value. So, if I want to set all letter to false, I must write it 4 times (for A to D). Just wondering, is there a way to make this shorter without making a method inside Game_Interpreter class?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,837
Reaction score
12,255
First Language
English
Primarily Uses
RMMV
['A', 'B', 'C', 'D'].each do {|switch| $game_self_switches[[map_id, id, switch]] = false


Assuming you're replacing map_id and id with actual numbers, because they would not work in a script call. You'd have to use $game_map.map_id and @event_id for the "current" event.
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
Actually, he/she can use

['A','B','C','D'].each{|ss|$game_self_switches[[@map_id, @event_id, ss]]}if he/she wants it shorter
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,837
Reaction score
12,255
First Language
English
Primarily Uses
RMMV
oh yeah, you don't need the "do" with {}, but other than that, what you put is exactly what I put, except you used ss instead of switch as the variable name. And you didn't assign it a value ;)
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
Note the @map_id.

You noted that he/she can use $game_map.map_id, but Game_Interpreter has a public instance variable @map_id.

No need for $game_map.map_id

That's the reason why I posted, and not because of do and ss. And yeah, I forgot to add the initial value, oops :)
 
Last edited by a moderator:

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
What am I doing wrong?

Problem:

class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * alias: initializes back variable #-------------------------------------------------------------------------- alias cdr_rows_initialize initialize def initialize(actor) cdr_rows_initialize(actor) if actor.back_row? @back = true else @back = false end end  
Error:

back_row definition:

#==============================================================================# ** RPG::BaseItem#==============================================================================class RPG::Actor #-------------------------------------------------------------------------- # * new method: check initial back row #-------------------------------------------------------------------------- def back_row? return !(note =~ CDR_ROWS::REGEXP::BACK_ROW).nil? endend
CDR_ROWS::REGEXP::BACK_ROW = /<(?:back_row)>/i

Thanks guys :)
 

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
679
First Language
Polish
Primarily Uses
Other
Question - How to get amount of party members?

For example - there are 2 actors in party > output 2; there are 5 actors in party > output 5

What I need that for? - setting dynamic window size based on current amount of party members.

IDK, something like $game.party_members.amount < translate that to Ruby language.

Thank you in advance.
 
Last edited by a moderator:

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
@Rikifive

You were close

Code:
$game_party.members.size
 
Last edited by a moderator:

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
@Alyon

Because in the initialize, the actor is a parameter.

Try changing that to

Code:
def initialize(actor_id)
 

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
Ok it's working even if I don't actually understand why.

The more I think I'm starting to learn scripting, the more I lose hope on it!  :D

Cheers Mate  :)
 

metronome

Veteran
Veteran
Joined
Aug 21, 2014
Messages
348
Reaction score
144
First Language
English (Sure!)
Primarily Uses
Questions:


What is the script call to turn all switches and self switches in the game off?


Is it:

$game_switches = Game_Switches.new


$game_self_switches = Game_SelfSwitches.new
And then, what is the script call turn all variables in the game into 0?


is it:

$game_variables = Game_Variables.new
I want to restart the whole game from the start when the game is ended without going to


menu screen, and I don't want to use New Game+ script (too confusing and I am not into


adding more scripts into script editor). That's why I ask these questions.


Thanks for at least reading~~!!
 
Last edited by a moderator:

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
I've got another question:

Is it possible to extend "an ally(dead)" scope so that I can target a member in another state too? 

I'm doing a skill with wich a character may help the others while in danger. Right now he works as a simple revive skill, but I'd like to use it also for traps(like a character caught in a spider net or something).

I might use it in "an ally" scope but I don't like the idea to being able to select other members too.

I guess if it's not possible I will keep the "an_ally" scope but I'm really curious about it actually.
 
Last edited by a moderator:

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
@metronome

I think it can be done like that.

But, if it does not work, paste the error here, and we may be able to help you

@Alyon

It CAN be done, but I think it is not in the scope of RGSSx Script Supporters.

Try posting this to RGSS3 Script Requests, because this script requires a bit more work than just a few lines of code (first some regexps, then Scene_Battle...)

That's just my opinion, maybe when you post there some moderator will redirect your post to this forum, and I'm sorry in that case.

(Sorry, moderators, if I led him to a wrong forum)
 
Last edited by a moderator:

Alyon93

Veteran
Veteran
Joined
May 19, 2015
Messages
62
Reaction score
2
First Language
Italian
Primarily Uses
N/A
@Alyon

It CAN be done, but I think it is not in the scope of RGSSx Script Supporters.

Try posting this to RGSS3 Script Requests, because this script requires a bit more work than just a few lines of code (first some regexps, then Scene_Battle...)

That's just my opinion, maybe when you post there some moderator will redirect your post to this forum, and I'm sorry in that case.
 Ok mate I'll try there. I thought it would have been easy actually. 

Thanks anyway :)
 

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
679
First Language
Polish
Primarily Uses
Other
Question: Is it possible to make a condition, where game checks which window it is?

Example: Something like "if SceneManager.scene_is?(Scene_<Scene>)" but to not check the whole scene, but one window.

What I'm trying to achieve: I'm using MOG menu cursor and I would like to change its position when moving to actor selection window. In general - the cursor is on the left side ~ I want to move it to the right side when going to window, where I'm selecting actors (through 'formation' 'equip' etc. commands).

Thank you in advance.
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
It can't be really done that easy.

But it can be done like this :

Imagine you have a scene with @actor_window, @item_window, @skill_window, @some_window and @choice_window (just an example, no need for that much windows, though)

So, if you want to check is Actor Window active you do @actor_window.active

For Choice Window it would be @choice_window.active

There isn't really a variable of currently active window, because more windows at once can be active.
 
Last edited by a moderator:

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
679
First Language
Polish
Primarily Uses
Other
So.. for actor status window should I try something like this?

if SceneManager.scene_is?(Scene_Menu) && if @actor_window.active < lol will this work? xD

cursor to the right

else

nope, stay on the left.

end

?



I tried

if SceneManager.scene_is?(Scene_Menu) if @actor_window # because .active caused crash. righty else lefty endelse also leftyendbut it didn't work. =P

So I think it's kinda impossible? =P
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

Latest Profile Posts

I try to check out 2-3 projects from the Games In Development forum every fortnight. I usually don't spend more then 30 minutes to an hour on each project, but I do try to leave a comment to share my thoughts on each one I check out. I usually just pick whatever catches my eye, but if you're reading this and would like a little feedback on your project in development let me know and I'll see if I can check it out :)
I drew Resident Evil 2 style lock for my horror game. (Pixels intended)
I wake up to see I now have 73 subscribers on YouTube, that means I've gained 67 subs in the last two days. :LZSexcite:
With all this practice, I'll be hitting competitive in social distancing soon.
Ugh! I have a headache coming on--not sure if it's from the sudden change in weather or caffeine withdraw...only one way to fi d out--Coffee time!

Forum statistics

Threads
95,804
Messages
932,061
Members
126,229
Latest member
LastKingOfScotland
Top