[XP] Help with script aliasing

Started by Memor-X, June 17, 2012, 02:50:03 am

Previous topic - Next topic

Memor-X

i've been trying to get my XGrid script done for Nexis Core and i've been having some problems in it, 2 problems infact

my first problem is with this script

class Xgrid

def initialize

@check = []
@check[2] = 1

end

def check_active(id)

return @check[id]

end

end



class Scene_Map
 
alias update_first_1 update
def update
update_first_1
   
if $game_switches[7] == true
     
# Sets Event Graphics
for event in $game_map.events.values
     
if $xgrid.check_active(event.id) == 1
$game_map.events[event.id].turn_left
#p "chnaged"
elsif $xgrid.check_active(event.id) == 0
$game_map.events[event.id].turn_down
end
     
end
end
end
end


the above is a test script i've been running outsidemy project, how it works is that when your on a map, if Switch 7 is true, then go though every event checking what value check_active(), if the return value is 1 then the even turns left, if its 0 then it turns down

the idea is that switch 7 only goes to true when your in a map that i want the events to be checked like this, ie, the XGrid and those events work differently than any other event,

now the problem is that $game_map.events[ID].turn_left isn't working, the commented line fires off when i have it uncompensated but event 2 (the one marked as 1 in the XGrid class @check array, i now that .turn_left and .turn_down works cause i used them in call_script with an event but i couldn't get them to work in an Auto-Start or Parallel Process event so i then tried this

----------------------------------------------------------------------

the second problem is that i want a window to appear on screen like a HUD when a variable is true (i can create a separate system for switching the value of the variable later) the but when i alias update in Scene_Map i cant seem to work out how to create the window without it being recreated all the time (and that normally starts to slow down the game very quickly) and i need it created before the check if the variable is true cause if it isn't the window is disposed and obviously there'll be an error if the variable isn't the right data type (instance of Window_Base), i even tried aliasing main in Scene_Map but the window only showed up when the variable is true after i went into like the menu, i know how to put text in and all but the initial creation is stumping me, how do i get this window created

KK20

I don't understand the first problem. I got it working fine in a test project, no edits. Is there some kind of method that you are doing that I'm not aware of?

As for the second, it could look something like this:
if $game_switches[20] #the variable is TRUE
  @window = MyWindow.new if @window.nil? #create window ONCE
  @window.update
elsif !@window.nil? #the variable is FALSE and a window exists
  @window.dispose
  @window = nil
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Memor-X

thanks for your help, with my first problem you did help fix it, when you said you got the code working in a blank project i went and tested that out myself and saw it did work, i then went to remove every script to see if another script was interfering with it, in the end i found out it was my own stupidity, the even in my project that wouldn't change direction had Directional Fix on so i had to just create an attrib_accessor for @direction_fix in Game_Character 1 and switch this to false before my code went then turn it back to true

as for my second problem, you fixed that, i never though of that second line you used, i've seen it before in C++ basics but when i code, i don't normally give a variable a value when i create it and i certainly dont use a method like that as a conditon checker, i normally just use normal if statements

anyway, thanks for your help