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

And to do what Dekita was wanting to do with their original example, just don't use regular expressions.

Code:
>> "Splitting sentences. Stupidly.".split('.')=> ["Splitting sentences", "Stupidly"]
Really, why do people always jump to regular expressions for the simplest things?
well i generally only split notetags like this

.split(/\r\n+/) other than a map name script i wrote which splits each character ( split(//)I had never tried to split a string using .split(/./) i was just using it as an example, but if it doesnt work then thats that 😛
Well learning using regular expression is not so bad. Beside split, you can use scan and match (though in this situation, I think split and scan are much better).

"Hi Guys ~. Hello Everybody ~. Yo dawg!".scan(/[^. ]+[^.]*/)

would return => ["Hi Guys ~", "Hello Everybody ~", "Yo dawg!"]
scan is equal to =~ is it not ?

Also, what is it you are acctually scanning for ?

like what does /[^.]+[^.]*/ check for ?
scan is equal to =~ is it not ?

Also, what is it you are acctually scanning for ?

like what does /[^.]+[^.]*/ check for ?
I split all sentences without having space at the beginning of sentence. 
interesting...

It seems Reg Exp is full of useful little things like that 😛
scan is equal to =~ is it not ?


Also, what is it you are acctually scanning for ?


like what does /[^.]+[^.]*/ check for ?
=~ is the match operator.
Ahh, i knew it was either scan or match that was equal to =~,

but match doesnt return the object data or something like that ? dunno, i use a case statement to check my notetags anyway, and its usually only notetags that i use RegExp for too 😛
Scan returns every match, while match returns the first one starting from the specified offset for the most part.


Scan is a String method, match is a Regexp method.
ahhh, ok. that explains things a little better 🙂

Edit:

Your like a little advice ninja... Just pop up and share your knowledge and wisdom then disappear  😀

Epic 😛
Is there a battle system that uses 8-directional battlers and is compatible with Galv's Timed Button Action? http://galvs-scripts.com/2013/03/11/timed-button-attacks/ I tried yami's sym.(http://symphonyan.org/battle-symphony-introduction/) and that didn't work (even though people say it does, I may be overlooking something...)
Somebody please tell me there's a self variable. I would love you if there was.
@Seacliff, your question belongs in Script Requests, not in this thread.


@Seita, maybe PK8's Self Data Suite might be helpful.
Thanks Shaz. If I were to use this script and use it solely for self variables, do you think it would adversely affect the gameplay, through lag or some other factor?

Also, just to make sure, when you call a self switch in a common event, it will use the event calling it's self switch correct? Would this script be similar in fashion?
@Shaz

Sorry, didn't know if it was a major enough issue to have it's own thread... on to the next step!
seita, I haven't used it, so I can't be sure. I can't see why it would cause lag or interfere with anything you already have in your game. It would only have an effect on things you TELL it to have an effect on after adding the script.


The Documentation.txt file shows you how to use it. Looks like you can just implement the scripts you're interested in - if you only want to add variables to events, then just use the Events (Self Data) script.


It LOOKS like, if you want to set Variable 1 to 15 on the current event, you'd just do Call Script: self_variable(1) = 15


So yes, if you called it from a common event that was called by a map event, it would put the variable on the map event.
Thanks Shaz that really helps.

Now I have a question regarding an error I'm getting.

error1hc.jpg


The eventing I have that generates this particular error is very complex, and the error isn't too easy to replicate, so I'm just trying to figure out the general direction. What are common reasons this error would happen?

Here's the portion of code for that default script:

  #--------------------------------------------------------------------------
  # * Update Origin
  #--------------------------------------------------------------------------
  def update_origin
    if @picture.origin == 0
      self.ox = 0
      self.oy = 0
    else
      self.ox = bitmap.width / 2     ##   <----This one
      self.oy = bitmap.height / 2
    end
  end
The error is occurring because "bitmap" is nil. Somehow the update origin method (or update in general for the sprite) is being called when there is no bitmap to update. Not sure how that would happen, but you could prevent the crash at that moment by adding a "return if self.bitmap == nil" at the beginning of the method you posted, though I suspect it could possibly still crash elsewhere not to mention the underlying problem of a picture with no bitmap.
would this have anything to do with sprites, actual pictures, or animations?
Since it's the Sprite_Picture class, it should just be pictures with show picture/move picture by default. I don't know if any scripts out there use the class or not.

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