Project1
标题:
【vx】事件中编辑数据库备注栏
[打印本页]
作者:
企鹅达达
时间:
2010-11-17 01:15
标题:
【vx】事件中编辑数据库备注栏
本帖最后由 企鹅达达 于 2010-11-17 01:15 编辑
许多脚本会用到数据库的备注栏,我们会想有些时候那些脚本不要起作用,一定时间过后再生效。那么,我们可以用到以下脚本:
p.s.使用方法自己查牛津词典 =.= 注意备注那的斜杠写法和不要漏了双引号……
#==============================================================================
# Note Editor
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: December 16, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to edit the note field of an item with script calls
# in-game. This is useful for editing features of other scripts that use the
# note field for adding features; this will allow you to add those features
# as part of the gameplay. The edits will only apply within the same game
# file, so the note field will be clean whenever the player starts a new
# game. It does not overwrite the regular note field - anything written in
# note field in the database will be permanent in every save file.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into the editor below the default scripts but above Main
#
# To use this script, simply use these codes in a call script:
#
# add_note (type, id, note)
# type : refers to the database tab you want to change the notes of.
# It is an integer, and broke down like this:
# 0 => Item
# 1 => Weapon
# 2 => Armor
# 3 => Skill
# 4 => Enemy
# 5 => State
# id : the specific ID of the particular item, weapon, armor, skill,
# enemy, or state you want to edit the note field of.
# note : this is the string that you want to add to the note field.
# delete_note (type, id, note)
# type : same as for add_note
# id : same as for add_note
# note : this is the note you want to delete. It can be either the
# string itself, or it can be an integer if (and onlt if) you
# know the order it was added in - if you put in the integer 2
# here, it will delete the third string you added to the item's
# note.
#
# delete_note will only delete notes that have been added to the note field
# in-game - it will not delete notes you set in the database directly.
#
# EXAMPLES:
# add_note (0, 1, "new \\ note")
# This would add "new \ note" to the note field of a potion (first item)
# add_note (4, 6, "Default wisp")
# This would add "Default wisp" to the note field of the sixth enemy in
# the database (coincidentally a willowisp by default)
# delete_note (2, 45, "\\CG[Evil, 5]")
# This would delete the note "\CG[Evil, 5]" from the note field of the
# 45th weapon in the database if it had been added in-game through the
# add_note script. It would not delete it if you set it in the database
# itself.
#==============================================================================
module RPG
#==============================================================================
# ** RPG::BaseItem
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - note
#==============================================================================
class BaseItem
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Return Note
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malgb_acigd_ntedit_7jb3 note
def note (*args)
type = case self
when RPG::Item then 0
when RPG::Weapon then 1
when RPG::Armor then 2
when RPG::Skill then 3
end
# Return Original Method + edited additions
return malgb_acigd_ntedit_7jb3 (*args) + $game_system.ma_added_notes(type, self.id)
end
end
#==============================================================================
# ** RPG::Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - note
#==============================================================================
class Enemy
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Return Note
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias ma_asciigod_noteedit_enmy_5hv2 note
def note (*args)
# Return Original Method + edited additions
return ma_asciigod_noteedit_enmy_5hv2 (*args) + $game_system.ma_added_notes(4, self.id)
end
end
#==============================================================================
# ** RPG::State
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - note
#==============================================================================
class State
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Return Note
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_gdasci_nted_stte_4xs2 note
def note (*args)
# Return Original Method + edited additions
return modalg_gdasci_nted_stte_4xs2 (*args) + $game_system.ma_added_notes(5, self.id)
end
end
end
#==============================================================================
# ** Game System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new instance variable - ma_note_edits
# aliased method - initialize
# new method - ma_add_note, ma_delete_note
#==============================================================================
class Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modabra_ascod_init_ntedtr_8nn2 initialize
def initialize (*args)
@ma_note_edits = [ {}, {}, {}, {}, {}, {} ]
# Run Original Method
modabra_ascod_init_ntedtr_8nn2 (*args)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Add Note
# type : the type of item (Item, Weapon, Armor, Skill, State, Enemy)
# id : the ID of the specific item in its type
# note : the note you want to add
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_add_note (type, id, note)
@ma_note_edits[type][id] = [] if @ma_note_edits[type][id] == nil
@ma_note_edits[type][id].push (note)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Delete Note
# type : the type of item (Item, Weapon, Armor, Skill, State, Enemy)
# id : the ID of the specific item in its type
# note : the note you want to delete
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_delete_note (type, id, note)
@ma_note_edits[type][id] = [] if @ma_note_edits[type][id] == nil
note.is_a? (String) ? @ma_note_edits[type][id].delete (note) : @ma_note_edits[type][id].delete_at (note)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Added Notes
#``````````````````````````````````````````````````````````````````````````
# Returns the notes added to that item
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_added_notes (type, id)
return "" if @ma_note_edits[type][id] == nil
note_string = ""
@ma_note_edits[type][id].each { |note| note_string += "\n #{note}" }
return note_string
end
end
#==============================================================================
# ** Game Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - add_note, delete_note
#==============================================================================
class Game_Interpreter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Add Note
# type : the type of item (Item, Weapon, Armor, Skill, State, Enemy)
# id : the ID of the specific item in its type
# note : the note you want to add
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def add_note (type, id, note)
$game_system.ma_add_note (type, id, note)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Delete Note
# type : the type of item (Item, Weapon, Armor, Skill, State, Enemy)
# id : the ID of the specific item in its type
# note : the note you want to delete
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def delete_note (type, id, note)
$game_system.ma_delete_note (type, id, note)
end
end
复制代码
作者:
lwdx0822
时间:
2010-11-17 22:28
范例~~~范例~~~
虽然我不想当伸手党~~~
可是没有范例~~~作为小白的我·~~~好难搞明白啊~。。。
被LZ PIA 飞·~~~~
作者:
px.凤翔九天
时间:
2010-11-17 22:36
本帖最后由 px.凤翔九天 于 2010-11-17 22:36 编辑
范例?貌似楼主没有啊...这个英文不难啊,但是我想问的是这个是从哪里搞来的...居然是英文的。LZ的英语实力我猜测不低,但是其他人呢...所以需要翻译的话大家说一下,我就把说明翻译一下,要是少于1个说需要翻译就算了吧....
需要翻译的部分请直接在此贴“点评”中写出。
作者:
懒De说
时间:
2010-11-18 12:34
为什么不发到VX区呢
作者:
企鹅达达
时间:
2010-11-18 15:28
回复
懒De说
的帖子
因为版规,因为非原创非讨论,而且是外国的,所以放到地球村。当然,本鹅不介意阁下把这东西放去那里,毕竟很实用。如果阁下转区,我会加上转载字样的 =.=
作者:
企鹅达达
时间:
2010-11-18 15:37
回复
lwdx0822
的帖子
add_note (0, 1, "new \\ note")、delete_note (2, 45, "\\CG[Evil, 5]"),作为新手,会在事件脚本中增加上面两句话就可以。
作者:
lwdx0822
时间:
2010-11-18 22:41
回复
企鹅达达
的帖子
求解你的那俩句话是什么意思~~~起什么作用。。。
我正在学习~。。。。所以~~~呵呵~~~
请LZ明解
作者:
精灵使者
时间:
2010-11-22 10:15
明白了,这个脚本会配合以备注判定的事件脚本混合使用……么?
作者:
企鹅达达
时间:
2010-11-22 10:44
本帖最后由 精灵使者 于 2010-11-22 11:44 编辑
回复
精灵使者
的帖子
你可以试一下,毕竟我没有见过可以判定数据库备注的脚本。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1