Calintz's Scripting Questions(Mainly Snippets)

Started by Calintz, February 19, 2009, 02:58:28 am

Previous topic - Next topic

Calintz

February 19, 2009, 02:58:28 am Last Edit: March 21, 2009, 10:03:41 pm by Calintz16438
Calintz's Scripting Questions Thread


**Let's Zoom to the Character**  :???:

To add simple aesthetics is the key to graphical success when making games. A very useful feature in any game is to be able to locate a specified object(character, tile, etc...) and zoom onto that specific object. Can somebody with scripting knowledge(probably requires a 'basic' level of scripting knowledge) help me learn how to perform this action??

**I think this will be done by acquiring the (x, y) coordinates of the character or object, and then zooming to that location.




RESOLVED :D

**Let's Move the Gold Window**

I was trying to figure out how to move the gold window, and all of my attempts have failed miserably.. .. .. :|

**I am using the default command to show the gold window from a message on the map. How do I change the location for this??




FOUND A WAY AROUND  :^_^':

**Let's Dispose of that Gold Menu** 

I was able to generate my own gold menu and placing it where I desired by using the "Call Script" command. However, the window does not disappear when I would like it to.

**What command can I used to dispose of that window from the "Call Script" command??
**Also, what command can I use to update the same window??





FOUND A WAY AROUND  :^_^':

**Let's Move the Window Pause Icon Permanently**

Everybody who uses RMXP knows that when a message is being shown, in order to continue, you have to press a certain button, right!? Well, while the system is waiting for that button to be pressed the system lets you know that it is waiting on you by displaying that small window pause icon at the bottom of your message.

What I am looking to do is to indefinitely change the y position of that little pause icon, but I do not know what syntax controls the pause icon, and I could not find anything that led me to believe that it is located in the Window Message script. Anyone wanna help me find the area that controls this icon??

**Please don't tell me to edit the windowskin itself, because the windowskins attributes for the pause icon themselves, aren't large enough to re-locate the icon to display where I desire.




**Let's Make an Icon Blink** :???:

I was wondering if somebody could help me set up a small snippet that could be added into a script that uses icons for display. The meaning of the snippet is to make the icon blink.

**I know it involves changing the icons hue, but I don't know how to loop the effect and have it continue to blink until a certain condition is met.




**Let's Determine the Passability of a Specific Tile** :???:

It has become my top priority to figure out a way to determine whether or not a tile (on any given map) is passable...Here is the catch. I need this tile to be very specific. I need to know how to determine if a tile that is placed two tiles ahead of the main character is passable or not.




RESOLVED :D

**Let's Check the System for the Current #of Party Members**

Is there a snippet I can use that can check the system for a set amount of party members?? Like, can I do something like this?? It would be called from the conditional branch, call script option.

Spoiler: ShowHide
$game_system.party == 1
- obviously not the proper syntax.
**Meaning if there is one member in your party.

Reno-s--Joker

When you say zoom, do you mean pan (i.e. scroll along a map until the person is centred on the screen)?

Calintz

No, I mean ZOOM into. Like the picture zoom command in the event editor. This command allows you to zoom anywhere to any point on pictures.

Is it possible that zooming on the map isn't possible??

Landith

There was a script on Creationasylum that had a map zoom feature, too tired to get a link though...
So no, it isn't impossible.

Calintz

Good deal...
I HAVE to figure out how to do it!!

I have yet to see a game that zoomed on the map though.


Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz

HAHAHA!!
I do no such thing Blizzard!!

@Reno:
That all depends on the level of detail in your graphics, and the distance of zoom.

Reno-s--Joker

Quote from: Calintz16438 on February 21, 2009, 05:24:48 am
HAHAHA!!
I do no such thing Blizzard!!

@Reno:
That all depends on the level of detail in your graphics, and the distance of zoom.

LIES. :D
<3

Yeah, as soon as I posted it I realised it might be good for a world map or something. :D I must admit I can't help you but I'd be interested to see if someone can figure this out. :shifty:

Calintz

Me too...

I really hate to spoil the surprise, but for the scenes I will be zooming, I am going to use charasets with dimensions around 75pixels by 75pixels, so we'll see what happens.

G_G

calintz get on msn and I can help you with the pic at the end of teh battle.

Fantasist

Dunno if this'll help, but you can always take a screenshot and zoom the sprite.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Calintz

I was thinking about that, but that doesn't allow for animation. I want to be able to have events playing while the zoom is in effect.

winkio

I would look at a Mode 7 script.  They have to have some sort of a zoom function in there...

Calintz

Alright, That one here on CP (Cata). you think it would have one?

Reno-s--Joker

I was thinking about Mode 7 too. And it allows for animation as well.

... bububut the pixellation... ;;_;;

