• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Resource icon

Tutorial How to: User-friendly code and Plug & Play v1.0

Marin submitted a new resource:

How to: User-friendly code and Plug & Play - A quick tutorial for making your code more user friendly and Plug and Play.

I myself absolutely suck(ed) at making scripts Plug and Play/user-friendly, and making it easy for people to implement a script/resource of mine. A perfect example of that is my old generation 7 project.

I saw someone suggest a tutorial on how best to make Plug and Play scripts, so let's get started.


[tabs][tab=Plug and Play]1.) Classes can be overwritten and added to from elsewhere.
Let's say you want to add an attr_accessor to the PokeBattle_Trainer class...[/tab][/tabs]

Read more about this resource...
 

mej71

Novice
Member
Joined
Mar 29, 2017
Posts
15
Just a slight suggestion, you should try to make your alias names something unique to your public script.
For instance, if made a public script that had
Code:
class MyClass
	alias old_myMethod myMethod
	def myMethod
		Kernel.pbMessage("a")
		old_myMethod
	end
end

And then Marin made a public script that you put below that edits that same class
Code:
class MyClass
	alias old_myMethod myMethod
	def myMethod
	  Kernel.pbMessage("b")
	  old_myMethod
	end
end

And say
Code:
MyClass.new.myMethod
We wind up with the first aliased method infinitely calling itself. The solution is to use unique alias names. In this instance, I might put
Code:
alias mej_whatevermyscriptdoes_myMethod myMethod
And Marin would do the same, thus avoiding any potential conflicts
 
Back
Top