Set a targeted picture

Fridjah

Veteran
Veteran
Joined
Jan 13, 2015
Messages
155
Reaction score
7
First Language
French
Primarily Uses
RMVXA
Hello !


I have a "Gauge" picture that I wish to force to get zoom_x 100 if >100.


I wrote it my self (woooooo yeah !)  and it looks to work.


class Game_Picture
#--------------------------------------------------------------------------
# * Show Picture
#--------------------------------------------------------------------------
def show (name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
if @name = "Gauge"
if zoom_x > 100
@zoom_x = 100
else
@name = name
@origin = origin
@x = x.to_f
@y = y.to_f
@zoom_x = zoom_x.to_f
@zoom_y = zoom_y.to_f
@opacity = opacity.to_f
@blend_type = blend_type
init_target
init_tone
init_rotate
end #if
else
# Nothing
end #if
end #Def
end #Class


I just need the expertise from someone to tell me if that can mess somewhere


in the project.


Don't laugh at me ... It took about 2h to make it work without "errors" :D


Thank in advance !
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
It's a good try, but there are two serious flaws that I can see, that I believe should cause it to not work at all.

Code:
class Game_Picture
  #--------------------------------------------------------------------------
  # * Show Picture
  #--------------------------------------------------------------------------
  def show (name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
    if @name = "Gauge"        <<< @name is not set at this point - it only gets set a few lines down.  You only have 'name' to work with here.
       if zoom_x > 100
          @zoom_x = 100
       else                   <<< if xoom_x is > 100, none of the code below this will work.  I'd change this line to 'end' and get rid of the one lower down.
          @name = name
          @origin = origin
          @x = x.to_f
          @y = y.to_f
          @zoom_x = zoom_x.to_f
          @zoom_y = zoom_y.to_f
          @opacity = opacity.to_f
          @blend_type = blend_type
          init_target
          init_tone
          init_rotate 
       end #if  
    else
    # Nothing   
    end #if  
  end #Def
end #Class
With these issues, I'm not actually sure how your code is working at all, because @name will be empty so that first condition will be false, and none of the code will be run.  Are you certain it's your code being run and not the default method?  Where have you put the script in the list?
 
Last edited by a moderator:

Fridjah

Veteran
Veteran
Joined
Jan 13, 2015
Messages
155
Reaction score
7
First Language
French
Primarily Uses
RMVXA
1st, I checked in the script editor where the "Picture" is managing and I found it


in Game_Picture.


Then I started to write something between #Materials and #Main, the usual place


where to add scripts.


I tried to chance the place of ...


@name = name
@origin = origin
@x = x.to_f
@y = y.to_f
@zoom_x = zoom_x.to_f
@zoom_y = zoom_y.to_f
@opacity = opacity.to_f
@blend_type = blend_type
init_target
init_tone
init_rotate


... But is the only place where I dont have any weired effect or error.


Everytime I try to find out if something is realy runing or to find a problème


with an event, I use SE or Message:


class Game_Picture
#--------------------------------------------------------------------------
# * Show Picture
#--------------------------------------------------------------------------
def show (name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
if @name = "Gauge"
if zoom_x > 100
@zoom_x = 100
RPG::SE.new("Up4", 100, 100).play
else
@name = name
@origin = origin
@x = x.to_f
@y = y.to_f
@zoom_x = zoom_x.to_f
@zoom_y = zoom_y.to_f
@opacity = opacity.to_f
@blend_type = blend_type
init_target
init_tone
init_rotate
RPG::SE.new("Down2", 100, 100).play
end #if
else
# Nothing
end #if
end #Def
end #Class


It can be noisy, but I sure the stuff is runing.


And down here, you can see part of the gauge, it's the orange one.


The orange gauge is not the only picture on the screen. there is about 10-12 at the same time


and my script only targeting the orange one. That's why I thinking it works, but cause


I am a script noob, I was just wondering if is just a cohinsidence.


Script gauge.png
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
I don't see how that could possibly work, because if the zoom is greater than 100, those other variables are not being set.  Unless you're doing a Show Picture with it = or < 100 first, and then you're doing another Show Picture with it > 100 but you're using the same picture number.  In that case it might just be remembering the other variables.


Try testing, and ONLY show a picture with > 100 zoom.  Don't do the <= 100 zoom at all.  If you ONLY do one and it's the > 100 zoom, you might get different results.
 

Fridjah

Veteran
Veteran
Joined
Jan 13, 2015
Messages
155
Reaction score
7
First Language
French
Primarily Uses
RMVXA
I controling it in events too, that way:


EDIT: the image is wrong cause of a quick montage:


VAR 13 Gauge X


VAR 14 Gauge Y


VAR 16 Gauge


Gauge Event.png
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
You've set the same variable (14) twice there, and haven't set 13 at all, so no guarantee that's going to be bigger than 100
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
Shaz is right, that code you wrote will mess up other pictures, even your gauge pictures in some cases.


What I don't understand is, why don't you simply check if the variable that you use for the zoom argument is greater than 100 or not in your events instead?


If it's greater, it should be corrected to the maximum amount right there, or else your gauge will keep getting more and more "value", even if you can't see it on your screen.


This means, that if you want to lower the "value" of that gauge, you will first need to get rid of the excess amounts which got added to the zoom_x variable before you could see any change visually on your gauge. Needless to say, this kinda destroys the purpose of showing that gauge, it won't be accurate that way.


In all cases where a gauge is displayed, you must limit the real value of the data you want to show with it, not the visual size of your gauge.


So, simply add a check for the maximum value of your zoom_x variable (which is variable 16, judging from your event screenshot) before you show the picture for real, and if it is greater than 100, set it to 100 there. This will ensue that your gauge will display an accurate data, assuming that your max "real value" for that thing you want to display is 100.


Doing this will also eliminate the need for any code made directly in the Game_Picture class.


Btw, if you set the value of the X and Y variable to a static one before showing the image, what's the point of using those variables at all?


You could simply pass the direct numbers for them instead. 


Unless that's just for testing, and in the real deal, you will use the variable values which are set somewhere else, in which case, ignore this part. :D
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
@Sixth I can't see how that code could possibly work - I would expect nothing at all to display on the screen.  Can you explain why it appears to work for the OP when logic dictates that it shouldn't?
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
Aside from the @name variable, all of the used instance variables got a default value set up the moment a picture is shown (before it, actually).


The @name variable got a default value too (just an empty string), but that is not really usable for anything, other than showing an empty "image".


The default values will only be set once for each pictures (upon initialization). After that, all of those values are saved until they get changed (these doesn't include the pictures' angle and tone values, those get reset every time a picture is shown).


There is no way to show a picture without setting up all the values from the "Show Picture" editor command, so it is not possible to mess them up that way (unless the default show method is changed in the Game_Picture class, which it is now).


What he did in his script call will also set all the values up (and might even work in certain conditions - written below).


Now for his actual code...


There are many more flaws with it.


First, that check he used is not really a check, it will always return true. 

if @name = "Gauge" # Sets the name AND returns true.

if @name == "Gauge" # This would only check it.



From this point on, the @name variable is set to "Gauge". This also means that there is no way to end up with an empty @name variable ever, at least not if the picture is shown with the show method from the Game_Picture class.


After this, the code continues to check for the 100 limit. If the limit is reached, it gets set to 100. Nothing else will run at this point from the code. This doesn't matter if the value of the zoom_x argument was below 100 the first time he showed the "Gauge" picture, because the other variables will be loaded than, and will be saved until they are changed again. This is why the X and Y position seems to be correctly set, because they are set before the 100 limit is reached.


Now, if the limit is NOT reached, it proceeds to load the default arguments. This means the @name variable will get the correct value, because it gets it from the name argument. Same for every other instance variable here, they get the correct values from the arguments.


There will be issues (many of them) when the zoom_x argument exceeds 100, especially for other images (not the "Gauge" ones).


If that would happen (and it could happen in many ways, just show any image with a zoom level of 150, for example), the image shown would be the "Gauge" image all the time, regardless of what you have set in the "Show Picture" command (or in it's script equivalent), and the other values you have set in the event command would get ignored too (it will just load either the initial defaults or the last saved values).


And this would be it, in short, I guess. :p
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Ah, the @name = "Gauge" assignment not comparison is what I missed :)   Thanks.


So to prove this doesn't work, the test is simply to use Show Picture with a different image name and a zoom x > 100?
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
Yeah, that would give a not desired result for sure.


The image shown would be the "Gauge" image, and the other settings would be either set to the defaults or to the last saved ones for that picture.
 

Fridjah

Veteran
Veteran
Joined
Jan 13, 2015
Messages
155
Reaction score
7
First Language
French
Primarily Uses
RMVXA
What I don't understand is, why don't you simply check if the variable that you use for the zoom argument is greater than 100 or not in your events instead?
Yes you're right. why to do simple when it's possible to do it complicated ... or ... whatever :p


My 1st guess was if I dont do a script, the bar will show over 100 for a frame then fit to 100.


But my brain cheated me. Now I see how I can do it in my event.

So to prove this doesn't work, the test is simply to use Show Picture with a different image name and a zoom x > 100?
I just tried it as as I readed that, and you're right. The other picture not showing up and the image changed.


finaly it was just a (wooooo failed again !)  good lesson.


And it looks to be a profit for someone else too. :)


Thank you guys +1 !   Woot ! You got a "HQ thanks" !
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,047
Messages
1,018,539
Members
137,834
Latest member
EverNoir
Top