Hello, I have a script to add pages in an event.
module Page_Plus
#Ici tu creer des pages de commandes
#pour remplir cette partie :
#Creer un event avec en page 1 la page que tu veut creer (les ineter, son graphics etc...)
#ajoute en DEBUT de page un appel de script : create_parametre_page
#execute cette event in game (le résultat n'a aucune importance, il faut faire en sorte que les condition soit remplis pour voir la page)
#cela creer un fichier texte dans ton dossier de jeu avec tout déjà configurer
#ici :
def self.page(id)
case id
when "Argent restant 2"
{:index_page => 1,
:condition => {:switch1_id => 0,
:switch2_id => 0,
:variable_id => 2,
:variable_value => 0,
:self_switch_ch => '',
:item_id => 0,
:actor_id => 0},
:graphic => {:tile_id => 867,
:character_name => '',
:character_index => 0,
:direction => 2,
:pattern => 0},
:move_type => 0,
:move_speed => 3,
:move_frequency => 3,
:walk_anime => true,
:step_anime => false,
:direction_fix => false,
:through => false,
:priority_type => 0,
:trigger => 0,
:list => [ [0,0,[]]]
}
when "Argent restant 3"
{:index_page => 2,
:condition => {:switch1_id => 0,
:switch2_id => 0,
:variable_id => 3,
:variable_value => 0,
:self_switch_ch => '',
:item_id => 0,
:actor_id => 0},
:graphic => {:tile_id => 867,
:character_name => '',
:character_index => 0,
:direction => 2,
:pattern => 0},
:move_type => 0,
:move_speed => 3,
:move_frequency => 3,
:walk_anime => true,
:step_anime => false,
:direction_fix => false,
:through => false,
:priority_type => 0,
:trigger => 0,
:list => [ [0,0,[]]]
}
end
end
#Ici tu définit les event a qui il faut ajouter des pages
#[id_map,id_event] => [page1,page2,...]
#page1 = page(1)
TABLE = {[2,49] => [page("Argent restant 2")]}
TABLE = {[2,50] => [page("Argent restant 3")]}
end
class Game_Map
def setup_events
@events = {}
@map.events.each do |i, event|
if Page_Plus::TABLE[[@map_id,event.id]] != nil
ajouter_page(event,Page_Plus::TABLE[[@map_id,event.id]])
end
@events[i] = Game_Event.new(@map_id, event)
end
@common_events = parallel_common_events.collect do |common_event|
Game_CommonEvent.new(common_event.id)
end
refresh_tile_events
end
def ajouter_page(event,param)
for i in 0..param.length-1
page = RPG::Event::Page.new
index = param[i][:index_page]
page.condition = make_condition_class(param[i][:condition])
page.graphic = make_graphic_class(param[i][:graphic])
page.move_type = param[i][:move_type]
page.move_speed = param[i][:move_speed]
page.move_frequency = param[i][:move_frequency]
page.walk_anime = param[i][:walk_anime]
page.step_anime = param[i][:step_anime]
page.direction_fix = param[i][:direction_fix]
page.through = param[i][:through]
page.priority_type = param[i][:priority_type]
page.trigger = param[i][:trigger]
page.list = make_list_class(param[i][:list])
event.pages.insert(index-1,page)
end
end
def make_condition_class(param)
cond = RPG::Event::Page::Condition.new
if param[:switch1_id] > 0
cond.switch1_valid = true
cond.switch1_id = param[:switch1_id]
end
if param[:switch2_id] > 0
cond.switch2_valid = true
cond.switch2_id = param[:switch2_id]
end
if param[:variable_id] > 0
cond.variable_valid = true
cond.variable_id = param[:switch2_id]
cond.variable_value = param[:variable_value]
end
if param[:self_switch_ch] != ''
cond.self_switch_valid = true
cond.self_switch_ch = param[:self_switch_ch]
end
if param[:item_id] > 0
cond.item_valid = true
cond.item_id = param[:item_id]
end
if param[:actor_id] > 0
cond.actor_valid = true
cond.actor_id = param[:actor_id]
end
return cond
end
def make_graphic_class(param)
graph = RPG::Event::Page::Graphic.new
graph.tile_id = param[:tile_id]
graph.character_name = param[:character_name]
graph.character_index = param[:character_index]
graph.direction = param[:direction]
graph.pattern = param[:pattern]
return graph
end
def make_list_class(param)
list = []
for i in 0..param.length-1
list.push(RPG::EventCommand.new(param[i][0],param[i][1],param[i][2]))
end
return list
end
end
class Game_Event < Game_Character
attr_reader :event
end
class Game_Interpreter
def create_parametre_page
event = $game_map.events[@event_id].event.pages[0]
texte = "{:index_page => 1,# A changer \n"
a = event.condition.switch1_valid ? event.condition.switch1_id : 0
texte += " "+" :condition => {:switch1_id => #{a},\n"
a = event.condition.switch2_valid ? event.condition.switch2_id : 0
texte += " "+" :switch2_id => #{a},\n"
a = event.condition.variable_valid ? event.condition.variable_id : 0
texte += " "+" :variable_id => #{a},\n"
a = event.condition.variable_valid ? event.condition.variable_value : 0
texte += " "+" :variable_value => #{a},\n"
a = event.condition.self_switch_valid ? event.condition.self_switch_ch : ''
texte += " "+" :self_switch_ch => '#{a}',\n"
a = event.condition.item_valid ? event.condition.item_id : 0
texte += " "+" :item_id => #{a},\n"
a = event.condition.actor_valid ? event.condition.actor_id : 0
texte += " "+" :actor_id => #{a}},\n"
texte += " "+" :graphic => {:tile_id => #{event.graphic.tile_id},\n"
texte += " "+" :character_name => '#{event.graphic.character_name}',\n"
texte += " "+" :character_index => #{event.graphic.character_index},\n"
texte += " "+" :direction => #{event.graphic.direction},\n"
texte += " "+" :pattern => #{event.graphic.pattern}},\n"
texte += " "+" :move_type => #{event.move_type},\n"
texte += " "+" :move_speed => #{event.move_speed},\n"
texte += " "+" :move_frequency => #{event.move_frequency},\n"
texte += " "+" :walk_anime => #{event.walk_anime},\n"
texte += " "+" :step_anime => #{event.step_anime},\n"
texte += " "+" :direction_fix => #{event.direction_fix},\n"
texte += " "+" :through => #{event.through},\n"
texte += " "+" :priority_type => #{event.priority_type},\n"
texte += " "+" :trigger => #{event.trigger},\n"
texte += " "+" :list => ["
texte += create_list_commandes_texte[11..-1]+"]\n"
texte += " "+"}"
File.delete("Pages_event#{@event_id}_map#{@map_id}.txt") rescue true
File.open("Pages_event#{@event_id}_map#{@map_id}.txt","a") do |file|
file.write(texte.to_s)
end
end
def create_list_commandes_texte
texte = ""
for i in 1..@list.length-1
texte += " "+" ["
texte += @list[i].code.to_s + ","
texte += @list[i].indent.to_s + ","
texte += @list[i].parameters.to_s
texte += "],\n" if i != @list.length-1
texte += "]" if i == @list.length-1
end
return texte
end
end
Only here is he blocks because the line 68 does not work unless I remove the line 69. Somebody could he tell me what he blocks or even to propose a better script. Thank you