Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Cursor Script
#1
Cursor Script
by Selwyn



INTRODUCTION
Selwyn @ RMXP.Org Sun Apr 09, 2006 Wrote:this allows to show a cursor with or without the highlight box. (if you don't want to show the highlight box, remove it from you windowskin)

create a cursor icon of 32*32 pixel, name it 'cursor' and put it in your game's Pictures folder.

paste the following code in a new section UNDER Window_Selectable



SCRIPT
The Script



TERMS AND CONDITIONS
Give credit, enjoy!
Reply }
#2
how can i switch it on and of ??
Reply }
#3
Selwyn did not create an on/off switch for this system. It's a case of either you use it, or not.

Technically, you could make a switch that only turned the cursor on by.....

...going into the initialize method of Window_Selectable and doing:
Code:
@cursor = Sprite_Cursor.new(x, y) if $cursor_switch == true

...going into the dispose method of Window_Selectable and doing:
Code:
@cursor.dispose if $cursor_switch == true

...going into the update method of Window_Selectable and doing:
Code:
update_cursor if $cursor_switch == true

... and retooling the update_cursor_rect for that class to accommodate an on/off switch.

I used $cursor_switch as a global switch for a convenient example basis.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]

Reply }
#4
thx alot dear VVulfman !
Reply }
#5
(04-07-2012, 08:48 PM)DerVVulfman Wrote: Selwyn did not create an on/off switch for this system.  It's a case of either you use it, or not.

Technically, you could make a switch that only turned the cursor on by.....

...going into the initialize method of Window_Selectable and doing:
Code:
@cursor = Sprite_Cursor.new(x, y) if $cursor_switch == true

...going into the dispose method of Window_Selectable and doing:
Code:
@cursor.dispose if $cursor_switch == true

...going into the update method of Window_Selectable and doing:
Code:
update_cursor if $cursor_switch == true

... and retooling the update_cursor_rect for that class to accommodate an on/off switch.

I used $cursor_switch as a global switch for a convenient example basis.


Sorry for the necroposting, but I didn't really understood what do you mean for "retooling the the update_cursor_rect" also, where should i put the switch? i mean, where to definite the number of the switch.
(This below is my signature, it's not part of the post/message)

I'm a male and italian indie game developer, spriter and musician.
I'm currently working on my own indie game, called Our Destiny.
Follow it on it's GameJolt page: https://gamejolt.com/games/ourdestinyofficial/449988

----Contacts----
Twitter: https://twitter.com/Andrea87Sky
SoundCloud: https://soundcloud.com/skycraft-team-official/tracks
YouTube: https://www.youtube.com/channel/UCjPA_e7...subscriber
Reply }
#6
Okay, I posted that pretty quickly... Confused seven years ago? I do have some bugs.... Let me correct, shall I?

FIRST, IT IS NOT IMMUNE TO THE F12 STACK ERROR!!!!! So the three alias statements in the Window_Selectable Class should be encapsulated like this:
Code:
if @selwyn_cursor_script_antistack.nil?
  alias initialize_cursor initialize
  alias update_cursor_moves update
  alias dispose_cursor dispose
  @selwyn_cursor_script_antistack = true
end

Now for my corrections....

Going into the initialize method of Window_Selectable class, replace...
Code:
@cursor = Sprite_Cursor.new(x, y)
update_cursor
...with this...
Code:
@cursor = Sprite_Cursor.new(x, y) if $cursor_switch == true
update_cursor if $cursor_switch == true
This will only let the cursor sprite be generated AND begin updating the cursor if the switch is turned on. If it isn't, no cursor.


Going into the dispose method of Window_Selectable class, replace...
Code:
@cursor.dispose
...with this...
Code:
@cursor.dispose if $cursor_switch == true
This will eliminate the cursor ONLY if the cursor switch is on. If there's no cursor and you try to dispose of it... *KE-RASH!!!*


NOW... for the removal/hiding of the RECTANGLE CURSOR... merely add...
Code:
cursor_width = 0 if $cursor_switch == true
...right before you draw the rectangle using this statement...
Code:
self.cursor_rect.set(x, y, cursor_width, 32)
Yes, this means it will be the 2nd from the last statement in the method. And it hides the rectangle cursor by making it literally 0 pixels in width.

For a little extra, we have to make sure the cursor doesn't have any issues being turned on/off, so go into the update method of the Window_Selectable class, and add...
Code:
@cursor = Sprite_Cursor.new(x, y) if @cursor.nil?
as the first line in the method.


And finally, going into the update method of Window_Selectable class, replace...
Code:
update_cursor
...with this...
Code:
update_cursor if $cursor_switch == true
This will only execute the cursor graphic update system if the switch is turned on.




Now all the time and code, I used the basic global switch of $cursor switch. That is a switch you can use in a map event. Like use the script call command and enter "$cursor_switch = true" to turn it on, and "$cursor_switch = nil" to turn it off. That means, you do not use the RPGMaker Switches to turn it on or off.

