-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRS_ItemTempStorage.rb
53 lines (43 loc) · 1.41 KB
/
RS_ItemTempStorage.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#================================================================
# The MIT License
# Copyright (c) 2020 biud436
# ---------------------------------------------------------------
# Free for commercial and non commercial use.
#================================================================
#==============================================================================
# Name : RS_ItemTempStorage
# Desc :
# This script allows you to save or restore all items using simple commands.
# Author : biud436
# Usage :
# 저장
# $game_party.save_all_items
# 복구
# $game_party.restore_all_items
#==============================================================================
$imported = {} if $imported.nil?
$imported["RS_ItemTempStorage"] = true
class Game_Party
def save_all_items
# 아이템 해시를 직렬화합니다.
@temp_storage = [
Marshal.dump(@items),
Marshal.dump(@weapons),
Marshal.dump(@armors)
]
# 아이템을 비웁니다.
@items = {}
@weapons = {}
@armors = {}
end
def restore_all_items
# 직렬화 데이터가 없으면 반환
return if not @temp_storage
# 아이템 데이터를 역직렬화하여 복구합니다.
@items = Marshal.load(@temp_storage[0])
@weapons = Marshal.load(@temp_storage[1])
@armors = Marshal.load(@temp_storage[2])
# 메모리를 비웁니다.
@temp_storage = nil
end
end