Save-Point
matching seqential filenames - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: matching seqential filenames (/thread-5104.html)



matching seqential filenames - trapless - 04-15-2014

I have edited Modern Algebra's "Fix Picture to Map" script allowing animation. Great success as it will allow me to animate bits of the map where needed when "parallax mapping". My dilemma is selecting the next image of a set properly.

I'll use the "show picture" function of the event editor just as modern algebra's script does. The script then recognizes a regex match in the file name and flips a switch to "true" witch adds another method to the show picture update method.

the file i am working with is named "0123[ANI][1][20].png"
(base_name): 0123
(update trigger): [ANI] = yo, this is an animation flip the switch and update accordingly"
(fame of "base_name" set): [1] = this is "frame one" of the [ANI]
(duration for timer): [20] = this picture remains on screen for "20" frames then update switches self.bitmap with "0123[ANI][2]["any number"].png" if a filename with "0123[ANI][2]" in it exist in the same directory.

putting "@name[/(\w+)(\[ANI\])\[(\d+)\]\[(\d+)\]/i]" at the beginning of my method: animation_update creates the variables:
$1 = 0123
$2 = [ANI]
$3 = 1
$4 = 20 and i am able to find the next picture in the animation with the line:

if FileTest.exist?("Graphics/Pictures/#{$1}#{$2}[#{$3.to_i + 1}][#{$4}]"
#and flip to that image with:
@name = "#{$1}#{$2}[#{$3.to_i + 1}][#{$4}]"
@mafpm_ani_duration = $4.to_i
else
@name = "#{$1}#{$2}[1][#{$4}]"
@mafpm_ani_duration = $4.to_i
end

but if i specify a different duration in the filename of [ANI][2], the file is not found. I have tried to use:
("Graphics/Pictures/#{$1}#{$2}[#{$3.to_i + 1}][#{/(\d+)/}]" and a few other things but I dont think FileTest accepts regex so i moved on to: @mafpm_ani_frames = Dir.entries("Graphics/Pictures").select{|e| e =~ /(\w+)(\[ANI\])\[(\d+)\]\[(\d+)\]/i} witch gives me an array of all the files in my picture folder with the same name formatting. Even a file named "thorn_in_my_ball[ANI][1][20].png" so again i need to refine it and i'm sure i will soon.

Tsukihime mentioned to me on another post i made about it that filesystem operations wouldnt work if the game is encrypted. I dont suppose it's necessary to encrypt my "game" and i don't want to though, i would like to avoid filesystem methods if i must.(any info?)

point blank, I want my animation instruction read by the script directly from the filename. Can anyone help me achieve this in a more simple fashion? If you can, please explain how your method works if you would be so kind. I just began coding and would appreciate a definition supplied with a new word rather than a new quest for a definition supplied with a new word.

here is : a link to the other post, it may contain useful information for understanding my concept...?

I'm going to give my brain a rest and let this post soak in some views, maybe a response(or 10) and go cry on my wife's shoulder.


RE: matching seqential filenames - trapless - 04-15-2014

i found a way to get the the animation cell's on screen duration from the file name itself and cycle through an array of all matching file names of an animation set.

here is a video of it working:


code improvements?

Content Hidden

it does what i want BUT waIT! i seriously would enjoy some suggestions before i request this to close. :)