Page 151 of 377
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 3:32 am
by nreen123
MohAlnoaimi wrote: ↑Thu Oct 20, 2022 9:56 pm
is there a way to make every statue to level 1000 since it take so long with spawning statues
You could use command bulk statues 1000 in InjectCheatF4.
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 6:41 am
by tympanicblock61
Devilisious wrote: ↑Thu May 27, 2021 8:41 am
Creater0822 wrote: ↑Tue May 25, 2021 6:29 pm
Devilisious wrote: ↑Mon May 24, 2021 8:01 am
Because I like sharing Idea's:
created a way to log anything I want. for now I used the map id and active username ;p.
also made the portals auto unlock while going through them
![Smile :)](./images/smilies/icon_e_smile.gif)
. maybe this will bring up some fun idea's for others
edit: For the people wondering why I showed the map id instead of the map name is because for people that understand code this is more logical
Nice! How and where in the code did you manage to invoke the GUI components?
I just took a text box, Made a function. And called that function in every map load. Its handy to know what u get back in values. So I use it to find and lock stuff that I want to use. I added the portal requirements in the same function so every portal opens up... there is probably better places to call the function tho..
i just saw this could you send the code if you still have it i would like to try and find a way to add it to cheats.js
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 7:10 am
by tympanicblock61
found a way to log stuff in a new chat
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 7:29 am
by tympanicblock61
![Image](https://cdn.discordapp.com/attachments/1011008506427605155/1034005340871733288/unknown.png)
working on currently
mob drop edit
inventory edit
skills edit
gui creator
shop edit
event logger
Chat console
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 7:47 am
by tympanicblock61
think i found a way for events
Edit1 :
this["com.stencyl.Engine"].engine.getGameAttribute("DNSM").h["FrendChatyDL1"] is the most recent chat message no matter what channel
Edit2:
web workers suck
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 11:28 am
by tympanicblock61
Code: Select all
const worker = new Worker(onmessage = function onevent(params) {
const bEngine = params.data.bengine
var event_name = params.data.event
while (true) {
if (event_name.toLowerCase() == "changemap") {
if (typeof old_map == 'undefined') {
old_map = bEngine.getGameAttribute("CurrentMap")
} else if (old_map != null) {
new_map = bEngine.getGameAttribute("CurrentMap")
if (new_map != old_map) {
var myFunction = JSONfn.parse(e.data.myFunc)
myFunction(new_map)
old_map = new_map
}
}
}
else if (event_name.toLowerCase() == "changeplayer") {
if (typeof old_user == 'undefined') {
old_user = bEngine.getGameAttribute("UserInfo")[0]
} else if (old_user != null) {
new_name = bEngine.getGameAttribute("UserInfo")[0]
if (new_name != old_user) {
var myFunction = JSONfn.parse(e.data.myFunc)
myFunction(new_name)
old_user = new_name
}
}
}
}
})
could not get this to work for the life of me, if anyone can make it work do tell me
original
Code: Select all
function onEvent(bEngine, event, func) {
while (true) {
if (event.toLowerCase() == "changemap") {
if (typeof old_map == 'undefined') {
old_map = bEngine.getGameAttribute("CurrentMap")
} else if (old_map != null) {
new_map = bEngine.getGameAttribute("CurrentMap")
if (new_map != old_map) {
func(new_map)
old_map = new_map
}
}
}
else if (event.toLowerCase() == "changeplayer") {
if (typeof old_user == 'undefined') {
old_user = bEngine.getGameAttribute("UserInfo")[0]
} else if (old_user != null) {
new_name = bEngine.getGameAttribute("UserInfo")[0]
if (new_name != old_user) {
func(new_name)
old_user = new_name
}
}
}
}
}
i needed a way for the while true loop to not pause the game
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 2:14 pm
by valleymon
If you want to achieve the while loop without pausing the game, look into promises and async/await. There are plenty of articles online that explain better than I would.
For this use case, I would argue you are better off just adding functionality to the engine's enterScene method and you won't need a Worker or loop at all. It's also nice to keep the Proxy pattern that all the other cheats were implemented with which allows cheats to be dynamically toggled on and off in a tidy way:
Code: Select all
let cheatState = {
// other cheat states
showmapinfo: false,
}
function setup() {
//..... other setup methods, add the new one in:
setupChangeMapProxy.call(this);
}
function setupChangeMapProxy() {
const bEngine = this["com.stencyl.Engine"].engine;
bEngine.enterScene = new Proxy(bEngine.enterScene, {
apply: function (originalFn, context, argumentsList) {
let oldMap = bEngine.getGameAttribute("CurrentMap");
Reflect.apply(originalFn, context, argumentsList);
if (cheatState.showmapinfo) {
let newMap = bEngine.getGameAttribute("CurrentMap");
console.log(oldMap, newMap);
// code invoked each time a map is entered and showmapinfo cheat is toggled on
}
}
});
}
registerCheat("showmapinfo", function () {
cheatState.showmapinfo = !cheatState.showmapinfo;
return `${cheatState.showmapinfo ? 'Activated' : 'Deactived'} map info display`;
});
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 6:30 pm
by tympanicblock61
valleymon wrote: ↑Mon Oct 24, 2022 2:14 pm
If you want to achieve the while loop without pausing the game, look into promises and async/await. There are plenty of articles online that explain better than I would.
For this use case, I would argue you are better off just adding functionality to the engine's enterScene method and you won't need a Worker or loop at all. It's also nice to keep the Proxy pattern that all the other cheats were implemented with which allows cheats to be dynamically toggled on and off in a tidy way:
Code: Select all
let cheatState = {
// other cheat states
showmapinfo: false,
}
function setup() {
//..... other setup methods, add the new one in:
setupChangeMapProxy.call(this);
}
function setupChangeMapProxy() {
const bEngine = this["com.stencyl.Engine"].engine;
bEngine.enterScene = new Proxy(bEngine.enterScene, {
apply: function (originalFn, context, argumentsList) {
let oldMap = bEngine.getGameAttribute("CurrentMap");
Reflect.apply(originalFn, context, argumentsList);
if (cheatState.showmapinfo) {
let newMap = bEngine.getGameAttribute("CurrentMap");
console.log(oldMap, newMap);
// code invoked each time a map is entered and showmapinfo cheat is toggled on
}
}
});
}
registerCheat("showmapinfo", function () {
cheatState.showmapinfo = !cheatState.showmapinfo;
return `${cheatState.showmapinfo ? 'Activated' : 'Deactived'} map info display`;
});
thx i will try to figure it out
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 6:38 pm
by tympanicblock61
ive had problems trying to console.log() any ideas why?
Edit:
nvm i got it printing to chat
Edit2:
it gets executed twice if theres no delay after printing to chat
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 10:39 pm
by sheldon37
So what is the general “safest” things to modify. I know there’s a risk of everything to an extent but not sure if anyone has ran tests to determine ban rates.
Re: Legends of Idleon
Posted: Mon Oct 24, 2022 11:40 pm
by valleymon
tympanicblock61 wrote: ↑Mon Oct 24, 2022 6:38 pm
ive had problems trying to console.log() any ideas why?
Edit:
nvm i got it printing to chat
Edit2:
it gets executed twice if theres no delay after printing to chat
If you are using console.log and expecting it to log to the node console, then you'll have no luck. That's because the contents of cheats.js are injected into a chrome process running idleon, and the "cheat" function is called with the context of the element in an iframe __idleon_cheats__. console.log therefore logs to the chrome console, which you can see if you go to chrome://inspect and add a configuration for localhost:32123
I actually added a config option in the injectcheatsF5 version to pass console.log back through to the node prompt because it was handy.
Re: logging twice, not sure, again I would inspect in chrome, put a breakpoint on the console.log line and step debug to see what is invoking it each time. It's only logging once for me, but again I'm using the F5 version, and there are some minor differences
Re: Legends of Idleon
Posted: Tue Oct 25, 2022 4:00 am
by tympanicblock61
so i have this
Code: Select all
function setupButtonProxyTest() {
function build_button(params) {
var x = params[0]
var y = params[1]
var width = params[2]
var height = params[3]
var button = document.createElement("button");
button.innerHTML = params[4];
if (x < 0) {
button.style.left = Math.abs(x)+'px';
}
if (x > 0) {
button.style.right = x+'px';
}
if (y < 0) {
button.style.bottom = Math.abs(y)+'px';
}
if (y > 0) {
button.style.top = y+'px';
}
if (typeof params[5] == 'function') {
button.onclick = function() {params[5]();};
}
button.style.position = 'fixed';
button.style.font = 'inherit';
button.style.width = width+'px';
button.style.height = height+'px';
document.body.append(button);
}
function my_func() {
window.alert("test")
}
build_button([10, -10, 50, 50, "nice", my_func])
}
setupButtonProxyTest()
which works but how would i do this and allow it to have this["com.stencyl.Engine"].engine bc ive tried to add that to the top but i get a error
![Image](https://cdn.discordapp.com/attachments/1030229938634231868/1034323324538454077/unknown.png)
Edit:
nvm it doesnt i have to manually run the function
meaning i can run it with a command in the console
Re: Legends of Idleon
Posted: Tue Oct 25, 2022 11:10 am
by sheldon37
Is there a way to revert a portal unlock?
Unlock portals unlocks W5 now lol
Re: Legends of Idleon
Posted: Tue Oct 25, 2022 10:51 pm
by valleymon
tympanicblock61 wrote: ↑Tue Oct 25, 2022 4:00 am
so i have this
Code: Select all
function setupButtonProxyTest() {
function build_button(params) {
var x = params[0]
var y = params[1]
var width = params[2]
var height = params[3]
var button = document.createElement("button");
button.innerHTML = params[4];
if (x < 0) {
button.style.left = Math.abs(x)+'px';
}
if (x > 0) {
button.style.right = x+'px';
}
if (y < 0) {
button.style.bottom = Math.abs(y)+'px';
}
if (y > 0) {
button.style.top = y+'px';
}
if (typeof params[5] == 'function') {
button.onclick = function() {params[5]();};
}
button.style.position = 'fixed';
button.style.font = 'inherit';
button.style.width = width+'px';
button.style.height = height+'px';
document.body.append(button);
}
function my_func() {
window.alert("test")
}
build_button([10, -10, 50, 50, "nice", my_func])
}
setupButtonProxyTest()
which works but how would i do this and allow it to have this["com.stencyl.Engine"].engine bc ive tried to add that to the top but i get a error
![Image](https://cdn.discordapp.com/attachments/1030229938634231868/1034323324538454077/unknown.png)
Edit:
nvm it doesnt i have to manually run the function
meaning i can run it with a command in the console
The function needs to be called in the correct context (context essentially defines the value of "this"). If you just execute a function in cheats.js, it's running in context space of it's own (not 100% sure, but appears to be created by chrome-remote-interface). If you look in main.js you see that window.executeCheat is defined as a function that executes the cheat function in cheats.js with the context:
Code: Select all
window.document.querySelector('iframe').contentWindow.__idleon_cheats__
That is the page element that contains the idleon application.
Function.call allows you to pass a context (or "this" value) to a function when executing that is something other than the default.
If you want this["com.stencyl.Engine"].engine to be available, you therefore need to ensure that the function is executed with the context of that page element, which as mentioned, is achieved by doing something like setupButonProxyTest.call(context, [arguments]) where context is the idleon application page element.
As you discovered, running it from the console makes it work, because the console is passing the correct context for you.
Hope that helps
Re: Legends of Idleon
Posted: Wed Oct 26, 2022 1:17 am
by tympanicblock61
yes this does help