Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RGSS1 pop-up แสดงไอเทมที่ได้รับขึ้นมาบนจอ
#1
Me gusta

สคริปนี้โดยคุณ siliconHero จากเวบ rmxp.net ได้ถูกเอามาปรับปรุงโดย AgentMolder ให้ใส่รูปไอเทม และให้แสดงเงิน และเพิ่มภาษาไทยเข้าไป

ทำตามขั้นตอน

1.สร้าง script ใหม่ เหนือ main ใส่ชื่ออะไรก็ได้
2. copy script ข้างล่างไปแปะให้หมด

Quote:#==============================================================================
# ** Window_ItemAcquired By SiliconHero@rmxp.net
# Original Ver at Topic >> http://www.rmxp.net/forums/index.php?showtopic=24022
#------------------------------------------------------------------------------
#ปรับปรุงโดย AgentMolder
#วิธีใช้งาน ใน event ที่ได้รับ item ให้เรียกใช้คำสั่ง call script(เรียกใช้สคริป) แล้วพิมพ์บรรทัดด้านล่างลงไป
# Window_ItemAcquired.new(quantity, type, index)
#โดยค่าต่างๆ ตามนี้
# quantity = จำนวน item (หรือ จำนวนเงิน)
# type = ชนิดของ item ที่ได้รับ (1 = item, 2 = weapon, 3 = armor, 4 = เงิน)
# index = ตัวเลขแทน item (ดูได้จาก database โดยไม่ต้องใส่ 0 ด้านหน้า)
# **ถ้าเป็นจำนวนเงิน ให้ใส่ index เป็น 0
#==============================================================================
class Window_Base
def draw_a_name(item,x,y)
if item == nil
return
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x,y,bitmap, Rect.new(0,0,24, 24))
self.contents.font.color = crisis_color
self.contents.draw_text(x+28,y, 220, 32, item.name + " " + @quantity.to_s + " ชิ้น")
end
end

