點選上方RGSS圖示返回。


 

商店實現只能買不能賣或只能賣不能買的特殊功能

1.請在腳本開頭SHOPVAR = X修改X的值(特殊變數的編號)
本例變數100號=1時只能買入,變數100號=2時只能賣出,變數100號=其他值則為正常買賣

2.請將下列內容貼在腳本Main之前

# 設定特殊變數為100號
SHOPVAR = 100
class Window_ShopCommand < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化目標
#--------------------------------------------------------------------------
def initialize
super(0, 64, 480, 64)
self.contents = Bitmap.new(width - 32, height - 32)
# 根據指定變數設置參數
case $game_variables[SHOPVAR]
when 1
max = 2
commands = ["買入", "取消"]
when 2
max = 2
commands = ["賣出", "取消"]
else
max = 3
commands = ["買入", "賣出", "取消"]
end
@item_max = max
@column_max = max
@commands = commands
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 描繪項目
# index : 項目編號
#--------------------------------------------------------------------------
def draw_item(index)
ch = 448/@item_max
x = ch * index
self.contents.draw_text(x, 0, ch, 32, @commands[index],1)
end
end
class Scene_Shop
#--------------------------------------------------------------------------
# ● 更新畫面 (指令視窗啟動的情況下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 鍵的情況下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切換到地圖畫面
$scene = Scene_Map.new
return
end
# 根據指定變數設置參數
case $game_variables[SHOPVAR]
when 1
a,b,c = 0,-10,1
when 2
a,b,c = -10,0,1
else
a,b,c = 0,1,2
end
# 按下 C 鍵的情況下
if Input.trigger?(Input::C)
# 命令視窗游標位置分歧
case @command_window.index
when a # 購買
# 演奏確定 SE
$game_system.se_play($data_system.decision_se)
# 視窗狀態轉向購買模式
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
when b # 賣出
# 演奏確定 SE
$game_system.se_play($data_system.decision_se)
# 視窗狀態轉向賣出模式
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
when c # 取消
# 演奏確定 SE
$game_system.se_play($data_system.decision_se)
# 切換到地圖畫面
$scene = Scene_Map.new
end
return
end
end
end

 

   

inserted by FC2 system