Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
#============================================================================== # # "Persistent Map Events" # Version 2.0 # Last Update: September 9th, 2013 # Author: DerTraveler (dertraveler [at] gmail.com) # #============================================================================== # # Description: # # Adds the possibility to make map events persistent between map and/or page # changes. That means that you can leave a map (change a page) and when you # return it will be in the exact same state as last time. # This includes following properties: # - position # - direction # - position in the current move route # - changes to the events appearance by the "Set Move Route..." command # - changes to the movement style (speed, frequency) by the "Set Move Route..." # command # - execution progress of parallel events # # It is also possible to only make some of these properties persistents by # using notetags on event pages. # # NOTE #1: Autostart events are NEVER saved. # # NOTE #2: All the changes are also included in your save files. Thus, old save # files probably won't be compatible anymore. # # NOTE #3: Even though I don't think that this will be any problem with today's # hardware, you should note that the event data of potentially every # map event the player has met is stored in memory and in your save # files. If you have exceptionally many events in your game, this could # become a problem. # #============================================================================== # # How to use: # # Paste it anywhere in the Materials section. # Be sure to set the default behaviour in the options section. # #------------------------------------------------------------------------------ # Feature: Set persistence of single events pages with comment notetags #------------------------------------------------------------------------------ # If you want to overwrite the standard persistence behaviour of a particular # event page, just add one or more of the following notetags into a Comment-Box. # # <persistence [on/off]> # Activates or deactivates the persistence of this event. If activated the # behaviour is as defined in the standard behaviour configuration. # # <persistent [property 1] ([property 2]...)> # Saves the given properties in addition to the basic behaviour (either # given by configuration or by the persistence-notetag) # # <transient [property 1] ([property 2]...)> # Prevents the given properties from being saved. # This modifies the basic behaviour given by configuration or by the # persistence-notetag. # This also overrides the properties given in a persistent-notetag. # # List of properties: # position - the event position (map change only) # direction - the event direction # move_route - the execution state of the move route # appearance - includes event graphic, transparent flag, opacity and # blending mode # move_style - includes move speed, move frequency, walking animation flag, # stepping animation flag, direction fix flag, through flag # interpreter - the current execution progress of a parallel process event # erase - the erase flag # all - all of the above. # overwrites all other given properties in the notetag. # # #============================================================================== # # Changelog: # 2.0: # - Major rewriting of the script. Added support for page changes. Now the # state of every page is saved separately and will be restored # accordingly. # - Added own notetag code, so the dependency on EST Notetag Grabber was # removed # - Added more notetags, so that only particular properties will be saved # #============================================================================== # # Terms of use: # # - Free to use in any non-commercial project. For use in commercial projects # please mail me. # - Please mail me if you find bugs so I can fix them. # - If you have feature requests, please also mail me, but I can't guarantee # that I will add every requested feature. # - Credit DerTraveler in your project. # #============================================================================== ############################################################################### # OPTIONS ############################################################################### module PersistentMapEvents CONFIG = {} #--------------------------------------------------------------------------- # GLOBAL_PERSISTENCE # Set this to true, if every map event should be persistent by default. #--------------------------------------------------------------------------- CONFIG[:GLOBAL_PERSISTENCE] = false #--------------------------------------------------------------------------- # PERSISTENT_PROPERTIES # The list of properties that should be saved by default. # This list applies when GLOBAL_PERSISTENCE is true and when the notetag # <persistence on> is used. #--------------------------------------------------------------------------- CONFIG[:PERSISTENT_PROPERTIES] = [:position, :direction, :move_route, :appearance, :move_style, :interpreter] end ############################################################################### # # Do not edit past this point, if you have no idea, what you're doing ;) # ############################################################################### module NotetagSupport def any_notetag? !notetags.empty? end def have_notetag?(name, *args) notetags.keys.include?(name) && (args.empty? || args == notetags[name]) end def any_notetag_from?(names) notetags.keys.any? { |k| names.include?(k) } end def notetags result = {} note.scan(/<([^>]+)>/) { |match| args = match[0].split result[args[0]] = args[1..-1] } result end end class Game_Event < Game_Character include NotetagSupport #----------------------------------------------- # new method : note #----------------------------------------------- def note return "" if !@page all_comments = "" @list.each { |command| if command.code == 108 || command.code == 408 all_comments += command.parameters[0] + "\n" end } return all_comments end end #============================================================================== # Game_System #============================================================================== class Game_System attr_accessor :saved_events #----------------------------------------------- # alias method : initialize #----------------------------------------------- alias pme_initialize initialize def initialize pme_initialize @saved_events = {} end end #============================================================================== # Game_Event #============================================================================== class Game_Event < Game_Character ALL_PROPERTIES = [:position, :direction, :move_route, :appearance, :move_style, :interpreter, :erase] attr_accessor :persistent_properties #----------------------------------------------- # overwrite method : clone #----------------------------------------------- def clone result = super() result.instance_variable_set("@interpreter", @interpreter.clone) if @interpreter result end #----------------------------------------------- # new method : page_id #----------------------------------------------- def page_id @event.pages.index(@page) end #----------------------------------------------- # new method : save_state #----------------------------------------------- def save_state @persistent_properties = determine_persistent_properties $game_system.saved_events[[@map_id, @id]] = page_id $game_system.saved_events[[@map_id, @id, page_id]] = self.clone end #----------------------------------------------- # new method : get_saved_state #----------------------------------------------- def get_saved_state pid = $game_system.saved_events[[@map_id, @id]] $game_system.saved_events[[@map_id, @id, pid]] end #----------------------------------------------- # new method : get_saved_page #----------------------------------------------- def get_saved_page $game_system.saved_events[[@map_id, @id, page_id]] end #----------------------------------------------- # new method : has_saved_state? #----------------------------------------------- def has_saved_state? $game_system.saved_events.has_key?([@map_id, @id]) end #----------------------------------------------- # new method : has_saved_page? #----------------------------------------------- def has_saved_page? $game_system.saved_events.has_key?([@map_id, @id, page_id]) end #----------------------------------------------- # new method : persistent? #----------------------------------------------- def persistent?(property) @persistent_properties.include?(property) end def determine_persistent_properties transient = have_notetag?("transient") ? notetags["transient"].map { |p| p.to_sym } : [] return [] if transient.include?(:all) standard = Array.new(PersistentMapEvents::CONFIG[:PERSISTENT_PROPERTIES]) persistent = have_notetag?("persistent") ? notetags["persistent"].map { |p| p.to_sym } : [] if persistent.include?(:all) result = Array.new(ALL_PROPERTIES) else result = ( PersistentMapEvents::CONFIG[:GLOBAL_PERSISTENCE] && !have_notetag?("persistence", "off") ) || have_notetag?("persistence", "on") ? standard : [] result += persistent result.uniq! end return result - transient end def restore_event restored = get_saved_state @persistent_properties = restored.persistent_properties if persistent?(:position) @x = restored.x @y = restored.y @real_x = x @real_y = y @bush_depth = restored.bush_depth end if persistent?(:direction) @direction = restored.direction end if persistent?(:appearance) @tile_id = restored.tile_id @character_name = restored.character_name @character_index = restored.character_index @opacity = restored.opacity @blend_type = restored.blend_type @transparent = restored.transparent end if persistent?(:move_style) @move_speed = restored.move_speed @move_frequency = restored.move_frequency @walk_anime = restored.walk_anime @step_anime = restored.step_anime @direction_fix = restored.direction_fix @through = restored.through end if persistent?(:move_route) @move_route_forcing = restored.move_route_forcing @pattern = restored.pattern @anime_count = restored.instance_variable_get("@anime_count") @stop_count = restored.instance_variable_get("@stop_count") @jump_count = restored.instance_variable_get("@jump_count") @jump_peak = restored.instance_variable_get("@jump_peak") @move_route = restored.instance_variable_get("@move_route") @move_route_index = restored.instance_variable_get("@move_route_index") @original_move_route = restored.instance_variable_get("@original_move_route") @original_move_route_index = restored.instance_variable_get("@original_move_route_index") @wait_count = restored.instance_variable_get("@wait_count") @move_succeed = restored.instance_variable_get("@move_succeed") end if persistent?(:erase) @erased = restored.instance_variable_get("@erased") end refresh end def restore_page restored = get_saved_page @persistent_properties = restored.persistent_properties if persistent?(:direction) @direction = restored.direction end if persistent?(:appearance) @tile_id = restored.tile_id @character_name = restored.character_name @character_index = restored.character_index end if persistent?(:move_style) @move_speed = restored.move_speed @move_frequency = restored.move_frequency @walk_anime = restored.walk_anime @step_anime = restored.step_anime @direction_fix = restored.direction_fix @through = restored.through end if persistent?(:move_route) @pattern = restored.pattern @move_route_forcing = restored.move_route_forcing @move_route = restored.instance_variable_get("@move_route") @move_route_index = restored.instance_variable_get("@move_route_index") @original_move_route = restored.instance_variable_get("@original_move_route") @original_move_route_index = restored.instance_variable_get("@original_move_route_index") @wait_count = restored.instance_variable_get("@wait_count") end if persistent?(:interpreter) @interpreter = restored.instance_variable_get("@interpreter") @interpreter.create_fiber if @interpreter end @original_direction = @page.graphic.direction @original_pattern = @page.graphic.pattern end #----------------------------------------------- # alias method : initialize #----------------------------------------------- alias pme_initialize initialize def initialize(map_id, event) pme_initialize(map_id, event) @persistent_properties = [] restore_event if has_saved_state? end #----------------------------------------------- # alias method : setup_page #----------------------------------------------- alias pme_setup_page setup_page def setup_page(new_page) save_state if @page pme_setup_page(new_page) end #----------------------------------------------- # alias method : setup_page_settings #----------------------------------------------- alias pme_setup_page_settings setup_page_settings def setup_page_settings pme_setup_page_settings restore_page if has_saved_page? end end #============================================================================== # Game_Player #============================================================================== class Game_Player < Game_Character #----------------------------------------------- # alias method : perform_transfer #----------------------------------------------- alias pme_perform_transfer perform_transfer def perform_transfer if transfer? $game_map.events.each { |id, event| event.save_state } end pme_perform_transfer end end
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
웹 보안 - HTML & JavaScript 기초
5 hours ago | 6.45 KB
Trevor-powershell
6 hours ago | 0.15 KB
Halo Evolutions 21
13 hours ago | 1.25 KB
EU Defense Stocks
1 day ago | 0.06 KB
Halo Evolutions 19
1 day ago | 0.42 KB
Halo Evolutions 17
1 day ago | 0.43 KB
Halo Evolutions 16
1 day ago | 0.20 KB
gen5
1 day ago | 0.75 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!