Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
RPG

Quick Scripter Question!

Recommended Posts

Hey guys it's RPG again.

 

A quick question to anyone who knows their scripts better than I.

 

I'm great at just about everything in RMXP but scripting. ( I never really bothered to learn it's syntax that much....)

 

Below I shall show you a simple script made in the description inside that simply displays a small box with your gold in it. (I prefer to have my gold on screen rather than having to open the menu up to look.)

 

As labeled below, calling a script with Gold_Window.hide will hide it. After a million attempts with:

  • Gold_Window.hide
  • Gold_Window.unhide
  • Gold_Window.show
  • Gold_Window.true
  • Gold_Window.false
  • Gold_Window

I am curious to how you unhide it. Anyone know? rolleyes.gif

 

 

 

#==============================================================================

# ----------------------------------------------------------------------------

# Created By Micko (on http://save-point.or...321-page-2.html)

# ----------------------------------------------------------------------------

# * Using "Gold_Window.hide" in a call script turns off the HUD.

#==============================================================================

module Gold_Window

# Window's horizontal position

WINDOW_X = 460

# Window's vertical position

WINDOW_Y = 396

# Window's width

WINDOW_WIDTH = 160

# Window's height

WINDOW_HEIGHT = 64

# Default hide status of the window (true = hidden, false = visible)

DEFAULT_HIDE = false

 

@hide = DEFAULT_HIDE

def self.hidden?

return @hide

end

def self.hide

@hide = !@hide

end

end

#==============================================================================

# ** Window_Gold_HUD

#------------------------------------------------------------------------------

# This window displays amount of gold.

#==============================================================================

class Window_Gold_HUD < Window_Base

#--------------------------------------------------------------------------

# * Object Initialization

#--------------------------------------------------------------------------

def initialize

super(Gold_Window::WINDOW_X, Gold_Window::WINDOW_Y,

Gold_Window::WINDOW_WIDTH, Gold_Window::WINDOW_HEIGHT)

self.contents = Bitmap.new(width - 32, height - 32)

@old_gold = -1

@old_hide = Gold_Window.hidden?

self.opacity = Gold_Window.hidden? ? 0 : 255

@text_opacity = Gold_Window.hidden? ? 0 : 255

refresh

end

#--------------------------------------------------------------------------

# * Refresh

#--------------------------------------------------------------------------

def refresh

if @old_gold != $game_party.gold || @old_hide != Gold_Window.hidden?

self.contents.clear

self.opacity = Gold_Window.hidden? ? 0 : 255

@text_opacity = Gold_Window.hidden? ? 0 : 255

color_normal = Color.new(255, 255, 255, @text_opacity)

color_system = Color.new(192, 224, 255, @text_opacity)

cx = contents.text_size($data_system.words.gold).width

self.contents.font.color = color_normal

self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)

self.contents.font.color = color_system

self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)

@old_gold = $game_party.gold

@old_hide = Gold_Window.hidden?

end

end

end

#==============================================================================

# ** Scene_Map

#------------------------------------------------------------------------------

# This class performs map screen processing.

#==============================================================================

class Scene_Map

#--------------------------------------------------------------------------

# * Main Processing

#--------------------------------------------------------------------------

alias gold_hud_main main

def main

@gold_window = Window_Gold_HUD.new

gold_hud_main

@gold_window.dispose

end

#--------------------------------------------------------------------------

# * Frame Update

#--------------------------------------------------------------------------

alias gold_hud_update update

def update

@gold_window.refresh

gold_hud_update

end

end

 

Edited by RPG

Share this post


Link to post
Share on other sites

You just call hide again.

The method appears to be a toggle:

 

@hide = !@hide

 

This basically just returns the opposite of whatever boolean value it actually is.

Share this post


Link to post
Share on other sites

Odd...it doesn't work......adding that to the list of failures for me.

Share this post


Link to post
Share on other sites

I can make a script that actually works real quick if you like. I see all sorts of errors with the one you have posted. It will only take a couple minutes.

Share this post


Link to post
Share on other sites

Couple of minutes?! blink.png Well sure then if it's that quick.

 

I was thinking of possibly toggling the actual window so that you only see the gold value (if you used it in game yet).

 

But yeah go ahead I'll be very thankful for your help and not having to waste all the time trying to figure that out.

Share this post


Link to post
Share on other sites

On pastebin since the this site does not know how to handle tabs in the message box, quite possibly the most annoying thing here.

 

http://pastebin.com/TJK9wbGy

 

Just use $game_map.display_gold = true/false to hide/unhide the window.

This doesn't redraw the window every frame like the old script did, which is a horrible mistake even for a beginner scripter.

 

If you want it located somewhere differently on the screen, changed opacity, colors, no windowskin, etc. just say, I'll give you the line to add to do it.

Share this post


Link to post
Share on other sites

Oh wow that was fast and it is indeed efficient! I thank you once again. laugh.png

 

And yes i would like to change its attributes since it gets in the way for one of my graphics. yes.gif

Edited by RPG

Share this post


Link to post
Share on other sites

Directly above/below the comment in the scripts, just add the lines:

 

@gold_hud.x = X

@gold_hud.y = Y

 

Obviously replace the values with actual numbers.

 

If you simply want to move it to the right side of the screen:

@gold_hud.x = 640 - @gold_hud.width

 

...or move to the bottom

@gold_hud.y = 480 - @gold_hud.height

 

...or change the opacity:

@gold_hud.back_opacity = OPACITY (a value between 0..255)

 

...or not use a windowskin...

@gold_hud.windowskin = nil

Share this post


Link to post
Share on other sites

Thank you very much!

 

I also didn't notice until I was adding and checking my other scripts. I'm also using your hunger and thirst script too! (Which btw was released 2 days from now, exactly 2 years ago.)

 

So I also thank you on that as well!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...