Showing posts with label Personal note. Show all posts
Showing posts with label Personal note. Show all posts

Aug 21, 2014

personal note 8 - Debug

(1) What happened:
I wanted to see callstack.

(2) Solution
 module DebugView
    def parse_caller(at)
      if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
        return [$2, $3] #file = $1; line = $2.to_i; method = $3
      end
    end
  
    def track
    return if !$TEST
        stack = []
      caller.each { |arr| stack.push( parse_caller(arr) ) }
      stack.pop; stack.pop
      self.trace(stack)
    end
end

call DebugView.track

(3) Remained Problems
caller returns [filename, line, method].
but in rgss3, filename has no meaning since all scripts are loaded in single file.

Q. why DebugView?
A. ('w') < because it was there.

Aug 19, 2014

personal note 7

(1) What happened:
Bias in the random movement.
If you use "Options: Direction Fix" and "Movement Type: Random" simultaneously,
The event biased to move to the fixed direction.

(2) Cause
In the line 114 of Game_Event,

  def move_type_random
    case rand(6)
    when 0..1;  move_random
    when 2..4;  move_forward
    when 5;     @stop_count = 0
    end
  end

Since direction is fixed, that "move_forward" goes to always same direction.



If I remember correctly,

in RPG Maker 2000, inner direction values can be changed even if direction if fixed.
And some crazy people used the direction of events as a substitute of variables.
VX Ace not allow it.


(3) Solution
when 2..4;  @direction_fix ? move_random : move_forward



('w') < ...harmless.

personal note 6

(1) What happened:

If you set event parametes as "Trigger: Event Touch" and "Movement Type: Random",
the event will never touch player.

(2) Cause
"Movement Type: Random" checks whether a movement is possible before it move.
If not, the event do nothing. It will not check an event activation.

(3) Solution
I made a short script...but wait.
Just changing "Movement Type: Player touch" is enough isn't it?

Aug 12, 2014

personal note 5 : Reading RegEx


(1) What happened
I had trouble at RegEx while editing my CC_FG.

In line 300 in Window_Base;
  #--------------------------------------------------------------------------
  # * Destructively Get Control Code Argument
  #--------------------------------------------------------------------------
   def obtain_escape_param(text)
    text.slice!(/^\[\d+\]/)[/\d+/].to_i rescue 0
  end

What is that [/\d+/] ?
That single line crashed my whole night.

Perhaps I'll forget what does this line say, so leaving this note.

(2) Decryption
That bracketed RegEx ([/\d+/]) is one style of [] for String.
It returns a matched part of String.

Example:
"hoge01"[0] => "h"
"hoge01"[/\d+/] => "01"

so a collapsed form of the line means;

begin
  str = text.slice!(/^\[\d+\]/)
  str.match(/\d+/)
  str = $&.to_i
rescue
  0
end


(3) Application

And from there, I made a line to get String parameter.
  str = text.slice!(/^\[.+?\]/)
  str.match(/\[(.+?)\]/)
  str = $1

or
  str.match(/\[(.+?)\]/)[1]

or
  text.slice!(/^\[\S+\]/)[/\[(.+?)\]/, 1]

I will not use the compressed RegEx line though.

(4) Biproduct

Class Window_Base < Window
  def obtain_escape_param_string(text)
    text.slice!(/^\[\S+\]/)[/\[(.+?)\]/, 1] rescue 0
  end
end


This allows us to take a parameter as String for control characters in RMVXA.
I thought I need this method in CC_FG at first, but not in result.

('w')

Aug 9, 2014

personal note 4

(1) What happened:
CACAO's DebugView script (for VX) does not work on RPG Maker VX Ace.
http://cacaosoft.blog42.fc2.com/blog-entry-508.html

(2) Cause
Difference in version of ruby(1.8 and 1.9.2) of RGSS2 and RGSS3.
NKF in 1.9 does not work as in 1.8.
I forgot details.

(3) Solution
Replace 7th line;
  'OutputDebugString.call(NKF.nkf('-s', s))'
with
  'OutputDebugString.call(s.to_s.encode("Shift_JIS"))'.

('w') < DebugView is nice.

Aug 8, 2014

personal note 3

(1) What happened:
Confliction.
When you introduced ろかん's "シンボルエンカウント補助"
with Mog Hunter's "Character EX", latter won't work.

(2) Cause
Aliasing inherited Method.
Aliasing Method(Update) of Class(Game_Character) in "シンボルエンカウント補助".
But Class(Game_Character) does not have own Method(Update).

(3) Solution
I made my own version of it, CC_TracerEvent.
But simply adding Method(Update) before alias might be enough...

Aug 2, 2014

personal note 2

(1) What happened:
In CC_FG;
When F12 is pushed while displaying a picture,
bitmap in (Class Figure) is disposed while FGManager.dispose is not called.

(2) Cause
Unknown. Perhaps embedded (Class Sprite) has some problem.

(3) Solution
Check the case of that the instance of (Class Figure) is not disposed
but inner bitmap is disposed.

personal note

(1) What happened:
When I opened VX ACE's 'Manage Projects', it deleted my projects in 'Save Path' without confirm dialog.

(2) Cause
A file 'Game.ini' in project folder which includes;
  CreationDate= ***
  CloudDate= ***
  SteamOwner= ***
These lines are basically appear in the project folder downloaded from Steam Workshop.
Deleted projects were originally copy of Workshop projects and were edited.

VX ACE checks 'Game.ini' and, if it finds strange lines, automatically delete whole project folder without warning. It is a bit of...

(3) Solution
Avoid to copy workshop projects.
With copied folder, delete these lines or overwrite by default 'Game.ini'

('w') < don't forget to back up.