• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Eevee Expo's webhost has been having technical issues since Nov. 20th and you might be unable to connect to our site. Staff are also facing issues connecting, so please send a DM to Cat on-site or through Discord directly for faster service!
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:
Expand Collapse Copy
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:
Expand Collapse Copy
class MyClass
	alias old_myMethod myMethod
	def myMethod
	  Kernel.pbMessage("b")
	  old_myMethod
	end
end

And say
Code:
Expand Collapse Copy
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:
Expand Collapse Copy
alias mej_whatevermyscriptdoes_myMethod myMethod
And Marin would do the same, thus avoiding any potential conflicts
 
Back
Top