class Window_ItemAcquired < Window_Base
def initialize(quantity, type, index)
super(120, 200,450, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@quantity = quantity
@type = type
@index = index
self.pause = false
self.back_opacity = 127
self.contents.font.color = crisis_color
Audio.se_play("Audio/SE/056-Right02.ogg", 100, 100)
self.pause = true
while not Input.trigger?(Input::C)
Input.update
Graphics.update
self.contents.clear
case @type
# type: 1 = item, 2 = weapon, 3 = armor ,4 = เงิน
when 1
item = $data_items[@index]
self.contents.draw_text(4, 0, self.width - 40, 32, "ท่านได้รับ", 0)
draw_a_name(item,100,0)
when 2
item = $data_weapons[@index]
self.contents.draw_text(4, 0, self.width - 40, 32, "ท่านได้รับ", 0)
draw_a_name(item,100,0)
when 3
item = $data_armors[@index]
self.contents.draw_text(4, 0, self.width - 40, 32, "ท่านได้รับ", 0)
draw_a_name(item,100,0)
when 4
text = "ท่านได้รับ เงิน " + @quantity.to_s + " " + $data_system.words.gold
self.contents.draw_text(4, 0, self.width - 40, 32, text, 1)
end
end
self.dispose
end
end

วิธีใช้งาน
1. ใน event ที่เราต้องการแสดงผล เช่นหีบ หรือคุยกับคน หรืออะไรก็ตาม พอหีบเปิด หรือได้รับของดังกล่าว หรือตอนที่เราต้องการโชว์ของ ก็ให้เลือก "เรียกใช้สคริปต์" (อยู่ในหน้า event หน้าที่ 3 ตัวสุดท้าย)
2.พิมพิ์ว่า
Window_ItemAcquired.new(quantity, type, index)
โดย
-quantity = จำนวน item (หรือ จำนวนเงิน)
-type = ชนิดของ item ที่ได้รับ (1 = item, 2 = weapon, 3 = armor, 4 = เงิน)
-index = ตัวเลขแทน item (ดูได้จาก database โดยไม่ต้องใส่ 0 ด้านหน้า)
**ถ้าเป็นจำนวนเงิน ให้ใส่ index เป็น 0
เช่น เราต้องการให้เปิดหีบแล้วได้ item Potion จำนวน 2 ชิ้น ก็ให้ใส่ดังนี้

Quote:Window_ItemAcquired.new(2, 1, 1)

2 คือจำนวน potion ที่ได้รับ
1 แสดงถึงสิ่งนั้นเป็น item
1 แสดงถึง ไอเทม Potion ที่อยู่ในลำดับที่ 1 ใน database

หรือ เราต้องการให้ได้เงิน 100 ก็ใส่ไปว่า
Quote:Window_ItemAcquired.new(100,4,0)

ลองเอาไปใช้ดูนะครับ

Credit : siliconHero, AgentMolder
[Image: webboard%20signature1_zpskhtut2jg.png]
การทำอาหารที่อร่อยที่สุด และเดือดร้อนชาวบ้านมากที่สุด กำลังจะเริ่มขึ้น
[-] The following 5 users say Thank You to Mysticphoenix for this post:
  • [IRPG] bassza123, hengmana, jojo741963, LuZi, Shinryu
Reply
#2
ตัวนี้ใช้อยู่ๆ ใช้ง่ายมาก

แต่เสียดายไม่ได้เพิ่มไอเทมในตัวสคริป ต้องใช้คำสั่งเพิ่มเอาเอง
[Image: 7f7cb68ce0.png][Image: rlogo.png]
Show ContentSpoiler:
Reply
#3
การทำให้ pop up แบบอัตโนมัติ ผมใช้วิธีนี้อยู่นะ

$game_variables[66] เป็นตัวแปรอเนกประสงค์ใช้นับจำนวน
$game_switches[72] บ่งบอกว่าจะมีการเพิ่มไอเทมเกิดขึ้น
$game_switches[71] บ่งบอกว่าจะมีการเพิ่มอาวุธเกิดขึ้น
$game_switches[73] บ่งบอกว่าจะมีการเพิ่มชุดเกราะเกิดขึ้น
$game_switches[1] เปิดปิดโหมด pop up (บางทีเราอยากแอบเพิ่มไอเทมโดยไม่ทำให้ pop up)

การทำงานคือ เมื่อมีการเพิ่มไอเทม ตัวแปร 66 และสวิตช์(71หรือ72หรือ73) จะเปิด สั่ง parallel comment event ให้ทำงาน เรียกสคริป pop up จ้า สวิตช์1 จะทำให้เราควบคุมได้ว่าจะให้ pop up หรือเปล่า


[Image: itempop1.png]
[Image: itempopup2.png]
[Image: itempopup3.png]
[Image: itempopup4.png]
[Image: itempop6.png]

@parameter[0], @parameter[1] ควรคงไว้อย่างเดิม อย่าไปยุ่งมัน
[Image: webboard%20signature1_zpskhtut2jg.png]
การทำอาหารที่อร่อยที่สุด และเดือดร้อนชาวบ้านมากที่สุด กำลังจะเริ่มขึ้น
[-] The following 1 user says Thank You to Mysticphoenix for this post:
  • Shinryu
Reply
#4
ลองเขียน ในกรอบแดงใหม่ ไม่ต้องใส่เหตุการณ์ทั่วไป
ใช้คำสั่งเหตุการณ์ เพิ่มลดไอเทมเอา มันจะเด้งหน้าต่างแสดงไอเทมที่ได้รับขึ้นมาบนจอให้เลย
ไม่รู้ว่าจะมีบั๊กมั้ย ;w;

ไอเทม # def command_126
Code:
if $game_switches[1] == false && @parameters[1] == 0
Window_Item_Acquired.new(@parameters[3], 1, @parameters[0])
and
$game_switches[1] = false

อาวุธ # def command_127
Code:
if $game_switches[1] == false && @parameters[1] == 0
Window_Item_Acquired.new(@parameters[3], 2, @parameters[0])
and
$game_switches[1] = false

ชุดเกราะ # def command_128
Code:
if $game_switches[1] == false && @parameters[1] == 0
Window_Item_Acquired.new(@parameters[3], 3, @parameters[0])
and
$game_switches[1] = false

เงิน # def command_125 วางคล้ายๆกัน
Code:
if $game_switches[1] == false && @parameters[1] == 0
Window_Item_Acquired.new(@parameters[2], 4, 0)
and
$game_switches[1] = false

ถ้าเปิด $game_switches[1]  จะปิดโหมด pop up ครั้งเดียว #
[-] The following 2 users say Thank You to hengmana for this post:
  • jojo741963, Mysticphoenix
Reply
#5
ขอบคุณครับ
Reply
#6
เพิ่มเติม ถ้ากดCเร็วไป อาจมองไม่ทัน อยากให้ทิ้งช่วงไว้ให้ปรับแก่ตรง
Quote:while not Input.trigger?(Input::C)
Input.update
Graphics.update
เป็น
Quote:(0..200).each {|i| [Graphics,Input].each {|s| s.update}


และแก้ล่างๆตรง
Quote:end
self.dispose
เป็น
Quote:break if Input.trigger?(Input::C) && i > 50 || i == 200}
self.dispose

ทำให้ทิ้งช่วงมากกว่า 50 เฟรม (1.25 วิ) จึงจะกดCยกเลิกได้ หริอ
ถ้าทิ้งไว้ 200 เฟรม (5 วิ) ไม่ได้กดCยกเลิก มันจะหายไปเอง
[-] The following 2 users say Thank You to hengmana for this post:
  • jojo741963, Mysticphoenix
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)