Calintz

New question in the 1st post.
** Please help.

Jackolas

March 06, 2009, 02:02:56 am #17 Last Edit: March 06, 2009, 02:14:48 am by Jackolas
move the gold window?
in the menu?
if so, you use custom menu scripts?


if no custom script:
Spoiler: ShowHide

to change the size, change in Window_Gold around line 12:
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 64)            #change this
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end


to change position, change in Scene_Menu around line 51
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = 0           #Change these for x
    @gold_window.y = 416        #change for Y



hope it works.
if you use a custom script that i need to look into the script

Reno-s--Joker

Depending on which scene you wnat to change its co-ordinates for.

Do a Ctrl+Shift+F for this:
@gold_window = Window_Gold.new

And shortly following, the x and y co-rods should be specified. Change them there.

Hope it helped. Ask if you don't get it. ^-^

Calintz

March 06, 2009, 02:27:37 am #19 Last Edit: March 06, 2009, 03:29:31 am by Calintz16438
Ah, my mistake...I should have clarified...
I am showing the gold window using the \g command in a message on the map.

How do I change the position where it appears??

EDIT
**I was able to figure this out thanks to you guys.
**I simply removed the show gold command in the message, and created my own gold window with the "call script" command, and then I moved it where I wanted it.

Thank you guys. You are both powered up...

EDIT01
I have another question. I hope someone can help.

Tazero

The updste shouldn't it be like
gold_window.update if active

Or something along those lines?
And wouldn't you use scene_bler.close/quit/end
or something close to that?


If you were a fish...

Calintz

I'm pretty sure that those are not the proper commands.
**I have already tried to 'refresh,' 'dispose,' and 'remove.' Update might work, but I doubt it.

Tazero

Don't worry though i'm learning too, hqrd as hell isn't it?


If you were a fish...

Calintz

Can be.. .. ..
For the most part, I am beginning to nail everything simple.

I can do what I need to get things the way I want. I just hit some small road blocks sometimes.

Tazero

Alright try this
scene_gold.update else scene_gold.dispose


I'm using my basic knowledge of ruby sorry i can't be of more help


If you were a fish...

Calintz

March 06, 2009, 04:24:22 am #25 Last Edit: March 06, 2009, 04:27:27 am by Calintz16438
That might actually work, hold on.. .. ..let me try.

EDIT
No good...

Jackolas

probably have a idea. but need to get home from work to test it out.
will let you know.

Tazero

Scene_gold.active? else scene_gold.refresh else scene_gold.dispose

?


If you were a fish...

Juan

I'm not sure how you update it from a call script. Heres what  to change the gold window from the window_message class
Spoiler: ShowHide
        # If \G
        if c == "\002"
          # Make gold window
          if @gold_window == nil
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle
              [b]@gold_window.y = 192[/b]
            else
              [b]@gold_window.y = self.y >= 128 ? 32 : 384[/b]
            end
            @gold_window.opacity = self.opacity
            @gold_window.back_opacity = self.back_opacity
          end
          # go to next text
          next
        end

Here are the line numbers you change
Spoiler: ShowHide
Line 115 @gold_window.x = 560 - @gold_window.width
# Change the y positon in battle.
Line 117 @gold_window.y = 192
# Change the y depending if the y is less then 128. If goes to 32 if the y is there. Otherwise the y is 382.
Line 119 @gold_window.y = self.y >= 128 ? 32 : 384
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

G_G

Well Calintz the gold window should already be disposing by itself. Okay so you're using the \g command in a message box right? Well then it should dispose it already. Its not going to dispose until the message teh \g command is in is over. But if all failse use this


if  @gold_window.visible
  @gold_window.visible = false
end


or if that doesnt work try


if @gold_window.visible
  @gold_window.dispose
end


All done in a script command even the branch. And yes it should be
@gold_window.dispose


Hopefully you didnt mess up the Window_Message by accident.
So if the above two fails try replacing your current Message_Window with a new one from a new project and see if it still happens.

Calintz

March 06, 2009, 08:53:46 pm #30 Last Edit: March 06, 2009, 08:57:01 pm by Calintz16438
None of this works.
I don't use the gold window from the message box. I am creating a new window with the "Call Script" command. I constantly get a no method error when I use the dispose command.

**Could Ccoa's UMS be causing the issues, but I wouldn't understand why, because I am still using the default syntax.

**This is exactly as the commands appear in my game.

@gold = Window_Gold.new
@gold.x = 416
@gold.y = 288

The window will not dispose though...

I have tried using @gold.dispose and several other commands, but all attempts have failed. I even replaced the default window message script like game_guy suggested.

G_G

March 06, 2009, 08:56:59 pm #31 Last Edit: March 06, 2009, 08:58:07 pm by game_guy
then use
@gold.dispose