Using RMXP switches in this code can be problematic. That, I know.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]

Reply }
#7
(09-28-2019, 03:58 AM)DerVVulfman Wrote: Okay, I posted that pretty quickly...  Confused seven years ago?  I do have some bugs....  Let me correct, shall I?

FIRST, IT IS NOT IMMUNE TO THE F12 STACK ERROR!!!!!   So the three alias statements in the Window_Selectable Class should be encapsulated like this:
Code:
if @selwyn_cursor_script_antistack.nil?
 alias initialize_cursor initialize
 alias update_cursor_moves update
 alias dispose_cursor dispose
 @selwyn_cursor_script_antistack = true
end

Now for my corrections....

Going into the initialize method of Window_Selectable class, replace...
Code:
@cursor = Sprite_Cursor.new(x, y)
update_cursor
...with this...
Code:
@cursor = Sprite_Cursor.new(x, y) if $cursor_switch == true
update_cursor if $cursor_switch == true
This will only let the cursor sprite be generated AND begin updating the cursor if the switch is turned on.  If it isn't, no cursor.


Going into the dispose method of Window_Selectable class, replace...
Code:
@cursor.dispose
...with this...
Code:
@cursor.dispose if $cursor_switch == true
This will eliminate the cursor ONLY if the cursor switch is on.  If there's no cursor and you try to dispose of it... *KE-RASH!!!*


NOW... for the removal/hiding of the RECTANGLE CURSOR... merely add...
Code:
cursor_width = 0 if $cursor_switch == true
...right before you draw the rectangle using this statement...
Code:
self.cursor_rect.set(x, y, cursor_width, 32)
Yes, this means it will be the 2nd from the last statement in the method.  And it hides the rectangle cursor by making it literally 0 pixels in width.

For a little extra, we have to make sure the cursor doesn't have any issues being turned on/off, so go into the update method of the Window_Selectable class, and add...
Code:
@cursor = Sprite_Cursor.new(x, y) if @cursor.nil?
as the first line in the method.


And finally, going into the update method of Window_Selectable class, replace...
Code:
update_cursor
...with this...
Code:
update_cursor if $cursor_switch == true
This will only execute the cursor graphic update system if the switch is turned on.




Now all the time and code, I used the basic global switch of $cursor switch.  That is a switch you can use in a map event.   Like use the script call command and enter "$cursor_switch = true" to turn it on, and "$cursor_switch = nil" to turn it off.  That means, you do not use the RPGMaker Switches to turn it on or off.  

Using RMXP switches in this code can be problematic.  That, I know.


Now the cursor shows anyway when the switch is disabled but it don't move.

Also, I discovered that when it is active, like in a choice window or something, it spams the select sound from the system when i click the enter button, even if you are in another map or the choice windows is gone from ages. (only if i click that button)
(This below is my signature, it's not part of the post/message)

I'm a male and italian indie game developer, spriter and musician.
I'm currently working on my own indie game, called Our Destiny.
Follow it on it's GameJolt page: https://gamejolt.com/games/ourdestinyofficial/449988

----Contacts----
Twitter: https://twitter.com/Andrea87Sky
SoundCloud: https://soundcloud.com/skycraft-team-official/tracks
YouTube: https://www.youtube.com/channel/UCjPA_e7...subscriber
Reply }
#8
Then... you did something wrong or missed something. PMing the script (as it works in a demo on my end) to you.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]

Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Text Scroll Script - Enhanced DerVVulfman 23 22,499 02-18-2021, 04:16 AM
Last Post: DerVVulfman
   ACBS FIX SCRIPT #2: Advanced Cry Correction DerVVulfman 1 2,623 08-09-2019, 03:42 PM
Last Post: aeliath
   ACBS FIX SCRIPT #1: Victory Cries Patch DerVVulfman 1 2,618 08-08-2019, 02:53 PM
Last Post: aeliath
   Archived Script Listings DerVVulfman 9 21,983 01-08-2019, 04:27 AM
Last Post: DerVVulfman
   Spritesheet Generator Conversion Script DerVVulfman 0 2,588 11-21-2018, 04:48 AM
Last Post: DerVVulfman
   Neo Mode 7 Script by MGCaladtogel MGC 59 92,653 09-29-2017, 03:48 AM
Last Post: DerVVulfman
   Longer Script Calls LiTTleDRAgo 0 3,218 05-17-2017, 12:36 AM
Last Post: LiTTleDRAgo
   SLOLS: Snake Look-alike on Load Script Zeriab 3 8,196 05-14-2017, 06:25 PM
Last Post: LiTTleDRAgo
   Character Select Script Selwyn 3 7,196 03-07-2017, 04:14 AM
Last Post: JayRay
   ELSA (Event Layering Script Advance) JayRay 0 4,369 02-25-2015, 04:15 AM
Last Post: JayRay



Users browsing this thread: