Global Switches and Variables for RMX-OS
Authors: Blizzard
Version: 1.3
Type: RMX-OS plugin
Key Term: RMX-OS Plugin
IntroductionThis script will allow to have global switches and variables on your server.
This script is to be distributed under the same terms and conditions like the script it was created for: RMX-OS.
Features
- easy to configure
- controls a certain set of switches globallly
- controls a certain set of variables globallly
ScreenshotsN/A for this sort of script.
DemoN/A
ScriptJust make a new script above main and paste this code into it.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Global Switches and Variables for RMX-OS by Blizzard
# Version: 1.3
# Type: RMX-OS Add-on
# Date: 7.1.2010
# Date v1.01: 22.2.2010
# Date v1.1: 11.2.2011
# Date v1.2: 22.1.2013
# Date v1.21: 30.3.2013
# Date v1.3: 12.6.2013
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This script is to be distributed under the same terms and conditions like
# the script it was created for: RMX-OS.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Information:
#
# This script must be placed below RMX-OS and requires RMX-OS to work
# properly. This script will allow to have global switches and variables on
# your server.
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
if !defined?(RMXOS) || RMXOS::VERSION < 2.0
raise 'ERROR: The "Global Switches and Variables" requires RMX-OS 2.0 or higher.'
end
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GLOBAL_SWITCHES = [1, 2] # make sure this matches the extension configuration
GLOBAL_VARIABLES = [1, 2] # make sure this matches the extension configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
$rmxos_gswivars = 1.3
#==============================================================================
# Game_Temp
#==============================================================================
class Game_Temp
attr_accessor :disable_global
end
#==============================================================================
# Game_Switches
#==============================================================================
class Game_Switches
alias set_gswivar_later []=
def []=(id, value)
if !$game_temp.disable_global && GLOBAL_SWITCHES.include?(id)
$network.send_switch(id, value)
else
set_gswivar_later(id, value)
end
end
end
#==============================================================================
# Game_Switches
#==============================================================================
class Game_Variables
alias set_gswivar_later []=
def []=(id, value)
if !$game_temp.disable_global && GLOBAL_VARIABLES.include?(id)
$network.send_variable(id, value)
else
set_gswivar_later(id, value)
end
end
end
#==============================================================================
# RMXOS::Network
#==============================================================================
class RMXOS::Network
alias check_game_gswivar_later check_game
def check_game(message)
case message
when /\AGSWI\t(.+)\t(.+)/
$game_temp.disable_global = true
$game_switches[$1.to_i] = ($2 != '0')
$game_temp.disable_global = false
$game_map.need_refresh = true
return true
when /\AGVAR\t(.+)\t(.+)/
$game_temp.disable_global = true
$game_variables[$1.to_i] = $2.to_i
$game_temp.disable_global = false
$game_map.need_refresh = true
return true
end
return check_game_gswivar_later(message)
end
alias check_loading_gswivar_later check_loading
def check_loading(message)
result = check_loading_gswivar_later(message)
if result
if @messages.include?(RMXOS::LOADING_END)
@messages.delete(RMXOS::LOADING_END)
self.send('LGDAT')
end
else
case message
when /\ALGSWI\t(.+)/ # load global switches
hash = eval($1)
$game_temp.disable_global = true
hash.each_key {|id| $game_switches[id] = hash[id]}
$game_temp.disable_global = false
return true
when /\ALGVAR\t(.+)/ # load global variables
hash = eval($1)
$game_temp.disable_global = true
hash.each_key {|id| $game_variables[id] = hash[id]}
$game_temp.disable_global = false
$game_map.need_refresh = true
@messages.push(RMXOS::LOADING_END)
return true
end
end
return result
end
def send_switch(id, value)
self.send('GSWI', id, value ? 1 : 0)
end
def send_variable(id, value)
self.send('GVAR', id, value)
end
end
Make a new file with an
.rb extension in the
Extensions folder of RMX-OS and copy-paste this script into it.
module RMXOS
def self.load_current_extension
return GlobalSwitchesVariables
end
module Data
GlobalSwitchChange = 'Client \'CLIENT\' changed switch \'ID\' to \'STATE\'.'
GlobalVariableChange = 'Client \'CLIENT\' changed variable \'ID\' to \'STATE\'.'
end
end
#======================================================================
# module GlobalSwitchesVariables
#======================================================================
module GlobalSwitchesVariables
VERSION = 1.3
RMXOS_VERSION = 2.0
SERVER_THREAD = false
IDENTIFIER = 'Global Switches and Variables'
# START Configuration
GLOBAL_SWITCHES = [1, 2] # make sure this matches the configuration in the client
GLOBAL_VARIABLES = [1, 2] # make sure this matches the configuration in the client
SWITCHES_FILENAME = './gswitches.dat' # filename for global switch saving
VARIABLES_FILENAME = './gvariables.dat' # filename for global variable saving
SERVER_DISPLAY = true # show log in command prompt screen
LOG_FILENAME = './logs/gswivar.log' # leave empty if no log file should be created
DELETE_LOG_ON_START = false
# END Configuration
def self.initialize
@mutex = Mutex.new
@switches = {}
GLOBAL_SWITCHES.each {|id| @switches[id] = false}
if FileTest.exist?(SWITCHES_FILENAME)
file = File.open(SWITCHES_FILENAME, 'r')
ids = Marshal.load(file)
file.close
(ids & GLOBAL_SWITCHES).each {|id| @switches[id] = true}
end
@variables = {}
GLOBAL_VARIABLES.each {|id| @variables[id] = 0}
if FileTest.exist?(VARIABLES_FILENAME)
file = File.open(VARIABLES_FILENAME, 'r')
hash = Marshal.load(file)
file.close
(hash.keys & GLOBAL_VARIABLES).each {|id| @variables[id] = hash[id]}
end
if LOG_FILENAME != ''
File.delete(LOG_FILENAME) if DELETE_LOG_ON_START && FileTest.exist?(LOG_FILENAME)
RMXOS::Logs[IDENTIFIER] = LOG_FILENAME
end
end
def self.mutex
return @mutex
end
def self.main
while RMXOS.server.running
@mutex.synchronize {
self.server_update
}
sleep(0.1)
end
end
def self.server_update
end
def self.client_update(client)
case client.message
when /\ALGDAT\Z/ # load global data
client.send('LGSWI', @switches.inspect.sub(' ', ''))
client.send('LGVAR', @variables.inspect.sub(' ', ''))
return true
when /\AGSWI\t(.+)\t(.+)/ # global switch change
id = $1.to_i
value = ($2 != '0')
@switches[id] = value
self.save_switches
client.sender.send_to_all(client.message, true)
message = RMXOS::Data.args(RMXOS::Data::GlobalSwitchChange, {'CLIENT' => client.player.username, 'ID' => id.to_s, 'STATE' => value.to_s})
self.log(message)
return true
when /\AGVAR\t(.+)\t(.+)/ # global variable change
id = $1.to_i
value = $2.to_i
@variables[id] = value
self.save_variables
client.sender.send_to_all(client.message, true)
message = RMXOS::Data.args(RMXOS::Data::GlobalVariableChange, {'CLIENT' => client.player.username, 'ID' => id.to_s, 'STATE' => value.to_s})
self.log(message)
return true
end
return false
end
def self.save_switches
ids = @switches.keys.find_all {|id| @switches[id]}
file = File.open(SWITCHES_FILENAME, 'w')
Marshal.dump(ids, file)
file.close
end
def self.save_variables
hash = {}
@variables.each_key {|id| hash[id] = @variables[id] if @variables[id] != 0}
file = File.open(VARIABLES_FILENAME, 'w')
Marshal.dump(hash, file)
file.close
end
def self.log(message)
puts message if SERVER_DISPLAY
RMXOS.log('Log', IDENTIFIER, message)
end
end
InstructionsIn the script in the first comment.
CompatibilityRequires RMX-OS to work.
Credits and Thanks
Author's NotesIf you find any bugs, please report them here:
http://forum.chaos-project.com
That's it! N-Joy! =D
Okay so pretty much this can be used like this.
Theres one chest in the Forest of Killer Bunnies. It has 5000 gold.
When someone opens it it then turns on a global switch and no one else can get that gold right?
If thats what it is. Awesome script.
yet again you beat me and my busy ass to it :P
Lol! Well, I have that and some other scripts (RMX-OS + Blizz-ABS stuff) that I need to finish by the end of this month so I if you want me not to beat you to it, you better get working. xD
@G_G: Yup. Stuff is still saved in the database, but as soon as you enter the server, your switches and variables are overwritten by the with the global values. Also, this script does not ensure consistency completely. The game designers has to take care of that themselves.
Awesome script Blizz :D
this script works it is badd ass this is going to be the key to having a monstor killed and having the pepol
in the map see it happen
tho i have a question
if i hit a swich and stay thare
and some 1 else enters the map dose it swich that same swich for them
Update to v1.01.
Quote from: the scriptraise 'ERROR: The "Global DNS" requires RMX-OS 1.09 or higher.'
"Global DNS" ?
lol
Lulz
*fixes*
Could this be used for having a character show up on a different map after having been talked to?
Like if I wanted to have an area where a player could select party members, and have the selectable characters be walking around the area after having been unlocked/recruited.
You don't need GLOBAL switches for that.
is it possible to have a global variable equal to a string?
use this in a script call.
$game_variables[id] = "string here"
I have, and it works fine when i dont do a global variable, but when i do, it always is 0.
I have a problem with this script. When I make a global variable or switch and try to change them, they just change back to 0 or false. I can't even see that it changes on the game but on the server it says that they are changed.
These are the scripts I use(in the current order):
RMX-OS
Global Vars and Switches
Blizz-ABS 1, 2 and 3
Blizz-ABS Controller for RMX-OS
Questbook by Zeriab
Self Variables by DrakoShade
The Chaos Project Debug Menu by Blizzard
Location Window by Hunter X
Multiple Timers by Glitchfinder
ForeverZer0's Advanced Weather(the one based on Ccoa's script)
and at last the RMX-OS Main
http://forum.chaos-project.com/index.php/topic,23.0.html
Also, you didn't configure the script properly.
I have changed the order of the scripts and they are still not working. But what did I miss in the configuration?
I did configure the what switches and variables should be global, both on the client and the server.
Did you activate the extension?
Yes I did. That is the strange thing. I have made everything I was supposed to. Setup the script in the client. Adding the extension on the server and setting that up and adding the extension file name to the config.ini file. But I think that the server and client communicates enough since the server knows when a global variable/switch is changed. The thing is that it change it back to 0/false.
EDIT: I just have to ask. Can it be the server computer itself that is to old? The game runs and all but the computer is about 7 years old. It is my parents old computer. I'm just using it as a developement server. I will hopefully change it later.
Well, the RMX-OS server system is relatively lightweight so a weak server machine shouldn't become a bottleneck if there are only a few players online.
Try finding the file to which the server saves the global switches and variables and see if they are properly saved. Also, make sure you are using the newest versions. I changed something recently and I had to update a few RMX-OS pkugins so they work with the newest version of RMX-OS.
If you mean the .dat file, I don't know what program I need to use to open it, but if I open it with NotePad, all I get is
Nothing more.
And the Script version is the newest. 1.01
That seems that the extension did not save the variables. Can you post your configurations?
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Global Switches and Variables for RMX-OS by Blizzard
# Version: 1.01
# Type: RMX-OS Add-on
# Date: 7.1.2010
# Date: 22.2.2010
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This script is to be distributed under the same terms and conditions like
# the script it was created for: RMX-OS.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Information:
#
# This script must be placed below RMX-OS and requires RMX-OS v1.09 or
# higher to work properly. This script will allow to have global switches and
# variables on your server.
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
if !defined?(RMXOS) || RMXOS::VERSION < 1.09
raise 'ERROR: The "Global Switches and Variables" requires RMX-OS 1.09 or higher.'
end
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GLOBAL_SWITCHES = [1, 2] # make sure this matches the extension configuration
GLOBAL_VARIABLES = [1, 2, 3, 4, 5, 6] # make sure this matches the extension configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#==============================================================================
# Game_Temp
#==============================================================================
class Game_Temp
attr_accessor :disable_global
end
#==============================================================================
# Game_Switches
#==============================================================================
class Game_Switches
alias set_gswivar_later []=
def []=(id, value)
if !$game_temp.disable_global && GLOBAL_SWITCHES.include?(id)
$network.send_switch(id, value)
else
set_gswivar_later(id, value)
end
end
end
#==============================================================================
# Game_Switches
#==============================================================================
class Game_Variables
alias set_gswivar_later []=
def []=(id, value)
if !$game_temp.disable_global && GLOBAL_VARIABLES.include?(id)
$network.send_variable(id, value)
else
set_gswivar_later(id, value)
end
end
end
#==============================================================================
# RMXOS::Network
#==============================================================================
class RMXOS::Network
alias check_game_gswivar_later check_game
def check_game(message)
case message
when /\AGSW(.+)\t(.+)/
$game_temp.disable_global = true
$game_switches[$1.to_i] = ($2 != '0')
$game_temp.disable_global = false
$game_map.need_refresh = true
return true
when /\AGVA(.+)\t(.+)/
$game_temp.disable_global = true
$game_variables[$1.to_i] = $2.to_i
$game_temp.disable_global = false
$game_map.need_refresh = true
return true
end
return check_game_gswivar_later(message)
end
alias check_loading_gswivar_later check_loading
def check_loading(message)
result = check_loading_gswivar_later(message)
if result
if @messages.include?(RMXOS::LOADING_END)
@messages.delete(RMXOS::LOADING_END)
self.send('LGD')
end
else
case message
when /\ALGS(.+)/ # load global switches
hash = eval($1)
$game_temp.disable_global = true
hash.each_key {|id| $game_switches[id] = hash[id]}
$game_temp.disable_global = false
return true
when /\ALGV(.+)/ # load global variables
hash = eval($1)
$game_temp.disable_global = true
hash.each_key {|id| $game_variables[id] = hash[id]}
$game_temp.disable_global = false
$game_map.need_refresh = true
@messages.push(RMXOS::LOADING_END)
return true
end
end
return result
end
def send_switch(id, value)
self.send("GSW#{id}\t#{value ? 1 : 0}")
end
def send_variable(id, value)
self.send("GVA#{id}\t#{value}")
end
end
module RMXOS
def self.load_current_extension
return GlobalSwitchesVariables
end
module Data
GlobalSwitchChange = 'Client \'CLIENT\' changed switch \'ID\' to \'STATE\'.'
GlobalVariableChange = 'Client \'CLIENT\' changed variable \'ID\' to \'STATE\'.'
end
end
#======================================================================
# module GlobalSwitchesVariables
#======================================================================
module GlobalSwitchesVariables
VERSION = 1.01
RMXOS_VERSION = 1.09
SERVER_THREAD = false
# START Configuration
GLOBAL_SWITCHES = [1, 2] # make sure this matches the configuration in the client
GLOBAL_VARIABLES = [1, 2, 3, 4, 5, 6] # make sure this matches the configuration in the client
SWITCHES_FILENAME = './gswitches.dat' # filename for global switch saving
VARIABLES_FILENAME = './gvariables.dat' # filename for global variable saving
SERVER_DISPLAY = true # show log in command prompt screen
LOG_FILENAME = './logs/gswivar.log' # leave empty if no log file should be created
DELETE_LOG_ON_START = false
# END Configuration
def self.initialize
@switches = {}
GLOBAL_SWITCHES.each {|id| @switches[id] = false}
if FileTest.exist?(SWITCHES_FILENAME)
file = File.open(SWITCHES_FILENAME, 'r')
ids = Marshal.load(file)
file.close
(ids & GLOBAL_SWITCHES).each {|id| @switches[id] = true}
end
@variables = {}
GLOBAL_VARIABLES.each {|id| @variables[id] = 0}
if FileTest.exist?(VARIABLES_FILENAME)
file = File.open(VARIABLES_FILENAME, 'r')
hash = Marshal.load(file)
file.close
(hash.keys & GLOBAL_VARIABLES).each {|id| @variables[id] = hash[id]}
end
File.delete(LOG_FILENAME) if LOG_FILENAME != '' && DELETE_LOG_ON_START && FileTest.exist?(LOG_FILENAME)
end
def self.main
while RMXOS.server.running
self.server_update
sleep(0.1)
end
end
def self.server_update
end
def self.client_update(client)
case client.message
when /\ALGD\Z/ # load global data
client.send("LGS#{@switches.inspect.sub(' ') {''}}")
client.send("LGV#{@variables.inspect.sub(' ') {''}}")
return true
when /\AGSW(.+)\t(.+)/ # global switch change
id = $1.to_i
value = ($2 != '0')
Thread.exclusive {
@switches[id] = value
self.save_switches
client.sender.send_to_all(client.message, true)
}
message = RMXOS::Data::GlobalSwitchChange.sub('CLIENT', client.player.username).sub('ID', id.to_s).sub('STATE', value.to_s)
self.log(message)
return true
when /\AGVA(.+)\t(.+)/ # global variable change
id = $1.to_i
value = $2.to_i
Thread.exclusive {
@variables[id] = value
self.save_variables
client.sender.send_to_all(client.message, true)
}
message = RMXOS::Data::GlobalVariableChange.sub('CLIENT', client.player.username).sub('ID', id.to_s).sub('STATE', value.to_s)
self.log(message)
return true
end
return false
end
def self.save_switches
ids = @switches.keys.find_all {|id| @switches[id]}
file = File.open(SWITCHES_FILENAME, 'w')
Marshal.dump(ids, file)
file.close
end
def self.save_variables
hash = {}
@variables.each_key {|id| hash[id] = @variables[id] if @variables[id] != 0}
file = File.open(VARIABLES_FILENAME, 'w')
Marshal.dump(hash, file)
file.close
end
def self.log(message)
puts message if SERVER_DISPLAY
if LOG_FILENAME != ''
file = File.open(LOG_FILENAME, 'a')
file.write(message + "\n")
file.close
end
end
end
I'm sorry, I'm unable to look into the problem now. Your configuration seems fine and the file to which the server saved the the global data seems to be ok as well so the problem is probably with the plugin or the extension or RMX-OS.
I hope you can continue to work on your game for a few weeks until I can look into the problem and fix it.
Sure I can. The only thing that I currently need the global variables script is for the global tint that I have made. I've made so that every moderator or administrator can change the tint through the global variables and a parallel process event on each map. So that is the only thing that I currently need that for. I'll probably find out more later, but we'll see.
Oh, and I thought that you had retired from this. :???: But I'm glad it is you who are answering the question and not someone else. :)
I promised that I will finish a few things regarding RMX-OS regardless of my retirement.
Oh. Yea that is a good idea. But when you have finished those things, please teach someone else about RMX-OS so that we even after you're gone can get support about it.:P
thanks that's what i seached for :D
I am having a problem, not an error however.
Here are the scripts I am using and their order.
MAW 1.2
Mouse Map Menu
Skill Shop
Advance GameOver Script
Final Fantasy Tactics Advance Shop System
MOG - Location_Name
MOG - Treasure_Name
MOG - Item Limit
Ton 0f Addons (1)
Ton 0f Addons (2)
Ton 0f Addons (3)
RMX-OS Options
RMX-OS Script
Global Switches and Variables
Versioning
Blizz ABS (1)
Blizz ABS (2)
Blizz ABS (3)
ABS HUD made
Blizz ABS Controller
Critical Sounds for ABS
Auto-Targeting for ABS
Advanced Time and Environment
Global Day-Night System
Mouse Controller
Mouse Controller Enhancement
Mouse Drop Down Menu
RMX-OS Main
My problem is that whenever I open a Scene, rather Scene_Item or Scene_Equip, even shop interfaces Switches and Variables are change to from true back to false automatically. Basically, reseting all my events that aren't using self-switches. I didn't know where to post the my problem I am sorry if this isn't the best place. Thank you for any help.
Seems as the same problem I have. As Blizz said earlier, he i looking into it.
Quote from: stripe103 on August 31, 2010, 10:37:37 am
Seems as the same problem I have. As Blizz said earlier, he i looking into it.
Ah, I see. Thanks. I need to troll more to find out if someone has already addressed my issues. lol :)
I tried looking into this, but I couldn't reproduce the problem.
Try turning on message log on the server and reproduce it yourself, then post the message log. Maybe I can figure out what's going on if I see the communication log that went on between server and client.
Well, I can't test it right now as my server is broken and I don't know how long it will take to get it back online again. But before when I used this script and tried to change a global variable, it said on the server that I set it to 0 or False even if I turned it on. So it isn't like it changes it to 1 or true and then change back. It just resets it. Or something like that. But I'll try to get the server running as fast as I can.
Keep in mind that it tells you the ID of the switch and the value it was set to. Immediately after that the data is saved into the files.
Mine has seemed to worked it's self out and is functioning fine now. I don't know what I did. :)
Maybe it is a problem with the server machine itself. Or the network.
Network shouldn't cause a problem. At least not in the traditional sense. If the network is down and the connection is down, the game should stop responding completely (you should get a disconnection message).
Everything is working very well with the script, however, I have run into a small problem. I have a quest in my game where players need to collect flowers for NPC. So I made an event, the following:
Page 1 > Action Touch
Change Item: +1 [Flower]
Control Switch: 0001 Flower ON
Page 2 > Parallel Process > Control Switch 0001 Flower
Wait: 20
Control Switch 0001 Flower OFF
The event works however when looking at the server log after a player clicks on the flower, I am using Mouse Controller, the flower is set to true. But the event doesn't go away in the Map Scene. When I click on it again it is set to true again then disappears for the 20 then reappears and it set to true again. So bacially a player has to click it twice before it will "despawn" giving the player a chance to collect two flowers from one "node". Can anyone help me with this? I don't want them to be able to do that just one click and one flower.
I don't think you did this right if you need to click twice or the script utilizing the mouse controller doesn't work very well. Try removing RMX-OS for the time being and see if it works normally if you don't have RMX-OS installed.
I tested it, I am using blizzard's (your) mouse controller script, and the event works fine with your script. I am assuming it is either the Enchance mouse controller and mouse controller drop down menu by Nathmatt is causing the problem.
Here are both scripts, if anyone has any ideas.
Enhance mouse controller
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Mouse Controller Enhancement Script by Nathmatt
# Version: 1.44
# Type: Add On
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Instrutions:
#
# To use the event effects in this script you will need to name the following.
#
# defenitions
# w = the events width must be atleast 1
# h = the events height must be atleast 1
# d = 2 down, 4 left 6, right, or 8 up
# right click to acess an events command list
#
# \direction[d] If an event has no graphic or isn't direction specific
# they must be named this d as the open direction
#
# \commands[w,h] This will create a command list for each page with the
# name of the first avalible comment
#
# \curser[w,h,graphic] This will change the graphic of the curser while
# over that event
#
# \auto[w,h] This will start the event as soon as you click it
#
# \door[w,h,id] This will run the pages of an event as the following
# id is the item id needed to unlock the door
# first page when door is locked
# secound page when unlocking the door
# third page any time after being unlocked
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Script Calls:
#
# $MCES.disabled = true/false whether or not this script is disabled
#
# $MCES.movement_disabled = true/false whether or not movement is disabled
#
# $MCES.pick_up(id) is the id of the item that is picked up
#
# $MCES.drop drops the item
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
module Mouse_Controller_Enhancement_Script
Version = 1.44
module Config
Cant_go = 7 # The terrain tag for unreachable locations
Size = 20 # The size of the event name text
Color = Color.new(0,0,160,255) # The color of the event name text
Grab = false # false or the graphic for when you have
# an item in hand
end
#============================================================================
# ** Processor
#----------------------------------------------------------------------------
# This class performs the mouse processing.
#============================================================================
class Processor
attr_accessor :disabled,:movement_disabled,:wait
attr_reader :event_start,:item
def initialize
@disabled = false
@movement_disabled = false
@event_start = false
@unlock = []
@wait = 5
end
def update
return if @disabled
if !$scene.is_a?(Scene_Map)
@wait = 5
return
end
@int = $game_system.map_interpreter
@wait -= 1 if @wait > 0
@x,@y = $mouse.pos
if Input.trigger?(Input::Key['Mouse Right']) &&
!$game_temp.message_window_showing && @wait == 0
@wait = 5
check_right
elsif Input.trigger?(Input::Key['Mouse Left']) &&
!$game_temp.message_window_showing && @wait == 0
@wait = 5
check_left
end
force_moving if !$game_player.moving?
@commands.update if @commands != nil
check_mouse
check_item
check_finished
get_path
end
def check_left
check_events_left
check_tile
check_command
end
def check_right
check_events_right
end
def check_finished
return if @request == nil
if $game_player.x == @request.tx &&
$game_player.y == @request.ty
if @id != nil
turn_toward_event
@event_start = true
$game_map.events[@id].start
@event_start = false
end
@result = nil
@get_path = false
@id = nil
@request = nil
end
end
def check_events_left
$game_map.events.each_value{|event|
check_auto(event)
check_door(event)
check_event(event)}
end
def check_command
return if @commands == nil || @command_event == nil
if @commands.indexes >= 0 && @commands.index >= 0
event = @command_event
i = @commands.indexes
@int.setup(event.rpg_event.pages[i].list,event.id)
end
@commands.dispose
@commands = nil
@movement_disabled = false
end
def check_commands(event)
return if $game_map.commands[event.id] == nil || @commands != nil
if event.x == @x && event.y == @y || get_size(event)
@commands = Event_Command.new(event.commands)
@commands.x = event.screen_x
@commands.y = event.screen_y
@commands.z = 5000
@command_event = event
@movement_disabled = true
end
end
def check_events_right
$game_map.events.each_value{|event|
check_commands(event)}
end
def check_auto(event)
return if event.character_name == '' || !$game_map.auto[event.id]
if event.x == @x && event.y == @y || get_size(event)
@event_start = true
event.start
@event_start = false
end
end
def check_event(event)
return if $game_map.auto[event.id] || @movement_disabled
if event.x == @x && event.y == @y
@id = event.id
@d = ($game_map.event_direction[@id] != nil ?
$game_map.event_direction[@id]: $game_map.events[@id].direction)
case @d
when 2 then @y += 1
when 4 then @x -= 1
when 6 then @x += 1
when 8 then @y -= 1
end
request_path(@x, @y)
@result = nil
@get_path = true
end
end
def check_tile
return if @get_path || !$game_map.passable?(@x,@y,0) ||
@movement_disabled || check_terrain_tag || get_size
request_path(@x, @y)
@result = nil
@get_path = true
end
def check_door(event)
return if $game_map.door[event.id] == nil
if $game_map.door[event.id] == @item.id
@int.setup(event.rpg_event.pages[1].list,event.id)
$game_party.gain_item(@item.id, -1)
change_graphic
@unlock[event.id] = true
elsif @unlock[id]
@int.setup(event.rpg_event.pages[2].list,event.id)
else
@int.setup(event.rpg_event.pages[0].list,event.id)
end
return
end
def check_mouse
$game_map.events.each_value{|event|
if @x == event.x && @y == event.y || get_size(event)
$mouse.change_graphic($game_map.mouse_over_icons[event.id])
check_message(event)
else
$mouse.change_graphic
end}
end
def check_message(event)
if $game_map.msg[event.id] != nil
if @sprite == nil || @map != $game_map.map_id || @last_id != event.id
@map = $game_map.map_id
@last_id = event.id
@sprite = Sprite.new
@sprite.z = 1000
@sprite.bitmap = Bitmap.new(640,32)
@sprite.bitmap.font.size = Config::Size
@sprite.bitmap.font.color = Config::Color
@w = @sprite.bitmap.text_size($game_map.msg[id]).width
h = @sprite.bitmap.text_size($game_map.msg[id]).height
@sprite.bitmap.draw_text(0,0,@w,h,$game_map.msg[id].to_s)
end
@sprite.x = $game_map.events[id].screen_x - (@w / 2)
@sprite.y = $game_map.events[id].screen_y - 64
elsif @sprite != nil
@sprite.dispose
@sprite = nil
end
end
def check_item
if @item != nil
if @cursor == nil
@cursor = Sprite.new
@cursor.z = 1000000
@cursor.bitmap = RPG::Cache.icon(@item.icon_name)
end
@cursor.x , @cursor.y = $mouse.position
@cursor.x -= 5
@cursor.y += 5
elsif @cursor != nil
@cursor.dispose
@cursor = nil
end
end
def check_terrain_tag
if $game_map.terrain_tag(@x, @y) == Config::Cant_go
return true
end
end
def get_size(event = nil)
if event == nil
$game_map.events.each_value{|event|
return $game_map.size[event.id] != nil &&
$game_map.size[event.id]['X'].include?(@x) &&
$game_map.size[event.id]['Y'].include?(@y)}
end
return $game_map.size[event.id] != nil &&
$game_map.size[event.id]['X'].include?(@x) &&
$game_map.size[event.id]['Y'].include?(@y)
end
def get_path
if @get_path && @result == nil
@result = find_path
end
end
def pick_up(id)
@item = $data_items[id]
$mouse.change_graphic(Config::Grab) if Config::Grab != false
end
def drop
@item = nil
$mouse.change_graphic
end
def force_moving
return if @result == nil || @result == []
$network.send_player_data if $network != nil
case @result[0][0]
when 2 then $game_player.move_down
when 4 then $game_player.move_left
when 6 then $game_player.move_right
when 8 then $game_player.move_up
end
@result.shift
end
def turn_toward_event
case @d
when 2 then $game_player.turn_up
when 4 then $game_player.turn_right
when 6 then $game_player.turn_left
when 8 then $game_player.turn_down
end
end
def request_path(x, y = nil)
# if request does not exist yet
if x != nil && y != nil && @request == nil
# add request
@request = PathRequest.new(x, y)
end
end
def find_path
char = $game_player
# get pixel movement rate
pix = 1
# use request
request = @request
# if no nodes to test
if request.open.size == 0
# abort testing for this character
@request = nil
# stop execution
return []
end
# found
found = false
# find minimal key
key = request.open.keys.min {|a, b|
Math.hypot(a[0] - request.tx, a[1] - request.ty) <=>
Math.hypot(b[0] - request.tx, b[1] - request.ty)}
# this node is now logged as checked
request.closed[key[0], key[1]] = request.open[key]
# remove this node from the pending array
request.open.delete(key)
# iterate through all possible directions with relative offsets
pathDirs = [[0, 1, 2], [-1, 0, 4], [1, 0, 6], [0, -1, 8]]
pathDirs.each {|dir|
# coordinates of new position
kx, ky = key[0] + dir[0], key[1] + dir[1]
# if new coordinates are destination
if kx == request.tx && ky == request.ty
# the new node was checked
request.closed[kx, ky] = dir[2]
# path was found
found = true
# stop checking
break
# if new node not checked yet and coordinates are passable
elsif request.closed[kx, ky] == 0 &&
char.passable?(key[0] * pix, key[1] * pix, dir[2])
# add new node to be checked
request.open[[kx, ky]] = dir[2]
end}
# stop execution except if found path
return nil unless found
# backtrack the path
result = request.backtrack
# finish testing for this character
return result
end
end
class PathRequest
# setting all accessible variables
attr_reader :open
attr_reader :closed
attr_reader :sx
attr_reader :sy
attr_reader :tx
attr_reader :ty
def initialize(tx, ty)
a = $game_player
@sx, @sy, @tx, @ty = a.x, a.y, tx, ty
@x_off, @y_off = a.x - @sx, a.y - @sy
@open = {[@sx, @sy] => -1}
@closed = Table.new($game_map.width, $game_map.height)
end
def backtrack
pix = 1
tdirs = [[0, true], [1, true], [2, true], [3, true], [4, true], [5, true],
[6, true], [7, true], [8, true], [9, true]]
dirOffsets = [[0, 0], [-1, 1], [0, 1], [1, 1], [-1, 0], [0, 0], [1, 0],
[-1, -1], [0, -1], [1, -1]]
cx, cy, x, y, result = @tx, @ty, 0, 0, []
loop do
cx, cy = cx - x, cy - y
break if cx == @sx && cy == @sy
pix.times {result.unshift(tdirs[@closed[cx, cy]])}
x, y = dirOffsets[@closed[cx, cy]]
end
return result
end
end
end
class Mouse
def pos
return if $game_map.display_x == nil
x, y = self.position
x = ( x + $game_map.display_x / 4) / 32
y = ( y + $game_map.display_y / 4) / 32
return x, y
end
def change_graphic(graphic = nil)
if graphic != nil
@cursor.bitmap = RPG::Cache.picture(graphic)
@graphic = graphic
elsif @cursor.bitmap != RPG::Cache.picture(MOUSE_ICON)
@cursor.bitmap = RPG::Cache.picture(MOUSE_ICON)
end
end
end
class Event_Command < Window_Command
def initialize(commands)
@size = 0
@main_commands = commands
@array = []
commands.each{|command|
@array.push(command) if command != nil
@size = (commands.size * 32) if (commands.size * 32) > @size}
super(@size,@array)
end
def indexes
return @main_commands.index(@array[self.index])
end
end
class Game_Event < Game_Character
attr_reader :first
alias page_name initialize
def initialize(m,e)
@first = {}
page_name(m,e)
end
def start
return if @trigger == 0 && !$MCES.event_start
if @list.size > 1
@starting = true
end
end
def rpg_event
return @event
end
def commands
com = []
@event.pages.each{|page|
page.list.each{|list|
@last_list = list if @last_list == nil
if list.code == 108
if check_condition(@last_list)
com[@event.pages.index(page)] = list.parameters[0]
end
end
@last_list = list}}
return com
end
def check_condition(list)
return false if list.code == 411 && @result
return true if list.code != 111
result = false
par = list.parameters
case par[0]
when 0
result = ($game_switches[par[1]] == (par[2] == 0))
when 1
value1 = $game_variables[par[1]]
value2 = (par[2] == 0 ? par[3] : $game_variables[par[3]])
case par[4]
when 0
result = (value1 == value2)
when 1
result = (value1 >= value2)
when 2
result = (value1 <= value2)
when 3
result = (value1 > value2)
when 4
result = (value1 < value2)
when 5
result = (value1 != value2)
end
when 2
if @id > 0
key = [$game_map.map_id, @id, par[1]]
if par[2] == 0
result = ($game_self_switches[key] == true)
else
result = ($game_self_switches[key] != true)
end
end
when 3
if $game_system.timer_working
sec = $game_system.timer / Graphics.frame_rate
if par[2] == 0
result = (sec >= par[1])
else
result = (sec <= par[1])
end
end
when 4
actor = $game_actors[par[1]]
if actor != nil
case par[2]
when 0
result = ($game_party.actors.include?(actor))
when 1
result = (actor.name == parameters[3])
when 2
result = (actor.skill_learn?(parameters[3]))
when 3
result = (actor.weapon_id == parameters[3])
when 4
result = (actor.armor1_id == par[3] || actor.armor2_id == par[3] ||
actor.armor3_id == par[3] || actor.armor4_id == par[3])
when 5
result = (actor.state?(par[3]))
end
end
when 5
enemy = $game_troop.enemies[par[1]]
if enemy != nil
case par[2]
when 0
result = (enemy.exist?)
when 1
result = (enemy.state?(par[3]))
end
end
when 6
character = get_character(par[1])
if character != nil
result = (character.direction == par[2])
end
when 7
if parameters[2] == 0
result = ($game_party.gold >= par[1])
else
result = ($game_party.gold <= par[1])
end
when 8
result = ($game_party.item_number(par[1]) > 0)
when 9
result = ($game_party.weapon_number(par[1]) > 0)
when 10
result = ($game_party.armor_number(par[1]) > 0)
when 11
result = (Input.press?(par[1]))
when 12
result = eval(par[1])
end
@result = result
return result
end
end
module Input
class << Input
alias update_mouse_enhancement_later update
end
def self.update
$MCES.update
update_mouse_enhancement_later
end
end
$MCES = Mouse_Controller_Enhancement_Script::Processor.new
class Game_Map
attr_reader :map
attr_reader :mouse_over_icons
attr_reader :event_direction
attr_reader :commands
attr_reader :msg
attr_reader :auto
attr_reader :info
attr_reader :door
attr_reader :size
attr_accessor :event_index
alias setup_mouse_path_finder_later setup
def setup(map_id)
setup_mouse_path_finder_later(map_id)
check_names
end
def check_names
@mouse_over_icons = []
@event_direction = []
@commands = []
@event_index = []
@msg = []
@auto = []
@door = []
@size = []
$game_map.events.each_key {|i|
check_event_names(i) if $game_map.events[i] != nil}
end
def check_event_names(event_id)
event = @map.events[event_id]
if event.name.clone.gsub!(/\\[Cc]ommands\[([\d, ]+)\]/) {"#[$1]"}
array = eval("[#{$1}]")
@commands[event_id] = true
end
if event.name.clone.gsub!(/\\[Cc]urser\[([\S, ]+)\]/) {"#[$1]"}
array = eval("[#{$1}]")
end
if event.name.clone.gsub!(/\\[Mm]sg\[(.+?)\]/) {"#[$1]"}
@msg[event_id] = $1.to_s
end
if event.name.clone.gsub!(/\\[Dd]irection\[(\d)\]/) {"#[$1]"}
@event_direction[event_id] = $1.to_i
end
if event.name.clone.gsub!(/\\[Aa]uto\[([\d, ]+)\]/) {"#[$1]"}
array = eval("[#{$1}]")
@auto[event_id] = true
elsif event.name.clone.gsub!(/\\[Dd]oor\[([\d, ]+)\]/) {"#[$1]"}
array = eval("[#{$1}]")
@door[event_id] = array[2]
end
if array != nil
@size[event_id] = {}
@size[event_id]['X'] = []
@size[event_id]['Y'] = []
sx = event.x - ((array[0] - 1) / 2)
sy = event.y - (array[1] - 1)
ex = ((array[0] - 1) / 2) + event.x
ey = event.y
(sx..ex).each {|i| @size[event_id]['X'].push(i)}
(sy..ey).each {|i| @size[event_id]['Y'].push(i)}
end
end
end
if $network != nil
class Scene_Map
alias mces_create_trade_windows create_trade_windows
def create_trade_windows
$MCES.movement_disabled = true
mces_create_trade_windows
end
alias mces_dispose_trade_windows dispose_trade_windows
def dispose_trade_windows
$MCES.movement_disabled = false
mces_dispose_trade_windows
end
end
end
Mouse Controller Drop Down Menu
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Character Drop Down Menu by Nathmatt
# Version: 1.15
# Type: Misc System
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Character_Drop_Down_Menu
def initialize
username = ''
@mini_list_array = ['Add Buddy','Trade']
@mini_list_array.insert(1,'Add Party') if $blizzabs_rmxos != nil
if $network.guildleader == $network.username
@mini_list_array.insert(0,'Guild Invite')
end
@mini_list_array.push('Kick','Ban') if $network.usergroup > 0
@confirm_window = Window_Confirm.new
@mini_list = Window_Mini_List.new(@mini_list_array)
@mini_list.visible = false
@wait = 0
end
def update
@wait -= 1 if @wait > 0
if Input.trigger?(Input::Key['Mouse Right'])
return if @wait != 0
@mx,@my = $mouse.pos
@sx,@sy = $mouse.position
@player_username = $network.check_player(@mx,@my)
@players_info = $network.get_player(@mx,@my)
if @player_username != nil
@mini_list.visible = true
@mini_list.active = true
@mini_list.x = @sx
@mini_list.y = @sy
$MCES.disabled = true
end
@wait = 5
end
if @mini_list.active
@mini_list.update
if Input.trigger?(Input::Key['Mouse Left'])
return if @wait != 0
if @mini_list.index >= 0
@confirm_window.set_commands(@mini_list.item,@player_username)
end
@mini_list.visible = false
@mini_list.active = false
@wait = 5
end
end
if @confirm_window.active
@confirm_window.update
if Input.trigger?(Input::Key['Mouse Left'])
return if @wait != 0
case @confirm_window.index
when 0
case @mini_list.item
when 'Add Buddy'
$network.command_buddy_add(@player_username)
when 'Trade'
$network.command_trade_request(@player_username)
when 'Guild Invite'
$network.command_guild_invite(@player_username)
when 'Kick'
$network.command_kick_player(@player_username)
when 'Ban'
$network.command_ban_player(@player_username)
when 'Add Party'
$network.command_party_invite(@player_username)
end
@confirm_window.visible = false
@confirm_window.active = false
else
@confirm_window.visible = false
@confirm_window.active = false
end
$MCES.disabled = false
$MCES.wait = 5
@wait = 5
end
end
end
end
#==============================================================================
# Scene_Map
#==============================================================================
class Scene_Map
alias character_drop_down_menu_main main
def main
@mini_menu = Character_Drop_Down_Menu.new
character_drop_down_menu_main
end
alias character_drop_down_menu_update update
def update
@mini_menu.update
character_drop_down_menu_update
end
end
#==============================================================================
# Mouse
#==============================================================================
class Mouse
attr_accessor :cursor
def pos
x, y = self.position
x = ( x + $game_map.display_x / 4) / 32
y = ( y + $game_map.display_y / 4) / 32
return x, y
end
end
#==============================================================================
# Window_list
#==============================================================================
class Window_Mini_List < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(list)
super(476, 175, 104, 300)
@list = list
@column_max = 1
refresh
self.index = 0
self.opacity = 0
self.active = false
self.z = 10000
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index] if self.index >= 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
@list.each {|i| @data.push(i)}
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.fill_rect(0,0,width,height,Color.new(0, 0, 0, 160))
@data.each_index {|i| draw_item(i)}
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
x = index % 1 * (288 + 32)
y = index / 1 * 32
self.contents.font.size = 16
self.contents.draw_text(x, y, width - 32, 32, @data[index].to_s, 1)
end
end
#==============================================================================
# Window_Confirm
#==============================================================================
class Window_Confirm < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize
super(100, 100, 300, 150)
@data = ['Yes','No']
@column_max = 2
@command = nil
@user = nil
refresh
self.index = 0
self.opacity = 0
self.active = false
self.visible = false
self.z = 10000
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index] if self.index >= 0
end
#--------------------------------------------------------------------------
# * reset
#--------------------------------------------------------------------------
def set_commands(command,user)
@command = command
@user = user
self.visible = true
self.active = true
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, 20 + row_max * 32)
self.contents.font.size = 16
self.contents.fill_rect(0,0,width,height,Color.new(0, 0, 0, 160))
self.contents.draw_text(0,0,width,20,
'Are you sure you want to '+ @command.to_s + ' ' + @user.to_s)
@data.each_index {|i| draw_item(i)}
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
x = index * (width - 32) / 2
self.contents.draw_text(x, 20, (width - 32) / 2, 32, @data[index].to_s, 1)
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(self.index * (width - 32) / 2, 25,
(width - 32) / 2 , 20)
end
end
end
#============================================================================
# RMXOS::Network
#============================================================================
class RMXOS::Network
def check_player(x,y)
@players.any? {|key, value|
return value.username if value.x == x && value.y == y}
return nil
end
def get_player(x,y)
if $blizzabs_rmxos != nil
@players.any? {|key, value|
return value.battler if value.x == x && value.y == y}
end
return nil
end
end
# Load the network
$network = RMXOS::Network.new
Then you'll have to ask nathmatt to take a look at it. Try posting in his topics, I'm not sure if he reads other script topics.
I will do that than :) thank you
blizzard it seems to be caused by this
alias check_game_gswivar_later check_game
def check_game(message)
case message
when /\AGSW(.+)\t(.+)/
$game_temp.disable_global = true
$game_switches[$1.to_i] = ($2 != '0')
$game_temp.disable_global = false
$game_map.need_refresh = true
return true
when /\AGVA(.+)\t(.+)/
$game_temp.disable_global = true
$game_variables[$1.to_i] = $2.to_i
$game_temp.disable_global = false
$game_map.need_refresh = true
return true
end
return check_game_gswivar_later(message)
end
when i set $game_map.need_refresh = true it seemed to work
What do you mean? Where did you set it to true?
in that code they were both set to false
*takes a look at the script posted in the first post* O_o It says true in that part of the script.
Maybe somehow I tipped it to false or changed it to false thinking it was something else. I am not sure, it works fine now though. :) thanks for the help guys.
Using the new version of this script and the script RMXOS, this system has stopped working, please check this.
This error occurs when I try to change a switch or a variable global:
(http://piczasso.com/i/yfeio.PNG)
Server side error:
(http://piczasso.com/i/x2aqy.PNG)
Thank you
in the .rb file you need to comment that line until Blizz fixes it.
I fixed it. You just have to change that line in th extension to "log" instead of "logs".
Hi, well, I have a problem, I have the correct order, and I have the same config in extension and client, and when I activate a global switch, the client and the server gives me an error. What should I do?
Describe the error more specifically, such as the error name, message, and line number if you want someone to be able to help.
Quote from: ForeverZer0 on July 13, 2012, 10:37:33 pm
Describe the error more specifically, such as the error name, message, and line number if you want someone to be able to help.
Well, my error is in the line 77 from the global switches extension. All the config is the same, both in client and extension
Quote from: ForeverZer0 on July 13, 2012, 10:37:33 pm
Describe the error more specifically, such as the error name, message, and line number if you want someone to be able to help.
The server gives me an error in the line 77 of the extension, in the one that says : self.client_update, and the client gives me an error saying that the connection was anuled by the host, that's my error.
I'm getting a client crash any time I change a global variable or switch in game. My script order is RMX-OS Options, RMX-OS Script, Global Switches and Variables, and lastly RMX-OS Main. Both the script and the .rb file have the same switches/variables listed. The config file has the extension enabled. I'm not sure if I need to make the .dat files, as they do not exist. If I do, I'm clueless about what to put in them. I've played around with the whole thing, hoping for a miracle. I've deleted it and put in a fresh copy, I've tried just about everything I could before posting, with no luck. :(
Here is the server cmd output.
(http://s20.postimage.org/7qppikp31/Server_Problem.png)
Here is the client output error.
(http://s20.postimage.org/mleawqynx/Client_Error.png)
Any help would be appreciated and you would have my undying gratitude. Thanks in advance. :)
Did you add the server extension for the Global Switches and Variables script?
You don't need to create the .dat files yourself, RMX-OS takes care of that for you.
Quote from: Blizzard on January 16, 2013, 05:11:55 am
Did you add the server extension for the Global Switches and Variables script?
You don't need to create the .dat files yourself, RMX-OS takes care of that for you.
In the config file? Yes. It looks like:
EXTENSIONS = ['Global Switches and Variables']
The Global Switches and Variables.rb file is in the Extensions folder as well. When I start the server running, line 5 in the cmd says Global Switches and Variables was loaded and initialized, so I assumed it's working fine. But the second the switch changes in game, the client who changed it bugs out with the error in my last post. I can't imagine it has anything to do with the event in the editor, it's just a simple turn switch on command.
Here is what the error log printed out. Hopefully it helps.
2013-01-16 10:53:24 UTC; 1 (Kyle) - Error:
deadlock; recursive locking
<internal:prelude>:8:in `lock'
<internal:prelude>:8:in `synchronize'
<internal:prelude>:27:in `exclusive'
./Extensions/Global Switches and Variables.rb:77:in `client_update'
Data/Client.rb:43:in `block in handle'
Data/Client.rb:43:in `each_value'
Data/Client.rb:43:in `handle'
Data/Server.rb:276:in `block (2 levels) in run'
<internal:prelude>:28:in `block in exclusive'
<internal:prelude>:10:in `synchronize'
<internal:prelude>:27:in `exclusive'
Data/Server.rb:274:in `block in run'
Thanks so much for helping! :)
UPDATE:
I think I fixed it, here's what I did. Line 77 for switches and 88 for variables, in the .rb file, had the problem, so I just commented that line, and its ending bracket, for both the switches and variables. The .dat files showed up after the test. Registered a new account, jumped in, and sure enough the switch change was there. I'm not sure if those specific lines are necessary, but I thought I'd let you know, in case you wanted to look at it.
Thanks again for RMX-OS Blizzard, I've had a blast playing with it! :)
Thanks, I'll check it out and fix it if there is a bug (it's looks like it is).
EDIT: I finally took a look at the script. The original was made for RMX-OS 1.18 while in RMX-OS 1.2x the message handling already is thread-safe so that Thread.exclusive call that was causing the problem isn't needed anymore. I updated the script to 1.2 and now it requires RMX-OS 1.21 to run.
I have a question..
I have flowers on the map that u can pick up (its a event ofc)
when u pick them up global switch A goes on, then the 2nd page of the event says
If global switch A = on
Wait 999
wait 999
Set global switch A = off
(when global switch A is on the flower goes away, when switch goes off flower comes back)
Though it only comes back when i wait the 2times 999 frames on the map were the event is located.
So if no-one is in that map, than the event does not run am i right?
Well my question is:
How can i make the event to contineu even when no-one is on the map?
Thanks in advance.
Don't do it like that. The timer will restart and the event will be gone forever if all players leave the map. Use a parallel process for that kind of stuff and let it's count down from a variable each frame instead of using the wait command.
Thanks allot for reply.
Im not so familiar with variables yet but i will try that.
Also the event does not disapear forever.. Timer indeed resets but when u wait the appropiate time the flowers spawn again.
Thanks again.
If you leave the map, the event will never finish and the last command will never be executed.
I dont want to disagree with the best scripter i know.
But when i put event on map "a flower"
When i pick up self switch a goes ON.
Wait 200 = 10 sec
Self switch a OFF
Flower apeares on map again.
If i pick flower, wait 8 sec, leave map, come back, 10 sec later flower spawns.
So if i pick flower, wait 8 sec, leave map for 3 hours, come back, i wait 10 sec and flower comes back.
So sadly i have to disagree, event does not disapear. Last command will be executed when u enter the map.
That's weird. I was sure that events aren't processed when you're gone from the map.
They arent, unless hes using some obscure script
When your gone they arent, but when your back they are.
They just reset.
Like if i leave map 10 times after 8 sec, than the 11th time i enter the map i again need to wait the full 10 sec.
Also im not using anything "obscure" i think. unless Enu SBS Tanketai XP is obscure, im honest i dont know what obscure is and im atm to lazy to look it up.
He just meant that you may be using a script that changes the event behavior.
When you say
Quote
Make a new file with an .rb extension in the Extensions folder of RMX-OS and copy-paste this script into it.
what do you mean
Literally that. When you extract the RMX-OS server, there is a folder called Extensions. Make a new file, call is whatever you like, open the file in Notepad, copy-paste the extension code from my post into the file and save it. And don't forget to add the filename in the EXTENSIONS setting in cfg.ini so it's being loaded when RMX-OS starts.
Ok so i got it working only not with flowers but for chopping tree's
But my question: will the server become more laggy if more Variables are counting down at the same time?
Also when i chop tree A and the countdown begins (1000 frames)
Then after some seconds i chop tree B so also that countdown from 1000 frames begins.
But for some reason the countdown from tree B is faster, so the tree i chop last will respawn first.. how is that possible..?
Also, is there a way to make Selfs switches global?
Cus i now have 30 Common events so u can chop 30 diffrent tree's (if i use a self switch then for me the tree disapeares when i chop it but for other people not)
And if i use 1 common event for 30 tree's then when u cut one tree all 30 tree's disapear (if i make them all disapear when common event "tree chopped" is active)
Thanks and sorry for the many questions..
You will obviously need one variable for every tree.
No, self-switches are not supported, because the setup would be very, very difficult.
Updated to work with RMX-OS 2.0.
Hi! Thanks for this script, but i have an error.
I made all steps but the client freeze at the login when it says receiving.
It load all (41 / 41)
Version of RMX-OS = 2.0
This script. downloaded one hour ago.
Can you help me?
Edit: in the error.log appear this:
Warning: Incoming message not handled: LGDAT
Have you added the server extension?
Yep.
I notice one thing.. I have a problem with ruby for the encoding UTF-8. I don't know why.. i try to reinstall ruby, but nothing has changed.
Infact when I open the server in the cmd it says: error in open file Global switch.... cannot be loaded.
then: invalid multibyte char (UTF-8)
Actually i make research on the net for solve it.
Edit: I solve it! Anyhow Thanks for Yours awesome scripts :)
Edit2: I have another problem :^_^':. I want to save a variable that looks like an array but it causes crash..
I write that codes on a scene for debug:
$game_variables[1] = []
$game_variables[1][0] = x
What do you think: is better make another class with array to save? So I will try.. Any hints?
If I remember right, I think I implemented everything to work only with numbers. That way I wouldn't have to serialize data and can save bandwidth.
Ok. I understand, anyhow i can use this script too.
It only means more work :). Thanks
In the meanwhile I will study more ruby. See ya!
Im having a problem with this script similar to what Paco had but there no fix info, when i login i get stuck on Receiving:17/17 with titlescreen pic in background? I added extension and script.
BUMP*
:^_^': I don't remember what I did for fixing it.. I think I rename the folder that contain utf-8 character but I'm not sure. You use ruby? If yes, if you use an UTF-8 character it show an UTF-8 error? If that is the case search on google how to fix it. I remember I do something like that ahah. Sorry for the bad answer.. and if you solve the problem post it! Good luck :)
Hey Paco thanks for the reply, I have no idea about Ruby :P Its probably the reason im struggling to get all these scripts together :D Once I have them working I can start the building of the game, getting to that point is proving tricky lol, Do u think you could compile me a project with a working rmxos features installed? ty for reply
Have you enabled the extension in cfg.ini?
I guys, so im trying to work out how to define which switches and variables are global, I have made common events linked to spells that change a characters sprite, problem is it is global so everyone on the map changes if some 1 uses the spell!
I changed these so only a couple of varis and switches are global both in server ext and client and still the spell to transform is global :S
GLOBAL_SWITCHES = [49, 50] # make sure this matches the extension configuration
GLOBAL_VARIABLES = [49, 50] # make sure this matches the extension configuration
Taking a wild guess here...
# make sure this matches the extension configuration
But did you do that?
ye i chamged it in the server extension and client, cant seem to work it out
Update, i changed the value to a lower set instead of 100s + to 30s and it worked :)