alright i got 2 new scripts im working with and there both giving me trouble
and for the animation scripts theres some stuff in Game_Screen and Scene_Map
Ok so the problem with the first script is that when i define a key and set it to something
in the game when i push the button in this case Enter nothing happens
The problem with the second set of scripts is that whenever i run it it either says there's no file by that name which there is or it says the scrpit is hanging
Code:
#======================================
# â– Keyboard Script
#---------------------------------------------------------------------------
#  By: Cybersam
# Date: 25/05/05
# Version 4
#======================================
module Kboard
#--------------------------------------------------------------------------
$RMouse_BUTTON_L = 0x01 # left mouse button
$RMouse_BUTTON_R = 0x02 # right mouse button
$RMouse_BUTTON_M = 0x04 # middle mouse button
$RMouse_BUTTON_4 = 0x05 # 4th mouse button
$RMouse_BUTTON_5 = 0x06 # 5th mouse button
#--------------------------------------------------------------------------
$R_Key_BACK = 0x08 # BACKSPACE key
$R_Key_TAB = 0x09 # TAB key
$R_Key_RETURN = 0x0D # ENTER key
$R_Key_SHIFT = 0x10 # SHIFT key
$R_Key_CTLR = 0x11 # CTLR key
$R_Key_ALT = 0x12 # ALT key
$R_Key_PAUSE = 0x13 # PAUSE key
$R_Key_CAPITAL = 0x14 # CAPS LOCK key
$R_Key_ESCAPE = 0x1B # ESC key
$R_Key_SPACE = 0x20 # SPACEBAR
$R_Key_PRIOR = 0x21 # PAGE UP key
$R_Key_NEXT = 0x22 # PAGE DOWN key
$R_Key_END = 0x23 # END key
$R_Key_HOME = 0x24 # HOME key
$R_Key_LEFT = 0x25 # LEFT ARROW key
$R_Key_UP = 0x26 # UP ARROW key
$R_Key_RIGHT = 0x27 # RIGHT ARROW key
$R_Key_DOWN = 0x28 # DOWN ARROW key
$R_Key_SELECT = 0x29 # SELECT key
$R_Key_PRINT = 0x2A # PRINT key
$R_Key_SNAPSHOT = 0x2C # PRINT SCREEN key
$R_Key_INSERT = 0x2D # INS key
$R_Key_DELETE = 0x2E # DEL key
#--------------------------------------------------------------------------
$R_Key_0 = 0x30 # 0 key
$R_Key_1 = 0x31 # 1 key
$R_Key_2 = 0x32 # 2 key
$R_Key_3 = 0x33 # 3 key
$R_Key_4 = 0x34 # 4 key
$R_Key_5 = 0x35 # 5 key
$R_Key_6 = 0x36 # 6 key
$R_Key_7 = 0x37 # 7 key
$R_Key_8 = 0x38 # 8 key
$R_Key_9 = 0x39 # 9 key
#--------------------------------------------------------------------------
$R_Key_A = 0x41 # A key
$R_Key_B = 0x42 # B key
$R_Key_C = 0x43 # C key
$R_Key_D = 0x44 # D key
$R_Key_E = 0x45 # E key
$R_Key_F = 0x46 # F key
$R_Key_G = 0x47 # G key
$R_Key_H = 0x48 # H key
$R_Key_I = 0x49 # I key
$R_Key_J = 0x4A # J key
$R_Key_K = 0x4B # K key
$R_Key_L = 0x4C # L key
$R_Key_M = 0x4D # M key
$R_Key_N = 0x4E # N key
$R_Key_O = 0x4F # O key
$R_Key_P = 0x50 # P key
$R_Key_Q = 0x51 # Q key
$R_Key_R = 0x52 # R key
$R_Key_S = 0x53 # S key
$R_Key_T = 0x54 # T key
$R_Key_U = 0x55 # U key
$R_Key_V = 0x56 # V key
$R_Key_W = 0x57 # W key
$R_Key_X = 0x58 # X key
$R_Key_Y = 0x59 # Y key
$R_Key_Z = 0x5A # Z key
#--------------------------------------------------------------------------
$R_Key_LWIN = 0x5B # Left Windows key (Microsoft Natural keyboard)
$R_Key_RWIN = 0x5C # Right Windows key (Natural keyboard)
$R_Key_APPS = 0x5D # Applications key (Natural keyboard)
#--------------------------------------------------------------------------
$R_Key_NUMPAD0 = 0x60 # Numeric keypad 0 key
$R_Key_NUMPAD1 = 0x61 # Numeric keypad 1 key
$R_Key_NUMPAD2 = 0x62 # Numeric keypad 2 key
$R_Key_NUMPAD3 = 0x63 # Numeric keypad 3 key
$R_Key_NUMPAD4 = 0x64 # Numeric keypad 4 key
$R_Key_NUMPAD5 = 0x65 # Numeric keypad 5 key
$R_Key_NUMPAD6 = 0x66 # Numeric keypad 6 key
$R_Key_NUMPAD7 = 0x67 # Numeric keypad 7 key
$R_Key_NUMPAD8 = 0x68 # Numeric keypad 8 key
$R_Key_NUMPAD9 = 0x69 # Numeric keypad 9 key
$R_Key_MULTIPLY = 0x6A # Multiply key (*)
$R_Key_ADD = 0x6B # Add key (+)
$R_Key_SEPARATOR = 0x6C # Separator key
$R_Key_SUBTRACT = 0x6D # Subtract key (-)
$R_Key_DECIMAL = 0x6E # Decimal key
$R_Key_DIVIDE = 0x6F # Divide key (/)
#--------------------------------------------------------------------------
$R_Key_F1 = 0x70 # F1 key
$R_Key_F2 = 0x71 # F2 key
$R_Key_F3 = 0x72 # F3 key
$R_Key_F4 = 0x73 # F4 key
$R_Key_F5 = 0x74 # F5 key
$R_Key_F6 = 0x75 # F6 key
$R_Key_F7 = 0x76 # F7 key
$R_Key_F8 = 0x77 # F8 key
$R_Key_F9 = 0x78 # F9 key
$R_Key_F10 = 0x79 # F10 key
$R_Key_F11 = 0x7A # F11 key
$R_Key_F12 = 0x7B # F12 key
#--------------------------------------------------------------------------
$R_Key_NUMLOCK = 0x90 # NUM LOCK key
$R_Key_SCROLL = 0x91 # SCROLL LOCK key
#--------------------------------------------------------------------------
$R_Key_LSHIFT = 0xA0 # Left SHIFT key
$R_Key_RSHIFT = 0xA1 # Right SHIFT key
$R_Key_LCONTROL = 0xA2 # Left CONTROL key
$R_Key_RCONTROL = 0xA3 # Right CONTROL key
$R_Key_L_ALT = 0xA4 # Left ALT key
$R_Key_R_ALT = 0xA5 # Right ALT key
#--------------------------------------------------------------------------
$R_Key_SEP = 0xBC # , key
$R_Key_DASH = 0xBD # - key
$R_Key_DOTT = 0xBE # . key
#--------------------------------------------------------------------------
GetKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
GetKeyboardState = Win32API.new("user32","GetKeyState",['i'],'i')
GetSetKeyState = Win32API.new("user32","SetKeyboardState",['i'],'i')
#--------------------------------------------------------------------------
module_function
#--------------------------------------------------------------------------
def keyb(rkey)
if GetKeyState.call(rkey) != 0
return 1
end
return 0
end
#--------------------------------------------------------------------------
def keyboard(rkey)
GetKeyState.call(rkey) & 0x01 == 1 #
end
#--------------------------------------------------------------------------
def key(rkey, key = 0)
GetKeyboardState.call(rkey) & 0x01 == key #
end
#--------------------------------------------------------------------------
if Kboard.keyb($R_Key_RETURN) == 1
$scene = Scene_Status.new
return
end
end
Code:
#==============================================================================
# ** Game Animation
#------------------------------------------------------------------------------
# This script keeps all of the info on the animation that is to be played.
# It is very similar to Game Picture...
#==============================================================================
class Game_Animation
attr_reader :number #animation number
attr_reader :name #name of animation
attr_reader :width #width of frame(pixels)
attr_reader :height #height of frame(pixels)
attr_reader :frames #number of frames in animation
attr_reader :frame_width #width(by frames)
attr_reader :frame_height #height(by frames)
attr_accessor :x #x of animation
attr_accessor :y #y of animation
attr_reader :target_x #x destination of animation
attr_reader :target_y #y destination of animation
attr_reader :delay #Delay(in frames) between frames
attr_reader :loop #Repeat animation or not
attr_writer :playing #if animation is active
attr_writer :moving #if animation is moving
attr_reader :move_speed #animation moving speed
attr_reader :rotate_speed #animation rotating speed
attr_reader :zoom_x
attr_reader :zoom_y
attr_reader :opacity
attr_reader :blend_type
attr_accessor :tone
attr_reader :tone_target
attr_accessor :tone_duration
attr_accessor :angle
#---------------------------------------------------------------
# â— Initialize
#---------------------------------------------------------------
def initialize(number = 0)
@number = number
@name = ""
@width = 0
@height = 0
@frames = 0
@frame_width = 0
@frame_height = 0
@x = 0.0
@y = 0.0
@zoom_x = 100.0
@zoom_y = 100.0
@opacity = 255.0
@blend_type = 0
@duration = 0
@target_x = @x
@target_y = @y
@target_zoom_x = @zoom_x
@target_zoom_y = @zoom_y
@target_opacity = @opacity
@tone = Tone.new(0, 0, 0, 0)
@tone_target = Tone.new(0, 0, 0, 0)
@tone_duration = 0
@angle = 0
@rotate_speed = 0
@playing = true
@loop = true
@delay = 0
end
#---------------------------------------------------------------
# â— Display
#---------------------------------------------------------------
def display(name, x = 0, y = 0, delay = 5, loop = true, zoom_x = 100.0, zoom_y = 100.0, opacity = 255, blend_type = 0)
self.name = name
@frames = @frame_width * @frame_height
if x != 0
@x = x.to_f
end
if y != 0
@y = y.to_f
end
@delay = delay
@loop = loop
@zoom_x = zoom_x.to_f
@zoom_y = zoom_y.to_f
@opacity = opacity.to_f
@blend_type = blend_type
@duration = 0
@target_x = @x
@target_y = @y
@target_zoom_x = @zoom_x
@target_zoom_y = @zoom_y
@target_opacity = @opacity
@tone = Tone.new(0, 0, 0, 0)
@tone_target = Tone.new(0, 0, 0, 0)
@tone_duration = 0
@angle = 0
@rotate_speed = 0
end
#---------------------------------------------------------------
# â— Move
#---------------------------------------------------------------
def move(x, y, speed = 1)
@target_x = x
@target_y = y
@move_speed = speed
@moving = true
end
#---------------------------------------------------------------
# â— Animation Dimensions
#---------------------------------------------------------------
def animation_dimensions(name)
@frame_width, @frame_height = 0
for y in 1..100
for x in 1..100
if File.exists?("Graphics/Animations/" + name + " w_" + x.to_s + " h_" + y.to_s + ".png")
@frame_width, @frame_height = x, y
return true
end
break if File.exists?("Graphics/Animations/" + name + " w_" + x.to_s + " h_" + y.to_s + ".png")
end
break if File.exists?("Graphics/Animations/" + name + " w_" + x.to_s + " h_" + y.to_s + ".png")
end
return false
end
#---------------------------------------------------------------
# â— Name=
#---------------------------------------------------------------
def name=(name)
exist = self.animation_dimensions(name)
if exist
@name = name + " w_" + @frame_width.to_s + " h_" + @frame_height.to_s
bitmap = RPG::Cache.animation(@name, 0)
@width = bitmap.width / @frame_width
@height = bitmap.height / @frame_height
else
print "Animation file \"" + name + "\" does not exist!"
@name = ""
end
end
#---------------------------------------------------------------
# â— Rotate
#---------------------------------------------------------------
def rotate(speed)
@rotate_speed = speed
if speed > 0
@rotating = true
else
@rotating = false
end
end
#---------------------------------------------------------------
# â— Start Tone Change
#---------------------------------------------------------------
def start_tone_change(tone, duration)
@tone_target = tone.clone
@tone_duration = duration
if @tone_duration == 0
@tone = @tone_target.clone
end
end
#---------------------------------------------------------------
# â— Dispose
#---------------------------------------------------------------
def dispose
@name = ""
end
#---------------------------------------------------------------
# â— Playing?
#---------------------------------------------------------------
def playing?
return @playing
end
#---------------------------------------------------------------
# â— Moving?
#---------------------------------------------------------------
def moving?
return @moving
end
def rotating?
return @rotating
end
end
Code:
#==============================================================================
# ** Sprite Animation Written by Baskinein
#------------------------------------------------------------------------------
# Pulls info from a Game_Animation object and displays it on the screen.
#==============================================================================
class Sprite_Animation < RPG::Sprite
#---------------------------------------------------------------
# â— Initialize
#---------------------------------------------------------------
def initialize(viewport, animation)
super(viewport)
@animation = animation
@frame_count = Graphics.frame_count
@move_count = Graphics.frame_count
@frame_current = 0
update
end
#---------------------------------------------------------------
# â— Dispose
#---------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
self.visible = false
super
end
#---------------------------------------------------------------
# â— Update
#---------------------------------------------------------------
def update
super
if @animation_name != @animation.name
@animation_name = @animation.name
if @animation_name != ""
self.bitmap = RPG::Cache.animation(@animation_name, 0)
end
end
if @animation_name == ""
self.visible = false
return
end
update_move
update_rotate
update_tone
if self.bitmap != nil and @animation.playing? and refresh?
y = @animation.height * (@frame_current / @animation.frame_width)
x = @animation.width * (@frame_current - ((@frame_current / @animation.frame_width) * @animation.frame_width))
self.src_rect = Rect.new(x, y, @animation.width, @animation.height)
@frame_current += 1
if @frame_current == (@animation.frames - 1) and !@animation.loop
@animation.playing = false
@animation.dispose
end
@frame_current %= @animation.frames
end
if self.src_rect.width != @animation.width
self.visible = false
else
self.visible = true
end
self.x = @animation.x
self.y = @animation.y
self.ox = @animation.width / 2
self.oy = @animation.height / 2
self.z = @animation.number
self.zoom_x = @animation.zoom_x / 100.0
self.zoom_y = @animation.zoom_y / 100.0
self.opacity = @animation.opacity
self.blend_type = @animation.blend_type
self.angle = @animation.angle
self.tone = @animation.tone
end
#---------------------------------------------------------------
# â— Update Move
#---------------------------------------------------------------
def update_move
return if !@animation.moving?
if @animation.move_speed == 0
distance = 1
else
distance = @animation.move_speed
end
if @animation.x > @animation.target_x
@animation.x -= distance
end
if @animation.x < @animation.target_x
@animation.x += distance
end
if @animation.y > @animation.target_y
@animation.y -= distance
end
if @animation.y < @animation.target_y
@animation.y += distance
end
if @animation.move_speed > 1
if (@animation.target_x - @animation.x).abs <= @animation.move_speed and ((@animation.target_x - @animation.x).abs % @animation.move_speed) != 0
@animation.x = @animation.target_x
end
if (@animation.target_y - @animation.y).abs <= @animation.move_speed and ((@animation.target_y - @animation.y).abs % @animation.move_speed) != 0
@animation.y = @animation.target_y
end
end
if @animation.x == @animation.target_x and @animation.y == @animation.target_y
@animation.moving = false
end
end
#---------------------------------------------------------------
# â— Update Rotate
#---------------------------------------------------------------
def update_rotate
if @animation.rotate_speed != 0
@animation.angle += @animation.rotate_speed / 2.0
while @animation.angle < 0
@animation.angle += 360
end
@animation.angle %= 360
end
end
#---------------------------------------------------------------
# â— Update Tone
#---------------------------------------------------------------
def update_tone
if @animation.tone_duration >= 1
d = @animation.tone_duration
@animation.tone.red = (@animation.tone.red * (d - 1) + @animation.tone_target.red) / d
@animation.tone.green = (@animation.tone.green * (d - 1) + @animation.tone_target.green) / d
@animation.tone.blue = (@animation.tone.blue * (d - 1) + @animation.tone_target.blue) / d
@animation.tone.gray = (@animation.tone.gray * (d - 1) + @animation.tone_target.gray) / d
@animation.tone_duration -= 1
end
end
#---------------------------------------------------------------
# â— Refresh?
#---------------------------------------------------------------
def refresh?
if (Graphics.frame_count - @frame_count >= @animation.delay)
@frame_count = Graphics.frame_count
return true
end
return false
end
end
Code:
class Game_Screen
attr_reader :animations # EDIT
def initialize
@animations = [nil] # EDIT
for i in 1..20
@animations.push(Game_Animation.new(i))# Creates Animation objects
end # EDIT END
end
Code:
class Spriteset_Map
def initialize
@viewport4 = Viewport.new(0, 0, 640, 480) # EDIT START
@viewport4.z = 300 # EDIT END
@animated_sprites = [] # EDIT START
for i in 1..20
@animated_sprites.push(Sprite_Animation.new(@viewport4, $game_screen.animations[i]))
end # EDIT END
end
def dispose
for sprite in @animated_sprites # EDIT START
sprite.dispose
end # EDIT END
@viewport4.dispose # EDIT
end
def update
for sprite in @animated_sprites # EDIT START
sprite.update
end # EDIT END
@viewport4.update # EDIT
end
end
Ok so the problem with the first script is that when i define a key and set it to something
Code:
if Kboard.keyb($R_Key_RETURN) == 1
$scene = Scene_Status.new
return
end
The problem with the second set of scripts is that whenever i run it it either says there's no file by that name which there is or it says the scrpit is hanging