I am absolutely certain this should be incredibly simple but I am just banging my head against the wall.
I know you can set ActorID to variable using Control Variables in the event window but I can't figure out how to do it in a custom script.
I need it in script as I am modifying Vel's Chapter Indicator script to show various bits of other information in concert with Yanfly's save engine. Everything is working perfectly except in order to display the current outfit of the actor I need to set a variable to the party leaders ActorID as I have used different ActorID slots for each of the different outfits. This needs to happen whilst in the save menu and so cannot be done through event-ing.
I have tried a number of different methods, most of which should have worked from what my minuscule understanding of ruby tells me but none of them has. I am obviously missing a definition here but from everything I have managed to find online all the different ways of getting ActorID I am trying should be global and reference-able from my script but clearly I just don't understand it enough to make it work.
I have tried the following...
I am sure for anyone who has any real experience with scripting I am making an obvious error and would very much appreciate any and all help you can give. In case it is not clear I have absolutely no idea what I am doing and have only gotten this far through literal guess work. This isn't for any actual real game or project just my messing about but it's frustrating me no end and I would love to be able to put it behind me and maybe learn something in the process.
I have attached my modified Vel Chapter Indicator script below.
Original script was sourced from...
https://rpgmaker.net/scripts/270/
Script requires Yanfly Ace Save Engine from...
https://yanflychannel.wordpress.com/rmvxa/menu-scripts/ace-save-engine/
If someone could let me know the exact code to get the party leader ActorID and pass that ID into variable 100 and the exact place to put that code in the above script it would be tremendously satisfying. If you can explain the how and why of it as well that would be even more gratifying.
Whatever the case may be please Help.
Thanks, Daede
P.S. I have thoroughly googled every variation of Set variable to ActorID and there are a handful of similar requests but none seem to have been answered, or at least not in anyway I could understand or replicate. Most just seem to end with using Control Variable via Common Event which is of no use in this circumstance that I can see.
Note: Edited to add source links to original scripts as per Mod advice.
I know you can set ActorID to variable using Control Variables in the event window but I can't figure out how to do it in a custom script.
I need it in script as I am modifying Vel's Chapter Indicator script to show various bits of other information in concert with Yanfly's save engine. Everything is working perfectly except in order to display the current outfit of the actor I need to set a variable to the party leaders ActorID as I have used different ActorID slots for each of the different outfits. This needs to happen whilst in the save menu and so cannot be done through event-ing.
I have tried a number of different methods, most of which should have worked from what my minuscule understanding of ruby tells me but none of them has. I am obviously missing a definition here but from everything I have managed to find online all the different ways of getting ActorID I am trying should be global and reference-able from my script but clearly I just don't understand it enough to make it work.
I have tried the following...
def set_var_actoid_a
var100a = $game_party.members[0].id
$game_variables[100] = var100a
end
var100a = $game_party.members[0].id
$game_variables[100] = var100a
end
def set_var_actoid_b
var100b = $game_party.all_members[0]
$game_variables[100] = var100b
end
var100b = $game_party.all_members[0]
$game_variables[100] = var100b
end
def set_var_actoid_c
$gameVariables.setValue(100, $gameParty.leader().actorId())
end
$gameVariables.setValue(100, $gameParty.leader().actorId())
end
def set_var_actoid_d
var100d = $game_actors[actor_id]
$game_variables[100] = var100d
end
var100d = $game_actors[actor_id]
$game_variables[100] = var100d
end
I am sure for anyone who has any real experience with scripting I am making an obvious error and would very much appreciate any and all help you can give. In case it is not clear I have absolutely no idea what I am doing and have only gotten this far through literal guess work. This isn't for any actual real game or project just my messing about but it's frustrating me no end and I would love to be able to put it behind me and maybe learn something in the process.
I have attached my modified Vel Chapter Indicator script below.
Code:
#==============================================================================
#
# ▼ Vel System - Chapter Indicator v1.00
# -- Last Updated: 2/15/2013
# -- Author: Ven01273
# -- Level: Normal
# -- Requires: Yanfly Engine Ace - Ace Save Engine v1.00+
# *Based on Chapter Teller by wltr3565
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YEA-VS-CTI"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2/15/2013 - Started Script and finished.
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script enables Yanfly's Ace Save Engine to display the Chapter you're in.
# This'll be shown right below Variable Column 1 in the Ace Save Engine.
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below the Ace Save Engine Script but above ▼ Main Process.
#
# If you want to have more chapters, just follow the template below:
#
# CHAPTER_WORDS[n] = "string"
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script was made with RGSS3. I don't use the other versions, so I don't
# know if it'll work. See for yourself.
#
# This script requires Yanfly Engine Ace - Ace Save Engine v1.00+ and the
# script must be placed under Ace Save Engine in the script listing.
#==============================================================================
# ▼ Commercial?
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script itself is allowed to be used in commercial games.
# However it requires Yanfly's 'Ace Save Engine' to function.
# Only Yanfly can give permission for the use of the 'Ace Save Engine'
#==============================================================================
module VEL
#==============================================================================
# BEGIN OUTFIT EDITABLE REGION
#==============================================================================
module OUTFIT
OUTFIT_WORDS = [] #Do not remove or edit this.
OUTFIT_VARIABLE = 100
# The variable referenced when indicating the outfit you're wearing.
UNDEFINED_OUTFIT = "Outfit: None."
# What is shown when OUTFIT_VARIABLE's value is less than or greater OUTFIT_MAX.
OUTFIT_MAX = 24
# The maximum amount of outfits you want.
OUTFIT_WORDS[11] = "Outfit: Rookie Uniform."
OUTFIT_WORDS[14] = "Outfit: Smart Uniform."
OUTFIT_WORDS[22] = "Outfit: Casual Outfit."
end
#==============================================================================
# END OUTFIT EDITABLE REGION
#==============================================================================
#==============================================================================
# BEGIN TITLE EDITABLE REGION
#==============================================================================
module TITLE
TITLE_WORDS = [] #Do not remove or edit this.
TITLE_VARIABLE = 1
# The variable referenced when indicating the title you're known by.
UNDEFINED_TITLE = "Rookie."
# What is shown when TITLE_VARIABLE's value is less than or greater TITLE_MAX.
TITLE_MAX = 100
# The maximum amount of different Titles you want.
TITLE_WORDS[0] = "Title: Novice."
TITLE_WORDS[1] = "Title: Initiate."
end
#==============================================================================
# END TITLE EDITABLE REGION
#==============================================================================
#==============================================================================
# BEGIN BLURB EDITABLE REGION
#==============================================================================
module BLURB
BLURB_WORDS = [] #Do not remove or edit this.
BLURB_VARIABLE = 1
# The variable referenced when indicating the blurb to display.
UNDEFINED_BLURB = "Biography: None known."
# What is shown when BLURB_VARIABLE's value is less than or greater than BLURB_MAX.
BLURB_MAX = 100
# The maximum amount of different Blurbs you want.
BLURB_WORDS[0] = "Biography: some blurb and backstory."
BLURB_WORDS[1] = "Biography: some other blurb and backstory."
end
#==============================================================================
# END BLURB EDITABLE REGION
#==============================================================================
#==============================================================================
# Don't edit anything past this point, unless you know what you're doing.
#==============================================================================
end
#--------------------------------------------------------------------------
# * Edit Script: Ace Save Engine
#--------------------------------------------------------------------------
class Window_FileStatus < Window_Base
#--------------------------------------------------------------------------
# New Method: draw_save_outfit
#--------------------------------------------------------------------------
def draw_save_outfit(dx, dy, dw)
return if @header[:variables].nil?
reset_font_settings
change_color(normal_color)
variable_id = VEL::OUTFIT::OUTFIT_VARIABLE
return unless variable_id >= 0
varival = @header[:variables][variable_id]
if varival < 0
draw_text(dx, dy, dw, line_height, VEL::OUTFIT::UNDEFINED_OUTFIT)
end
if varival > VEL::OUTFIT::OUTFIT_MAX
draw_text(dx, dy, dw, line_height, VEL::OUTFIT::UNDEFINED_OUTFIT)
end
if varival <= VEL::OUTFIT::OUTFIT_MAX and varival >= 0
draw_text(dx, dy, dw, line_height, VEL::OUTFIT::OUTFIT_WORDS[varival])
end
end
#--------------------------------------------------------------------------
# New Method: draw_save_title
#--------------------------------------------------------------------------
def draw_save_title(dx, dy, dw)
return if @header[:variables].nil?
reset_font_settings
change_color(normal_color)
variable_id = VEL::TITLE::TITLE_VARIABLE
return unless variable_id >= 0
varival = @header[:variables][variable_id]
if varival < 0
draw_text(dx, dy, dw, line_height, VEL::TITLE::UNDEFINED_TITLE)
end
if varival > VEL::TITLE::TITLE_MAX
draw_text(dx, dy, dw, line_height, VEL::TITLE::UNDEFINED_TITLE)
end
if varival <= VEL::TITLE::TITLE_MAX and varival >= 0
draw_text(dx, dy, dw, line_height, VEL::TITLE::TITLE_WORDS[varival])
end
end
#--------------------------------------------------------------------------
# New Operation: slice_text (Automatically word wrap text onto new line)
# Gifted by Mangomight from http://rmrk.net/index.php?topic=47289.0
#--------------------------------------------------------------------------
def slice_text(x, y, width, height, text)
words = text.split
result, current_text = [], words.shift
words.each_index {|i|
if current_text.sub!(/\ln/) { '' } != nil ||
self.text_size("#{current_text} #{words[i]}").width > width
result.push(current_text)
current_text = words[i]
else
current_text = "#{current_text} #{words[i]}"
end
result.push(current_text) if i >= words.size-1
}
result.each_index { |i|
draw_text(x, y + (height * i), width, height, result[i])
}
end
#--------------------------------------------------------------------------
# New Method: draw_save_blurb
#--------------------------------------------------------------------------
def draw_save_blurb(dx, dy, dw)
return if @header[:variables].nil?
reset_font_settings
change_color(normal_color)
variable_id = VEL::BLURB::BLURB_VARIABLE
return unless variable_id >= 0
varival = @header[:variables][variable_id]
if varival < 0
slice_text(dx, dy, dw, line_height, VEL::BLURB::UNDEFINED_BLURB)
end
if varival > VEL::BLURB::BLURB_MAX
slice_text(dx, dy, dw, line_height, VEL::BLURB::UNDEFINED_BLURB)
end
if varival <= VEL::BLURB::BLURB_MAX and varival >= 0
slice_text(dx, dy, dw, line_height, VEL::BLURB::BLURB_WORDS[varival])
end
end
#--------------------------------------------------------------------------
# Overwrite Method: draw_save_contents
#--------------------------------------------------------------------------
def draw_save_contents
draw_save_slot(4, 0, contents.width/2-8)
draw_save_playtime(contents.width/2+4, 0, contents.width/2-8)
draw_save_total_saves(4, line_height, contents.width/2-8)
draw_save_gold(contents.width/2+4, line_height, contents.width/2-8)
draw_save_location(4, line_height*2, contents.width-8)
draw_save_characters(0, line_height*5 + line_height/3)
draw_save_outfit(4, line_height*7, contents.width-8)
draw_save_column1(16, line_height*8, contents.width/2-48)
draw_save_column2(contents.width/2+16, line_height*8, contents.width/2-48)
draw_save_title(4, line_height*9, contents.width-8)
draw_save_blurb(4, line_height*10, contents.width)
end
end
#==============================================================================
# END OF FILE
#==============================================================================
Original script was sourced from...
https://rpgmaker.net/scripts/270/
Script requires Yanfly Ace Save Engine from...
https://yanflychannel.wordpress.com/rmvxa/menu-scripts/ace-save-engine/
If someone could let me know the exact code to get the party leader ActorID and pass that ID into variable 100 and the exact place to put that code in the above script it would be tremendously satisfying. If you can explain the how and why of it as well that would be even more gratifying.
Whatever the case may be please Help.
Thanks, Daede
P.S. I have thoroughly googled every variation of Set variable to ActorID and there are a handful of similar requests but none seem to have been answered, or at least not in anyway I could understand or replicate. Most just seem to end with using Control Variable via Common Event which is of no use in this circumstance that I can see.
Note: Edited to add source links to original scripts as per Mod advice.