Only use
@gold_window.dispose

If you've actually named it @gold_window. And why do that when you can go into Window_Message line 115 and change teh x there and also change teh y and call it from teh message

Calintz

No, no, no!! I have been using
@gold.dispose

G_G

Quote from: game_guy on March 06, 2009, 08:56:59 pm
then use
@gold.dispose


Only use
@gold_window.dispose
[/s]
If you've actually named it @gold_window. And why do that when you can go into Window_Message line 115 and change teh x there and also change teh y and call it from teh message


Use the method thats not strook out then.

Calintz


G_G

Give me ccoa's message system
and I'll alter the gold x and y for you.

I was trying to cross out the code but it didnt work.  But gimme ccoa's message system and the x and y coordinates and I'll alter it for you. Then just use the
\g command.

Calintz

That's okay. I know how to do that.
Thank you...So far, things are working well.. .. ..

Reno-s--Joker

Maybe you've put the dispose command in the wrong spot. But I still suggest you give G_G your script. ^-^

Calintz

I guarantee that I did not put the .dispose command into the wrong place.

This was my exact code.. .. ..

@gold = Window_Gold.new
@gold.x = 416
@gold.y = 288


Upon attempting to update, I tried all of the following:
Spoiler: ShowHide

if @gold.visible
  @gold.dispose
end



if @gold != nil
  @gold.dispose
end



@gold.dispose

**None of the aforementioned succeeded.
**I have everything under control now though.


**Game_Guy = Power Up!!

G_G

game_guy says "So I solved it?" game_guy gets slapped by Ronnie. ronnie says " No duy look at the power up"

Calintz

Haha, yes Game_Guy...you solved the problem.

I had never actually thought about changing the (X, Y) values of the default placement in Ccoa's script. I knew how, but it hadn't crossed my mind.

Thank you very much Game_Guy XD.

Calintz is now.. .. ..a...
!! LEXIMAN WARRIOR !!


Calintz

Haha thanks Reno...
I might have some more questions soon.

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

If you ever want to create your own gold window through script command again use "$gold" instead of "@gold" and see if that works.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Calintz

March 07, 2009, 11:23:09 pm #45 Last Edit: March 07, 2009, 11:24:11 pm by Calintz16438
I just used it on any old map Blizz...
I have found a way around this problem Ryexander, but thanks anyway buddy...

**Thanks to gameguy

fugibo

*only read the first post and the last 4-5 on this page* Zooming in on the map isn't supported in RGSS :(

Blizzard

Doesn't mean it can't be done by using a Tilemap rewrite. <_<;
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

try searching on creation asylum calintz. I saw one there and I tried it and it was pretty good.

Landith

Yeah, there was one there too, it was even used in this one game, although I forgot what it was.
They zoomed in the map for cutscenes, and stuff like that. The only thing wrong with it was that it was pixelated when you zoomed in, but I believe that's near impossible to fix.

Calintz

Of course it's gonna pixelate...Just don't radically zoom in, Lol.
Zoom in to a maximum of 125% or so for a decent effect.

I will look, thanks everyone.

Calintz



Ryex

March 14, 2009, 08:11:03 pm #53 Last Edit: March 14, 2009, 08:15:11 pm by Ryexander
Isn't there a built in method to add hews to a bitmap?

Quote from: Rgss reference
Sprite
The sprite class. Sprites are the basic concept used to display characters, etc. on the game screen.

flash(color, duration)
Begins flashing the sprite. duration specifies the number of frames the flash will last.

If color is set to nil, the sprite will disappear while flashing.

color
The color (Color) to be blended with the sprite. Alpha values are used in the blending ratio. (uses a color object)

Handled separately from the color blended into a flash effect. However, the color with the higher alpha value when displayed will have the higher priority when blended.

tone
The sprite's color tone (Tone). (uses a Tone object not a color object)



Color
The RGBA color class. Each component is handled with a floating point value (Float).

SuperclassObject
Class MethodColor.new(red, green, blue[, alpha])
Creates a Color object. If alpha is omitted, it is assumed at 255.

Methodset(red, green, blue[, alpha])
Sets all components at once.

Propertiesred
The red value (0-255). Values out of range are automatically corrected.

green
The green value (0-255). Values out of range are automatically corrected.

blue
The blue value (0-255). Values out of range are automatically corrected.

alpha
The alpha value (0-255). Values out of range are automatically corrected.



The color tone class. Each component is handled with a floating point value (Float).

SuperclassObject
Class MethodTone.new(red, green, blue[, gray])
Creates a Tone object. If gray is omitted, it is assumed at 0.

Methodset(red, green, blue[, gray])
Sets all components at once.

