Thank you Shaz and KockaAdmiralac_FINALLY! Yes, I usually using @map_id to represent current map id. What I want to achieve is makes all stone at a cave back to its shape after being destroyed. I am currently making mining game.
Ruby/RGSSx questions that don't deserve their own thread
RGSSx Script SupportYou might be better off grabbing one of the tile swapping scripts around. Using lots of events to cover a large area could cause lag issues. See how it goes, but that's an alternative for you if you find it's affecting performance.
@Rikifive
I don't know why it isn't working. I tried this code :
This code logs to the console the active state of a window.
On the other hand, what error is thrown when you try @actor_window.active ?
Is @actor_window defined?
I don't know why it isn't working. I tried this code :
class Scene_Test < Scene_Base def start super @window = Window_Test.new.show.activate @window.set_handler🙂ok, method🙂on_ok)) end def on_ok p @window.active @window.activate p @window.active endend class Window_Test < Window_Selectable def initialize super(0, 0, 100, 100) endend
On the other hand, what error is thrown when you try @actor_window.active ?
Is @actor_window defined?
Actually, I am about to join a contest that prohibits me using custom script. Maybe later if I want to continue to work with the game. Maybe I'll break the mine into parts or limiting stones that can be destroyed. Thanks again Shaz.
@KockaAdmiralac_FINALLY
When I tried:
class Sprite_Cursor < Sprite(...) def initialize(viewport = nil , x , y) (...) if SceneManager.scene_is?(Scene_Menu) if @actor_window.active @c_p = [-@cw + CURSOR_POSITION[0] + 180,CURSOR_POSITION[1]] #RIGHT else @c_p = [-@cw + CURSOR_POSITION[0],CURSOR_POSITION[1]] # LEFT end else @c_p = [-@cw + CURSOR_POSITION[0],CURSOR_POSITION[1]] # LEFT end(...)it threw that on me upon opening main menu:
--------------------------------------------------------------
Did I do something wrong?
There is more info about my problem:
The problem is that, the status window in near the left border, and the cursor goes off (completely), which is weird, so I'd like to make it to be on the right side when going to party window. If it's impossible, then it's fine, I'll find a workaround for it.
Here is how it looks: (don't mind the mess)
Here's the script.
and my part, where it changes position:
When I tried:
class Sprite_Cursor < Sprite(...) def initialize(viewport = nil , x , y) (...) if SceneManager.scene_is?(Scene_Menu) if @actor_window.active @c_p = [-@cw + CURSOR_POSITION[0] + 180,CURSOR_POSITION[1]] #RIGHT else @c_p = [-@cw + CURSOR_POSITION[0],CURSOR_POSITION[1]] # LEFT end else @c_p = [-@cw + CURSOR_POSITION[0],CURSOR_POSITION[1]] # LEFT end(...)it threw that on me upon opening main menu:
--------------------------------------------------------------
Did I do something wrong?
There is more info about my problem:
The problem is that, the status window in near the left border, and the cursor goes off (completely), which is weird, so I'd like to make it to be on the right side when going to party window. If it's impossible, then it's fine, I'll find a workaround for it.
Here is how it looks: (don't mind the mess)
and my part, where it changes position:
Code:
class Sprite_Cursor < Sprite include MOG_MENU_CURSOR #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- def initialize(viewport = nil , x , y) super(viewport) @cursor_image = Cache.system($game_system.menu_cursor_name.to_s) @frame_max = (@cursor_image.width / @cursor_image.height) rescue 1 @frame_range = @frame_max > 0 ? (@cursor_image.width / @frame_max) : 1 @frame = 0 ; @ca_speed = CURSOR_ANIMATION_SPEED self.bitmap = Bitmap.new(@frame_range,@frame_range) self.z = 10000 ; self.opacity = 0 ; @cw = self.bitmap.width / 2 if SceneManager.scene_is?(Scene_Menu) && @actor_window < HERE IT STARTS @c_p = [-@cw + CURSOR_POSITION[0] + 180,CURSOR_POSITION[1]] < RIGHTY else @c_p = [-@cw + CURSOR_POSITION[0],CURSOR_POSITION[1]] < LEFTY end @mx = [0,0,0] ; refresh_animation(true) ; update_move end(...) rest of script
That should gp into its own thread I think because you are now having a problem with a certain script...
Well... Anyway you're right ~ For now I'll leave it be here and wait for @KockaAdmiralac_FINALLY, perhaps he'll know the answer ~ if not, then I'll move it to its own thread and stop spamming here.
SOLVED.
Are you sure you solved it?
Because I don't know if you understood the hierarchy of the displaying objects...
The main object that can display something is Bitmap.
Window is a Bitmap with windowskin, and Sprite is also a Bitmap, with it's own specifications.
Scenes are the controllers of Windows and Sprites.
But from a Sprite you can't control a Window, nor reverse (at least not USUALLY)
You placed @actor_window in the mouse SPRITE.
But, that Sprite is controlled by the Scene (in this case, Scene_Menu), and that Sprite has really no idea what Windows are.
So, you must put your code in the object that knows what are Sprites and what are Windows, and that is SCENE (in this case, Scene_Menu)
So, if you want to constantly check what window is active, you can do something like following :
Because I don't know if you understood the hierarchy of the displaying objects...
The main object that can display something is Bitmap.
Window is a Bitmap with windowskin, and Sprite is also a Bitmap, with it's own specifications.
Scenes are the controllers of Windows and Sprites.
But from a Sprite you can't control a Window, nor reverse (at least not USUALLY)
You placed @actor_window in the mouse SPRITE.
But, that Sprite is controlled by the Scene (in this case, Scene_Menu), and that Sprite has really no idea what Windows are.
So, you must put your code in the object that knows what are Sprites and what are Windows, and that is SCENE (in this case, Scene_Menu)
So, if you want to constantly check what window is active, you can do something like following :
Code:
class Scene_Menu < Scene_Base alias :rikifive_random_alias_update_1Mp0 :update # This method below is called upon initializing, that means, @actor_window is defined, but on every 1/60 of a second # This may not be a good idea to put this code here, since it may bug up the whole scene, but I did not read the whole script, # so I don't know which method is better for putting this in. Maybe you can find out. def update rikifive_random_alias_update_1Mp0 if @actor_window.active # Here, control the Sprite else # Some more controlling end endend
@KockaAdmiralac_FINALLY
If your internet stutters resulting in a double posting of the same thing, then just report your second post (the Report button is bottom right, near the Multiquote button) and ask the mod for this forum to delete it for you.
If your internet stutters resulting in a double posting of the same thing, then just report your second post (the Report button is bottom right, near the Multiquote button) and ask the mod for this forum to delete it for you.
@KockaAdmiralac_FINALLY I'm not sure if it's solved solved, but it's at least solved. =]
By that I mean ~ there is this
replaced with this:
and it works.
I'm not sure what to do with your code though, I pasted that below that script and it crashed upon launching game. =P
By that I mean ~ there is this
def update_cursor_position return if !can_update_cursor_position? x_v = [0,0] if SceneManager.scene_is?(Scene_Battle) x_v = [-self.viewport.ox, self.viewport.rect.y] if self.viewport != nil end x_e = (self.cursor_rect.x + self.x) - self.ox $game_temp.menu_cursor[1] = 2 ; $game_temp.menu_cursor[2] = x_e + x_v[0] y_e = (self.cursor_rect.y + self.y + self.cursor_rect.height / 2) - self.oy $game_temp.menu_cursor[3] = y_e + x_v[1] end
def update_cursor_position return if !can_update_cursor_position? x_v = [0,0] if SceneManager.scene_is?(Scene_Battle) if self.viewport != nil x_v = [-self.viewport.ox, self.viewport.rect.y] end end x_e = (self.cursor_rect.x + self.x) - self.ox if self.class == Window_MenuStatus x_e += self.width - 24 + 200 end $game_temp.menu_cursor[2] = x_e + x_v[0] y_e = (self.cursor_rect.y + self.y + self.cursor_rect.height / 2) - self.oy $game_temp.menu_cursor[3] = y_e + x_v[1] $game_temp.menu_cursor[1] = 2 end
I'm not sure what to do with your code though, I pasted that below that script and it crashed upon launching game. =P
@Rikifive : My code isn't made for usage, it's made for demonstration purposes, so I'm not surprised that it does not work.
@ksjp17 : Oh, I didn't know that, thanks. I reported both posts now.
@ksjp17 : Oh, I didn't know that, thanks. I reported both posts now.
KockaAdmiralac_FINALLY Hahaha my bad! xD
So if you don't have any objections about current solution, then it's solved. =]
Thank you for your time and helping me! =]
So if you don't have any objections about current solution, then it's solved. =]
Thank you for your time and helping me! =]
I feel so stupid for asking this, but hey, I'm still learning.
Question: How to use '>' '<' etc. in 'case'?
Example: When using condition 'if' I can put for example 'if $game_variables[1] <= 7' how to translate '<=' to be able to use that in 'case' ~> 'when'?
case $game_variables[1] when <= 7 <<< translate 7! when 8 8! when >= 9 <<< translate 9!end What I'm trying to achieve: Well... If certain variable is less or equal 7 , then it does one thing; when it's equal 8 - does second thing; when it's 9 or more then does third thing.
Thank you in advance.
Question: How to use '>' '<' etc. in 'case'?
Example: When using condition 'if' I can put for example 'if $game_variables[1] <= 7' how to translate '<=' to be able to use that in 'case' ~> 'when'?
case $game_variables[1] when <= 7 <<< translate 7! when 8 8! when >= 9 <<< translate 9!end What I'm trying to achieve: Well... If certain variable is less or equal 7 , then it does one thing; when it's equal 8 - does second thing; when it's 9 or more then does third thing.
Thank you in advance.
a = $game_variables[1]case awhen a >= 7#do_somethingwhen a <= 8#do_something_elseelse#don't do somethingendLike that, right?
It doesn't read "when's" with '<' '>' at all.
I did that
a = $game_variables[1] case a when a <= 7 7! <<< actually does nothing when a = 8 8! < it works when a >= 9 9! <<< actually does nothing end
Nvm. I figured it out.
ANSWER: just putting '..'
case $game_variables[1] when 0..7 7! when 8 8! when 9..99~ 9!end That's all, thanks for trying though.
I did that
a = $game_variables[1] case a when a <= 7 7! <<< actually does nothing when a = 8 8! < it works when a >= 9 9! <<< actually does nothing end
Nvm. I figured it out.
ANSWER: just putting '..'
case $game_variables[1] when 0..7 7! when 8 8! when 9..99~ 9!end That's all, thanks for trying though.
Why did you put ! on the lines? ! doesn't do anything, and I'm a bit surprised it didn't give you an error. ! means not, but you use it before something, not after.
< means "is less than"
= means assign. == is compare. So you should have == 8, not = 8. a = 8 will always return true, because it will always succeed in changing the value of a to 8.
You don't say case a and then when a < 3
Anyway - here's the correct syntax for what you're trying to do.
Try this:
case $game_variables[1] when 0..7 7 when 8 8 else 9endYou know, you could also look this up in the help file. F1 and go to Search, then type in Case. It's under Control Structures and it gives you an example.
< means "is less than"
= means assign. == is compare. So you should have == 8, not = 8. a = 8 will always return true, because it will always succeed in changing the value of a to 8.
You don't say case a and then when a < 3
Anyway - here's the correct syntax for what you're trying to do.
Try this:
case $game_variables[1] when 0..7 7 when 8 8 else 9endYou know, you could also look this up in the help file. F1 and go to Search, then type in Case. It's under Control Structures and it gives you an example.
Ninja'd =P
the 7!; 8!; 9! are just examples, it doesn't mean anything here, I just wanted to state it should be 7! here 8! here etc. I know it'd not work.
The question was just about using these <>.
I found the asnwer in the base scripts. =]
Thank you for replying anyway, sorry I didn't find that sooner.
the 7!; 8!; 9! are just examples, it doesn't mean anything here, I just wanted to state it should be 7! here 8! here etc. I know it'd not work.
The question was just about using these <>.
I found the asnwer in the base scripts. =]
Thank you for replying anyway, sorry I didn't find that sooner.
I actually more use ?: operator
b = a <= 7 ? 7 : a == 8 ? 8 : 9This code does that b is 7 when a is less than 7, b is 8 when a is 8 and b is 9 when a is greater than or equal to 9
b = a <= 7 ? 7 : a == 8 ? 8 : 9This code does that b is 7 when a is less than 7, b is 8 when a is 8 and b is 9 when a is greater than or equal to 9
Which is nice if you're comfortable enough with scripts to understand what that means. For a beginner, something less compact but easier to understand is better.
Yeah, you're right.
But still does not mean that they don't need to learn what ?: is.
I found myself editing my older scripts with this just to compress the code, so I think maybe someday the great scripter Rikifive would look at his old scripts and say :
"What did I do with case and when when I could just do this with one ?: operator???"
So that's why I mentioned ?: operator
But still does not mean that they don't need to learn what ?: is.
I found myself editing my older scripts with this just to compress the code, so I think maybe someday the great scripter Rikifive would look at his old scripts and say :
"What did I do with case and when when I could just do this with one ?: operator???"
So that's why I mentioned ?: operator
Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/