SladeTama wrote: ↑Thu Jul 08, 2021 8:34 pm
Not sure the difference between a proxy and regular function. Are proxy functions safer than regular functions? Or something? I donno anything about coding. If I wasn't scared of IP Logging on accounts, i'd probably make another to test out safety of each. If you know that accountoptions or whatever is what changes when you get banned, could you make a code that when turned on constantly checks that code and gives you a warning if you get shadowbanned? Then just tone down whatever you were using till you don't get shadowbanned. Does item editing shadowban instantly? For Instance Changing small balloons to the same xp big balloons give. The thing that gets me is, if I saved up like 100 4 hour time candys and then just spammed them back to back on a legit character, would it shadowban said character for leveling too fast.
Yeah great questions, let's start things off with proxy functions vs so-called regular functions:
So regularly when you're coding stuff, these so-called normal functions basically speak for themselves. They are basically tools aka black boxes that allow stuff to happen when you call them, for example the function mean that takes an Array of two integers and calculates the mean for you.
Here in this game, iBelg has designed a dictionary named
cheats
, and created the function
registerCheat()
, which two arguments (e.g. inputs) are basically the cheat command's name and a function, which will then be added to the dictionary. That explains the syntax in which we write our cheat commands.Now these cheat commands that we can execute in-game, are basically these regular functions. Basically a tool that executes a bunch of code upon being called.
Proxy-functions are different, in the sense that you're looking to change the behavior of an existing object or even existing function. We'll start with iBelg's Currencies proxy to analyse what's happening:
So a Proxy function has a bunch of flavors (where I only know the three versions on which iBelg gave demos). With the colosseum cheat we want the lowest value to be 1 (and not 0), as well as this variable value never decreasing.
So we define a Proxy that takes in the currencies object from the game, and we
get
to obtain the
obj
and
prop
, which are basically the data object and dictionary key. When the object has a key named
ColosseumTickets
, we want to trap its value either equivalent to itself, otherwise always at least 1. With the
set flavor we're looking for the value, which we do not want decreased. Here I gotta admit that I'm not sure why the teleports doesn't require any checking, whereas the tickets do.
This new Proxy, which is technically a value trapping mechanism, is then given to the currencies object, which in this case allow these values to keep the states that they're in.
Then at the very bottom, where we define the actual cheat command, all we have to do is to create a swtich between
true
and
false
on the respective boolean value that is being tied with the Proxy function. During each cheat function call, the
cheats()
function is re-executed, which in turn re-executes the Proxy function that makes the magic.
The last flavor I know is the
apply
, where I'll use a command of my own to explain:
Now what we're doing instead of trapping a value, is trapping a function's behavior. If you look inside Z.js you'll find the function
_customBlock_CauldronStats()
that comes some if-else. The noticeable thing about this function is that its 0th argument tells the function which thing it's doing, e.g. cauldron cost, bubble cost etc...
So with this Proxy function we're effectively looking at the 0th parameter, each time this function is being called. Upon detecting a call where the 0th parameter equals a certain thing that we're interested in, we'll want the function to return something that
we like it to return, instead of the original thing that it should do and return. When the 0th argument doesn't meet anything that we're interested in, we'll allow it to function as normal by returning the original function, context and argument list.