Propertiesred
The red balance adjustment value (-255 to 255). Values out of range are automatically corrected.

green
The green balance adjustment value (-255 to 255). Values out of range are automatically corrected.

blue
The blue balance adjustment value (-255 to 255). Values out of range are automatically corrected.

gray
The grayscale filter strength (0 to 255). Values out of range are automatically corrected.

When this value is not 0, processing time is significantly longer than when using tone balance adjustment values alone.






If I understand it correctly basically to blink an icon you would have to do this.  any one else feel free to correct me.

#create sprite use this cone to create a sprite
@icon = Sprite.new
@icon.bitmap = Bitmap.new(width, height)
@icon.bitmap.blt(x, y, RPG::Cache.icon("Icon_name_here"), Rect.new(x, y, width, height))
@icon_alpha = 0
@icon_mode = 1
#flash icon call the method every frame that you are flashing the icon
def flash_icon
    if @icon_mode == 1
         @icon_alpha += 5
         if @icon_alpha > 255
              @icon_alpha = 255
         end
         if @icon_alpha == 255
              @icon_mode = 0
         end
    elsif @icon_mode == 0
         @icon_alpha _= 5
         if @icon_alpha < 0
              @icon_alpha = 0
         end
         if @icon_alpha == 0
              @icon_mode = 1
         end
    end
    icon_color = Color.new(255, 255, 255, @icon_alpha)
    @icon.color = icon_color
end


The code creates a sprite object and then the  flash_icon method blends a wight color with the sprite and changes tha alpha of the blended color depending on the previous alpha. feel free to change the color blended or the alpha limits.

please note that I have not tested this so I'm not sure that the commands for creating the bitmap in the sprite or changing the icons color are correct, but the idea should be right.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Reno-s--Joker

From Game_Map:
To the person who wants to help with the tile jumping: ShowHide
  #--------------------------------------------------------------------------
  # * Determine if Passable
  #     x : x-coordinate
  #     y : y-coordinate
  #     d : direction (0,2,4,6,8)
  #         * 0 = Determines if all directions are impassable (for jumping)
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    # If coordinates are outside of map
    unless $game_map.valid?(new_x, new_y)
      # impassable
      return false
    end
    # If through is ON
    if @through
      # passable
      return true
    end
    # If unable to leave first move tile in designated direction
    unless $game_map.passable?(x, y, d, self)
      # impassable
      return false
    end
    # If unable to enter move tile in designated direction
    unless $game_map.passable?(new_x, new_y, 10 - d)
      # impassable
      return false
    end
    # Loop all events
    for event in $game_map.events.values
      # If event coordinates are consistent with move destination
      if event.x == new_x and event.y == new_y
        # If through is OFF
        unless event.through
          # If self is event
          if self != $game_player
            # impassable
            return false
          end
          # With self as the player and partner graphic as character
          if event.character_name != ""
            # impassable
            return false
          end
        end
      end
    end
    # If player coordinates are consistent with move destination
    if $game_player.x == new_x and $game_player.y == new_y
      # If through is OFF
      unless $game_player.through
        # If your own graphic is the character
        if @character_name != ""
          # impassable
          return false
        end
      end
    end
    # passable
    return true
  end

You'd probably have to incorporate it with your jumping script.

I changed my mind, but I haven't tested it: ShowHide
case $game_player.direction
  when 2
    if $game_map.passable?($game_player.x, $game_player.y+2, 0)
      disable_jump
    end
  when 4
    if $game_map.passable?($game_player.x-2, $game_player.y+2, 0)
      disable_jump
    end
  when 6
    if $game_map.passable?($game_player.x+2, $game_player.y+2, 0)
      disable_jump
    end
  when 8
    if $game_map.passable?($game_player.x, $game_player.y-2, 0)
      disable_jump
    end
  end
   

Calintz

March 15, 2009, 04:26:00 am #55 Last Edit: March 15, 2009, 04:29:34 am by Calintz16438
I'm not using a script.
My Running and Jumping System is event oriented. XD

But hopefully, your post will aide someone else.

edit
I thought for sure it was gonna have something to do with this...
# If unable to enter move tile in designated direction
    unless $game_map.passable?(new_x, new_y, 10 - d)
      # impassable
      return false
    end

G_G

are you wanting to see how many members are the party? If so


if $game_party.actors == 1
  Blah here
else
  if $game_party.actors == 2
    blah here
  else
    if $game_party.actors == 3
      blah here
    else
      if $game_party.actors == 4
        blah here
      end
    end
  end
end
[code]

Just select teh code thing in the 4th tab in a Conditional branch.
[/code]

Calintz


G_G

Yes I've used it when I created a custom menu asystem before

Calintz

Okay thank you...I will go test now, and...
*power up*