Developer cheats¶
This section is not a warning against using plugins to cheat, since the plugin moderation process will prevent that, but rather it is a guide for how you are allowed to "cheat" the game when you are developing plugins.
Info
These cheat commands are not available in the Live game environment. Don't rely on their output to support plugin logic, unless you are developing a plugin to assist development, for use only in the development environment.
Previous tutorial¶
This tutorial assumes you have already completed the previous tutorial, and have a main.lua file with UI elements, config lookup, event subscription, and database storage in which to copy snippets of code.
Objectives¶
- What cheats are and when you can use them
- Common cheats for assisting in plugin development
- Integrating cheats into plugins for testing
What are cheats¶
Cheats are tools that are available while in the plugin developer environment, for the purpose of testing your plugins. They give you control over aspects of the game that are not available in normal gameplay, such as giving you items to be able to test how they interact with your plugin, or resetting your progress for a quest so that you can test a guide for it.
Cheats are entered into the client console, they will not work on the live servers, and any progress they give to your character will not be transferred back to the live servers (or any other progress while in the developer environment). Some generally useful cheats for plugin testing are:
!resetsavewill make your character in the developer environment reset to a fresh start the next time it is logged in!allinonewill unlock a lot of account progression varplayers!godmodewill make your character unkillabale!tele <coords>will teleport your character to a specified set of coordinates
The CTRL+SHIFT+click option for teleporting that has already been mentions is also a developer cheat, as it does not work in the live game.
Warning
Cheat commands are logged on the server.
Any account found to be abusing these commands may be subject to a temporary or permanent account ban.
These cheats are intended for plugin development use only.
Cheats can also be run from plugins in the developer environment by using the ExecuteConsoleCommand() function from Lua.
Setting variables¶
This command lets you set variables related to your character in the developer environment, such as locking or unlocking content. For example
Example
This example cheat must be entered into the console, not into the plugin script.
This will set the number of dragon harpoons on the relevant collection log to be 100. You can view the list of variables with the console command pan VarPlayer or pan VarClient, which can be set with !setvar or !setvarc respectively. You can verify that this cheat has worked by opening: Adventures > Beasts > Boss Info > Flesh-hatcher Mhekarnahz > Collection.
Giving items¶
The developer environment is separated from the Grand Exchange, so if you need to get an item to test how it works with your plugin then you cannot simply buy it. Instead, use the !give cheat to simply spawn the item directly. The command should be followed by the configName of the item, which doesn't always match the display name. The configName can be found in the list created by the pan Obj console command. For example the configName for bones is just bones, but ranged_darkbow_t90_augmented is not an item of the same name.
For example, to give your character some bones to feed to the dog, enter into the console the following command:
Example
This example cheat must be entered into the console, not into the plugin script.
Teleport¶
In testing of this tutorial plugin it was necessary to find a stray dog, and the NPCEntity information allowed the plugin to display the stray dog's coordinates. The !tele cheat can be used to teleport directly to a specified set of coordinates. These can be combined to have your plugin directly teleport you to the coordinates of the dog that it finds.
To integrate this into your plugin, changes must be made to the callback functions for pressing the button, detecting dogs, and minimenu actions. This requires 3 total changes to the plugin. It is recommended to read through these as you copy them, so you have an idea of what they will do.
Example
-- Code section 7 version 4
-- When the button is pressed: Find all nearby NPCs that match the config and go to the last one
local function buttonPress()
localDogs = NPCList.ByName(strayDogName)
local coords = "0,50,52,12,53"
for _,npc in pairs(localDogs) do
myText.content = "You should pet the dog"
coords = tostring(npc.coordGrid)
end
ExecuteConsoleCommand("!tele "..coords)
end
myButton:Subscribe(ui.Hook.ONBUTTONPRESSED, buttonPress)
-- Code section 10 version 2
-- Check every server cycle for dogs
local function checkForDogs()
local localDogs = NPCList.ByName(strayDogName)
if #localDogs==0 then
myButton.label = "404 error dog not found"
else
myButton.label = "Take me to the dog"
end
end
Event.ServerLogic.Subscribe("serverLogicEvent",checkForDogs)
This code changes the function and text on the button. The text now says that it will take you to the dog once it has found a dog, and the function executes a console command that teleports you to the dog that has been found. All the more efficient for getting level 99 in your dog-petting skill.
If it doesn't find a dog, see if you can follow what it will do. And then you can test what happens when you run the plugin to see if you were right.
Finishing up¶
There is one final example for this tutorial, which is to replace the minimenu interaction code with the following:
Example
-- Code section 11 version 3
-- Check every minimenu interactions with dogs
local function checkForMinimenu(event)
if event.entry.npcData~=nil and event.entry.npcData.entity.config.name==strayDogName and event.entry.verbText=="Pet" then
numberOfPets = numberOfPets + 1
myText.content = formatStr("You have pet the dog<br>It is happy<br>Your streak is {}",numberOfPets)
elseif event.entry.npcData~=nil and event.entry.npcData.entity.config.name==strayDogName and event.entry.verbText=="Shoo away" then
numberOfPets = 0
myText.content = "You have shoo'd the dog<br>You monster<br>You deserve this"
ExecuteConsoleCommand("!tele 0,6,10,30,34")
myButton:Unsubscribe(ui.Hook.ONBUTTONPRESSED)
Event.NPCEntityAdded.Unsubscribe("dogAppearsEvent")
Event.NPCEntityRemoved.Unsubscribe("dogDisappearsEvent")
Event.ServerLogic.Unsubscribe("serverLogicEvent")
myButton.label = "Congratulations<br>You have completed the tutorial"
end
end
Event.MiniMenuEntrySelected.Subscribe("minimenuEvent",checkForMinimenu)
No guidance is given for what this code does, you should just try it and see. Surely nothing bad can happen...
Tutorial complete!¶
There are no further steps. There is a tutorial complete state that the plugin can reach if you do the correct actions and trigger the correct events. See if you can read the above code to reach it.
Even more?¶
Just because you have finished the tutorial it doesn't mean you are done with making plugins. Hopefully following along has given you the information that you need to take your plugin idea and turn it into a reality. But if you really want to play around more before starting work, here are a number of fun ideas that you could adapt this plugin to do:
- Make something different happen when you give the dog a bone.
- Select an NPC at random and then time how long it takes you to go and talk to them.
- Prevent the player from leaving a given chunk (or punish them if they do).
- Calculate the completion percentage of quests, collection logs, or any other tracked information.