This is a utility script that provides the functionality to return inputs
from the keyboard as well as free up more keys to be used in the Input module.
This script will also replace Scene_Name and allow for direct keyboard input
to type in an actor's name as well as fix the maximum characters shown from
the default base script.
Screenshot:
Spoiler:
Skrypt:
Spoiler:
Kod:
#===============================================================================
#
# OriginalWij and Yanfly Collaboration - Keyboard Input
# Last Date Updated: 2010.06.12
# Level: Normal
#
# This is a utility script that provides the functionality to return inputs
# from the keyboard as well as free up more keys to be used in the Input module.
# This script will also replace Scene_Name and allow for direct keyboard input
# to type in an actor's name as well as fix the maximum characters shown from
# the default base script.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 2010.06.12 - Started and Finished Script.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below Materials but above Main. Remember to save.
#
# For users:
# The Name Input event has been now replaced. It not longer takes you to the
# name entry scene, but instead, allows the player to enter in the name of
# the desired actor right in the current screen itself without needing to
# change the scene altogether.
#
# For scripters:
# For those curious as to how to retrieve certain letters while coding their
# Input commands, use the following as reference
#
# LETTERS['A'] through LETTERS['Z']
# This returns true if the respective letter from A through Z is pressed.
#
# NUMBERS[0] through NUMBERS[9]
# This returns true if the respective number on the top row of the keyboard
# is pressed. This does not include the numberpad.
#
# NUMPAD[0] through NUMPAD[9]
# This returns true if the respective number in the number pad is pressed.
# This does not include the numbers found at the top row of the keyboard.
#
# Symbol Keys
#
# USCORE - This returns true if the - key is pressed.
# EQUALS - This returns true if the = key is pressed.
# SCOLON - This returns true if the ; key is pressed.
# QUOTE - This returns true if the ' key is pressed.
# COMMA - This returns true if the , key is pressed.
# PERIOD - This returns true if the . key is pressed.
# SLASH - This returns true if the / key is pressed.
# BSLASH - This returns true if the \ key is pressed.
# LBRACE - This returns true if the [ key is pressed.
# RBRACE - This returns true if the ] key is pressed.
# TILDE - This returns true if the ~ key is pressed.
#
# Command Keys
#
# BACK - This returns true if the backspace key is pressed.
# ENTER - This returns true if the enter/return key is pressed.
# SPACE - This returns true if the space bar is pressed.
# ESC - This returns true if the escape key is pressed.
#
# Module Methods
#
# Input.typing?
# To check if typing is occurring. Returns true or false.
#
# Input.key_type
# Returns whatever key is being used to type as a string.
#
# Example:
#
# if Input.typing?
# string = Input.key_type
# end
#
#===============================================================================
$imported = {} if $imported == nil
$imported["KeyboardInput"] = true
#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================
class << Input
#--------------------------------------------------------------------------
# Aliases (Mods - Linked to Module) - Created by OriginalWij
#--------------------------------------------------------------------------
alias ow_dt_i_press press? unless $@
alias ow_dt_i_trigger trigger? unless $@
alias ow_dt_i_repeat repeat? unless $@
alias ow_dt_i_update update unless $@
end
#--------------------------------------------------------------------------
# initial module settings - Created by OriginalWij and Yanfly
#--------------------------------------------------------------------------
GetKeyState = Win32API.new("user32", "GetAsyncKeyState", "i", "i")
GetCapState = Win32API.new("user32", "GetKeyState", "i", "i")
KeyRepeatCounter = {}
module_function
#--------------------------------------------------------------------------
# alias method: update - Created by OriginalWij
#--------------------------------------------------------------------------
def update
ow_dt_i_update
for key in KeyRepeatCounter.keys
if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
KeyRepeatCounter[key] += 1
else
KeyRepeatCounter.delete(key)
end
end
end
#--------------------------------------------------------------------------
# alias method: press? - Created by OriginalWij
#--------------------------------------------------------------------------
def press?(key)
return ow_dt_i_press(key) if key < 30
adjusted_key = adjust_key(key)
return true unless KeyRepeatCounter[adjusted_key].nil?
return key_pressed?(adjusted_key)
end
#--------------------------------------------------------------------------
# alias method: trigger? - Created by OriginalWij
#--------------------------------------------------------------------------
def trigger?(key)
return ow_dt_i_trigger(key) if key < 30
adjusted_key = adjust_key(key)
count = KeyRepeatCounter[adjusted_key]
return ((count == 0) or (count.nil? ? key_pressed?(adjusted_key) : false))
end
#--------------------------------------------------------------------------
# alias method: repeat? - Created by OriginalWij
#--------------------------------------------------------------------------
def repeat?(key)
return ow_dt_i_repeat(key) if key < 30
adjusted_key = adjust_key(key)
count = KeyRepeatCounter[adjusted_key]
return true if count == 0
if count.nil?
return key_pressed?(adjusted_key)
else
return (count >= 23 and (count - 23) % 6 == 0)
end
end
#--------------------------------------------------------------------------
# new method: adjust_key - Created by OriginalWij
#--------------------------------------------------------------------------
def adjust_key(key)
key -= 130 if key.between?(130, 158)
return key
end
#--------------------------------------------------------------------------
# new method: key_pressed? - Created by OriginalWij
#--------------------------------------------------------------------------
def key_pressed?(key)
if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
KeyRepeatCounter[key] = 0
return true
end
return false
end
#--------------------------------------------------------------------------
# new method: typing? - Created by Yanfly
#--------------------------------------------------------------------------
def typing?
return true if repeat?(SPACE)
for i in 'A'..'Z'
return true if repeat?(LETTERS[i])
end
for i in 0...NUMBERS.size
return true if repeat?(NUMBERS[i])
return true if repeat?(NUMPAD[i])
end
for key in Extras
return true if repeat?(key)
end
return false
end
#--------------------------------------------------------------------------
# new method: key_type - Created by Yanfly
#--------------------------------------------------------------------------
def key_type
return " " if repeat?(SPACE)
for i in 'A'..'Z'
next unless repeat?(LETTERS[i])
return upcase? ? i.upcase : i.downcase
end
for i in 0...NUMBERS.size
return i.to_s if repeat?(NUMPAD[i])
if !press?(SHIFT)
return i.to_s if repeat?(NUMBERS[i])
elsif repeat?(NUMBERS[i])
case i
when 1; return "!"
when 2; return "@"
when 3; return "#"
when 4; return "$"
when 5; return "%"
when 6; return "^"
when 7; return "&"
when 8; return "*"
when 9; return "("
when 0; return ")"
end
end
end
for key in Extras
next unless repeat?(key)
case key
when USCORE; return press?(SHIFT) ? "_" : "-"
when EQUALS; return press?(SHIFT) ? "+" : "="
when LBRACE; return press?(SHIFT) ? "{" : "["
when RBRACE; return press?(SHIFT) ? "}" : "]"
when BSLASH; return press?(SHIFT) ? "|" : "\\"
when SCOLON; return press?(SHIFT) ? ":" : ";"
when QUOTE; return press?(SHIFT) ? '"' : "'"
when COMMA; return press?(SHIFT) ? "<" : ","
when PERIOD; return press?(SHIFT) ? ">" : "."
when SLASH; return press?(SHIFT) ? "?" : "/"
when NMUL; return "*"
when NPLUS; return "+"
when NSEP; return ","
when NMINUS; return "-"
when NDECI; return "."
when NDIV; return "/"
end
end
return ""
end
#--------------------------------------------------------------------------
# new method: upcase? - Created by Yanfly
#--------------------------------------------------------------------------
def upcase?
return !press?(SHIFT) if GetCapState.call(CAPS) == 1
return true if press?(SHIFT)
return false
end
#===============================================================================
#
# END OF FILE
#
#===============================================================================
PS Najważniejsze jest okienko na górze z awatarem. xD Dół jest zrobiony zdarzeniami. :D
Nie musicie konfigurować skryptu, ponieważ to nie wymaga konfiguracji... :)Mantiq - Czw 07 Lip, 2011 20:49 Taki skrypt już chyba istnieje.
Cytat:
Opis: (Nauczcie się Angielskiego xD)
CreeperCrisis - Czw 07 Lip, 2011 21:23 Tak istnieje, ale to wersja prostrza i stworzona przez Yanfly...
...a z tym Angielskim to tylko tak napisałem, a takich jak ty to nie powinno być na forum gdyż to nie było na temat skryptu. x2
PS ...a żebyście nie powariowali aferą z Angielskim ( ) to może wam to przetłumaczę w skrócie:
To jest skrypt, który podmienia Scene_Name (czyli klasę, gdzie się podstawia imię) na zmianę imienia poprzez wpisywanie tego klawiaturą i większą ilością znaków takich jak (!, @, #, $, % i inne)...Unnamed - Czw 07 Lip, 2011 22:07
Cytat:
Opis: (Nauczcie się Angielskiego xD)
Cytat:
This is a utility script that provides the functionality to return inputs
from the keyboard as well as free up more keys to be used in the Input module.
This script will also replace Scene_Name and allow for direct keyboard input
to type in an actor's name as well as fix the maximum characters shown from
the default base script.
skoro wystawiasz cos na polskim forum to tlumacz to na polski a nie zgrywasz cwaniaka
sry za offCreeperCrisis - Pią 08 Lip, 2011 13:27 Nie jestem cwaniakiem... xD Tak sobie napisałem... :D ...chociaż się cieszcie, że przetłumaczyłem. :)