This is fairly simple to do utilizing Common Events. It will take a couple steps. I will be assuming your item only turns a Switch on and off and has no other stipulations.
First off, make sure in your PBS, your item has "FieldUse = Direct" as one of its lines. Otherwise the item will not activate by clicking on it in the bag.
Part two is making the Common Event. Common Events are made just like normal events (like doors, trainer battles etc) but have a trigger that activates them. Go to the Common Event tab in the Database, select an empty one and make an event that looks like this.
Conditional Branch : Switch [0031: Shiny Wild Pokemon] == ON
Control Switches: [0031:Shiny Wild Pokemon] == OFF
Text: Your item is turned off. Wild Pokemon are no longer shiny.
Else
Control Switches: [0031: Shint Wild Pokemon] == ON
Text: Your item is turned on. Wild Pokemon are now shiny.
Branch End
Basically, make a Conditional Branch event with the condition being the event you are switching on and off is ON. When this condition is met, the event will turn off the switch. When it is not met, the event will turn on the switch. Replace the switch with the switch you are trying to turn on and off. You should include some text to know if the switch is actually switching or not, especially while testing.
The final step is making the script for the item. All you have to do is make the item call the common event.
Code:
ItemHandlers::UseInField.add(:OLDSEAMAP, proc { |item|
pbCommonEvent(3)
next true
})
And thats it. This will keep the bag open when you use the item. If you want the bag to close on use, you need to add an additional line, which looks like this:
Code:
ItemHandlers::UseFromBag.add(:OLDSEAMAP, proc { |item|
next 2
})
ItemHandlers::UseInField.add(:OLDSEAMAP, proc { |item|
pbCommonEvent(3)
next true
})
Remember to use your item name, switch name and Event Number. Also this is all assuming version 20 or 20.1.