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

[Ace]
Its been years and i still cant write simple script command yet.

How to write...
"random atkpattern(variable name) from 1-5.
If user.AP5(
this is custom parameter using Sixth's script) = atkpattern(variable name) then do A, else B
"

I want to use this in middle on battle.
For reference, i try to write this as
untitl10.png

Just to test and of course it pop an error window (range to integer etc)
@ashm Not sure what you're doing, but try $game_variables[1] instead?
Two faults.

First. Use rand(5) instead. But if you really want a random range from 1 to 5, use rand(4) + 1
Second. You're missing 's' from $game_variables just as moonless nite mentioned

(btw, why your name is so familiar)
@A-Moonless-Night, ah i feel so dumb.☺️ Thanks for reply.
Yeah that solve the problem and Theo also pointing another tips (I swear i've seen 'rand(1..4)' code somewhere' so i tried to copy it).

@Theo : nice timing. Yeah, im ashm from old rmid.
I've question about your battle system.
please check your message
Quick - but probably difficult to solve question, right now for my damage formula - I've been using a variable to set a move's base power. But I was thinking of maybe using a note tag - to write the power variable in instead so I can kill a variable.

From what I understand so far is that it is possible to reference a skill (and I think a last used one too) - but I'm not really sure how to go about getting something out of it that is a number value?
Last skill used might be complex, but if it's just to reference a notetag, you might want to start to mess with "def make_damage_value" in Game_Battler. I mean, all the calculation are there, and feel free to modify it
I guess that's worth a shot - though I should probably back this up since I had a heart attack over states, I'd probably die if I messed up the actual game code. From what I've seen so far of it though, I'm thinking I could probably alter this:

Code:
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)

but I don't imagine it would be as easy as pasting my default damage formula over it - and putting that "item.damage" bit where the base power is multiplied into the damage (with the hopes I'd just be able to put "base damage" in the formula box - along with the methods I'd still need to run for contact/sprite change checks).

Especially since I don't know how'd it calculate a physical or magical attack.
RGSS3;

So i was messing around with calling random battles similar to pokemon, walk around in the grass, boom dude pops up, right?

But using

Code:
BattleManager.setup(1, true, true)
BattleManager.event_proc = Proc.new {|n|
@branch[@indent] = n }
$game_player.make_encounter_count
SceneManager.call(Scene_Battle)
Fiber.yield

I get the error "Can't yield from root fiber"

From what I understand of fiber, according to DP videos, a fiber is something that can be paused/resumed so if I understand it right, this code is trying to 'save' Scene.map so that it can return to it after the battle is finished, because if I remove Fiber.yield, once the battle ends I get another error.

My question is, if I want to call a battle from the map how do I properly use this Fiber command?
Where you put that little snippet?
Where you put that little snippet?
I put it in Scene_Map in it's own method which I call from update
DP's explanation is not wrong, but you just perceived it in a wrong way. Fiber.yield main usage is to pause and to be resumed later, but you can't just randomly put Fiber.yield everywhere to do so. The method need to be called inside Fiber.new. In this case, it should be called within event command processing, see Game_Interpreter, or Window_Message.

The usage would be like this.
Code:
a = Fiber.new do
  puts "ABC"
  Fiber.yield
  puts "EFG"
  Fiber.yield
end

a.resume
puts "--------------"
a.resume
puts "--------------"
If you put this on a new code, then you will see the output gonna be like this in console
Code:
"ABC"
"--------------"
"EFG"
"--------------"

But you can't just go like this.
Code:
puts "ABC"
Fiber.yield
puts "--------------"
puts "EFG"
Fiber.yield
puts "--------------"

Last, you don't need event_proc. You don't call it within the event command, you don't need it. That's the reason why it will error on battle end
Oh right. I took out those commands and you were right, it worked as expected. I will play with Fiber some more on my own. But that code snippet I got from this post;

https://forums.rpgmakerweb.com/index.php?threads/script-call-collection-for-vxace.25759/

I'm confused why it would be there if it's not needed. I guess I'll just keep picking apart the codes. Thanks man
Well, that's "script call" for a reason. To be used in script call command. Some method may not available outside script call (like Fiber), some method need to be there because it's used within script call command, so you can't just pick whatever on it and paste inside the script editor without knowing how it works and why you need those lines.

You might as well as learning how RGSS works if you want to edit script from editor
Thanks for your help. TBH, I've watched videos and all sorts so many times, I don't want to do it again. I'm just gonna play with the scripts and try to figure out how they work.
I've noticed that some people alias methods like so:
Code:
alias :newname :oldname
def oldname
#blah blah
end

Whereas some people do the following:
Code:
alias newname oldname
def oldname
#blah blah
end

What is the difference between the two, or does it not matter too much?
I believe aliasing using symbol is less ambiguous
For example, in Game_Switches, you want to alias method []= I usually go with
Code:
class Game_Switches
  alias :aliased_switch :[]=
  def []=(switch_id, value)
    aliased_switch(switch_id, value)
    ........
  end
end
I'm not sure if this will work
Code:
alias aliased_switch []=
Maybe you can try?
It will work fine no matter which way you do it.
I don't think it matters, seems to be personal preference only.
It's the same with calling methods by their name (using either the send or call method) , you can use a string or symbol there too, both will work, and there is no difference from what I can see (although working with strings is much easier in some cases since you can add to them if needed, unlike with symbols).
Is there a way to change window color in-game? Not the skin
Event commands -> Page 3 -> System Settings
Oh yeah lol
idk how I missed that

Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/