CCommands 0.41 unstuck, fly, teleport console commands

CragrimCragrim REGISTERED Posts: 44
edited March 2015 in Mods
EDIT 2015-02-02: Mod system is currently broken so installing requires some careful text file editing.

CCommands is a tiny tiny mod with some extra console commands for survival mode
Can be used as cheat codes, debugging, help get you out if you fall in a hole or get stuck in terrain while playing survival.

Y8KRIoI.png

List of available commands:
» /coords - Shows your player coordinates.
» /tpx x y z - Teleport to exact coordinates for example /tpx 50000 10050 51000 will teleport you 1000 blocks from spawn!
» /tpr x y z - Teleport to relative coordinates, you need to enter 3 values separated by a space
» /fly - Toggle flying / flight mode
» /sethome - Save home location (not saved in world, so you can only use one for all saves)
» /home - Teleport to home location

Read this first please:
- Nerd Kingdom added a /unstuck command in a recent update. Try it first.
- /coords is not really needed anymore as you can press F2 twice to show your coordinates in the debug menu.
- If you get lost and can't find your way back to spawn type /tpx 50000 10050 50000 to return somewhat close to spawn. (spawn is randomized aprox 100-200 blocks around this location)
- Use /fly before teleporting. Otherwise its very easy to fall to your death or get stuck!
- Teleporting too far from spawn will disable terrain collision and you keep falling indefinitely so try to avoid that.
- If you get stuck in terrain first try typing:
/unstuck
If that doesn't work type:
/tpr 10 10 10
If it still doesn't work type:
/tpr 20 20 20
And so fourth...

I wanted to implement so that only ops can use these commands in multiplayer however there is no op list functionality implemented yet. Hence all the commented out code. Also I'm not skilled enough to do implement something like that, sorry.

Install instructions

Quick way that only works for version 0.8.2 Jan 30
Only use this if you're not using any other mods.
1. Extract the complete zip file into your SteamAppscommonTUG folder
2. Start Tug!

The way that 'might' work for newer versions
1. ONLY extract the file CCommands.lua into the folder SteamAppscommonTUGGameCoreScriptsMods if it does not exist, create it.
2. Open the file SteamAppscommonTUGGameCoreScriptsModesTUGGameMode.lua in a text editor like notepad, notepad2 or notepad++ (not Microsoft Word! it will mess it up)
3. Copy and paste the following text into line 19, between end and TUGGameMode Do not add or delete anything else.
include("Scripts/Mods/CCommands.lua")
It should look something like this:
0I3nkjs.png

or like this depending on which program you are using

a8a3hUZ.png
4. Start Tug!

Uninstall instructions
1. Delete CCommands.lua
2. Remove the line that you copy and pasted into TUGGameMode.lua in the previous step.

Download
Version 0.41 for Tug V0.8.2 Jan 30 updated 2015-02-02
https://dl.dropboxusercontent.com/u/368 ... nds041.zip


Old version (for Tug Indev v0.7.1 Nov 7)
(This mod system is currently broken, so don't follow this guide)
Installation instructions:

Latest tested version: Tug Indev v0.7.1 Nov 7

1. Locate your Steam Tug folder and open the file "mods.txt" you can find it here:
SteamSteamAppscommonTUGConfig
(The path before depends on where you installed steam)

2. In this file you need to add the following line "Mods/CCommands" so that it looks like this:
Use notepad or any other simple text editor like notepad2 or notepad++. (Not MSWord)
Mods
{
	"Mods/TestModScript"
	"Mods/CCommands"
	"Game/Survival"
	"Game/Creative"
	"Game/Core"
}
3. Download the zip file: https://dl.dropboxusercontent.com/u/368 ... ands04.zip
Tug Indev v0.7.1 Nov 7

4. Extract the mod in the Mod folder so that everything is placed as follows:
TUGModsCCommandsScriptsCCommands.lua
TUGModsCCommandsmanifest.txt

0L4x7mY.gif

Background...
I got myself in a predicament and was unable to get out of the terrain in survival so I wrote this mod in an attempt to get out. viewtopic.php?f=14&t=1754 No nasty cheats intended, however they're very helpful for glitchy situations.

Please don't expect this to work perfectly, remain stable or work in the future, I'm a nub :P I just wanted to share!

Best Regards
Cragrim
Y8KRIoI.png Extra commands with CCommands!

Comments

  • PamcakesPamcakes REGISTERED Posts: 738
    /spawn goat and /spawn cat are already commands, but just with spaces. :D

    but very helpful!
    That's a really cool shirt you have on.
  • CragrimCragrim REGISTERED Posts: 44
    Pamcakes wrote:
    /spawn goat and /spawn cat are already commands, but just with spaces. :D

    but very helpful!
    Oh! I never tried that for some reason. derp :)

    EDIT: I tried this again and apparently it doesn't work in InDev 0.7.1 Nov 7
    Jh3FCpR.png



    By the way, I tried to get some other commands to work without any luck. Excerpt from CCommands.lua:
    --not done
    function CCommands:TeleportCoordsFunction(args)
    	local player = Eternus.GameState:GetLocalPlayer()
    	--player:NKSetPosition(vec3.new(tostring(args[1]), tostring(args[2]), tostring(args[3])), false)
    	v1 = args[1].tonumber
    	v2 = args[2].tonumber
    	v3 = args[3].tonumber
    	
    	player:NKSetPosition(vec3.new(v1, v2, v3), false)
    	return true
    end
    
    --not done
    function CCommands:TeleportRelativeFunction(args)
    	local player = Eternus.GameState:GetLocalPlayer()
    	--player:NKSetPosition(player:NKGetPosition() + vec3.new(tostring(args[1]), tostring(args[2]), tostring(args[3])), false)
    	--NKError("You typed: "..tostring(args[1]).." and "..tostring(args[2]).." and ".. tostring(args[3]))
    	
    	v1 = args[1].tonumber
    	v2 = args[2].tonumber
    	v3 = args[3].tonumber
    	
    	player:NKSetPosition(player:NKGetPosition() + vec3.new(v1, v2, v3), false)
    	return true
    end
    

    What I'm trying to accomplish are the following commands
    /tpx x y z (teleport to exact position)
    /tpr x y z (teleport to position relative to current)

    I'm attempting to pass the arguments from the command line in a variable, convert the string into an integer(number) to use in a vector (vec3.new(x, y, z)) but I can't seem to get it to work. It works if I type in the numbers in the code (as done in the unstuck command) but not if I pass them in a function from a variable.

    I get this error message?

    dIB7BLf.png

    I'm probably just missing something obvious but maybe it needs to be declared in C++ before the lua interpreter? http://stackoverflow.com/questions/2376 ... onstructor :?:

    Cheers :)
    Y8KRIoI.png Extra commands with CCommands!
  • mercormercor REGISTERED Posts: 64 Seed
    Cragrim wrote:
    I get this error message?

    dIB7BLf.png

    I'm probably just missing something obvious but maybe it needs to be declared in C++ before the lua interpreter? http://stackoverflow.com/questions/2376 ... onstructor :?:

    Cheers :)

    Nice work with the mod. Stuck command could be very helpful when falling through the terrain.

    Can't try your code now, but the error message would imply that you are getting different amount of parameters from args, than the 3 parameters expected by vec3. You are either giving it too many, or too few. Are you giving integers or decimals for the slash command? Are you using the correct decimal separator? Console doesn't seem to support system locale. Or then it could just be that the parameters are separated bit differently into args, than what would be expected. Perhaps it splits values on both white space and decimal separators?

    Testing/debugging lua in-game seems to be a bit of pain. Or at least i have no idea how to do it effectively. But you might want to test your values, by giving v1, v2 and v3 default values just before using them if they are not defined/numbers. This should get you past the error message. After that just check the coordinates of the new vec3 after it's initialized to see which of the values were incorrect.

    Anyway, it's good practice to check all user given data before using it. Not that I would remember to do it myself all the time either :P
    Modder in making. Point of Interest mod - Now with GUI

    twitter: @mercorinred
  • CragrimCragrim REGISTERED Posts: 44
    Thank you mercor! Your comment got me to digging into and experiment a bit more.

    I tried declaring the variables as locals first adn then set them to the arguments. It didn't make it work but It removed the error message.
    local vX = 5.0
    local vY = 5.0
    local vZ = 5.0
    vX = args[1]
    vY = args[2]
    vZ = args[3]
    

    After that I figured it out. The function is expecting a "float" variable. So when it recieves an "integer" (number) it wont try to convert it, it will just ignore it without any error. One way to "force" convert an integer into a float is to perform a math operation. So added +1 -1 and now it works!
    function CCommands:TeleportRelativeFunction(args)
    	local player = Eternus.GameState:GetLocalPlayer()
    
    	local vX = 5.0
    	local vY = 5.0
    	local vZ = 5.0
    
    	vX = args[1]+1-1
    	vY = args[2]+1-1
    	vZ = args[3]+1-1
    	
    	player:NKSetPosition(player:NKGetPosition() + vec3.new(vX, vY, vZ), true)
    	return true
    end
    

    Theres probably a better way to do this :P

    EDIT: anyway I added the new commands to the download!

    EDIT2: Some more stuff that I noticed. When reloading assets, any errors with closed statements or the like will require you to reboot the game, else the assets won't update. Also any included code require a restart in order to be updated. I.e:
    include("Scripts/Core/Common.lua")
    include("Scripts/Characters/BasePlayer.lua")
    
    Y8KRIoI.png Extra commands with CCommands!
  • nocarenocare REGISTERED, Tester Posts: 92 Seed
    This is pretty awesome.

    Its actually
    /spawn "ItemName"
    

    This is definitely a nice tool to have.
  • reedooreedoo REGISTERED Posts: 151 Seed
    Holy moly - this was a life saver. I was off foraging, got lost way way out and then fell through the terrain while trying to navigate my way back. Was able to use the "/unstuck3" command, however when I got put back at the spawn point - terrain wasn't showing, when I moved I fell from a height and hit the terrain spawn point and took about 1/2 health damage.

    Still - now I can continue using the world instead of being stuck in the netherworld.
  • TcheyTchey REGISTERED Posts: 17 Seed
    I was very carefully exploring around my house, build not too far from my spwn point.

    Even with my care, i get lost ! House, farm, crafting stations, stocks of stuff, where were you !?

    This mod saved me. Thank you.
  • ZakeZake REGISTERED Posts: 216 Seed
    Thanks Cragrim, I'm working to make a honeybee mod and I used your mod to help me implement my /spawnbee command ("help" meaning I copied and pasted). Anyways I should certainly give credit where it's due!
    I think more than I say and say more than I do, but I do more than I used to and plan to continue.
    TUG modder (at least in the ounce of free time that occasionally flits by)
  • CragrimCragrim REGISTERED Posts: 44
    reedoo wrote:
    Holy moly - this was a life saver. I was off foraging, got lost way way out and then fell through the terrain while trying to navigate my way back. Was able to use the "/unstuck3" command, however when I got put back at the spawn point - terrain wasn't showing, when I moved I fell from a height and hit the terrain spawn point and took about 1/2 health damage.

    Still - now I can continue using the world instead of being stuck in the netherworld.

    I recommend using the /fly command before attempting any teleportation and then /fly again after the teleportation is complete. :)

    I tried to counteract the world not loading quick enough by adding a little to the height when using the /home command but it didn't work so well. Instead of falling through the world you get stuck in terrain above so it wasn't much help. Maybe if I added a timer that enables flying temporarily, checks for terrain loading in some way and then disables flying automatically.... well... I could do that. Maybe :P
    Zake wrote:
    Thanks Cragrim, I'm working to make a honeybee mod and I used your mod to help me implement my /spawnbee command ("help" meaning I copied and pasted). Anyways I should certainly give credit where it's due!

    Thanks but there is no need for any credit. Feel free to use anything you want, I'm a complete newbie at this anyway.
    The LUA I've learned comes from playing around in the ComputerCraft mod for Minecraft hehe http://www.computercraft.info/ :P
    (Tiny shout-out to dan200, thank you!)
    Y8KRIoI.png Extra commands with CCommands!
  • PixelDragon13PixelDragon13 REGISTERED, Tester Posts: 114 Seed
    When I saw this mod the first time, I thought meh, looks like cheating/hacking... Now I fell through the floor and quickly installed this mod, used /fly, /unstuck, /unstuck2, /unstuck3 and my world is recovered!!!! AWSOME mod! Thanks for making this.
    TUG Modder
    Twitter: @IKStreamIvo
    YouTube: IKStream!
    Site: Pixel's Web
  • johnycilohoklajohnycilohokla REGISTERED Posts: 283 Developer
    When I saw this mod the first time, I thought meh, looks like cheating/hacking... Now I fell through the floor and quickly installed this mod, used /fly, /unstuck, /unstuck2, /unstuck3 and my world is recovered!!!! AWSOME mod! Thanks for making this.

    It all depends how they are used :D

    I've made a tool for MC a good while ago to check the amount of resources generated in each chunks(and save to file), it was designed to debug world gen, but if could be used it to check which chunks are best to setup a quarry in or check if there was anything interesting in that chunk, like mob spawners or chest with good loot.
    While this tool was really useful to mod devs, modpack and map makers, it could also be used to cheat.
    My Blog
    jc.png
      yt.png  t.png  
  • Wilson423Wilson423 REGISTERED Posts: 24 Seed
    Is there a way to hotkey these commands?
  • Red AgliatorRed Agliator REGISTERED Posts: 307 Seed
    Wilson423 wrote:
    Is there a way to hotkey these commands?

    I seem to remember something about the mod-maker being able to add hotkeys to their mod. (I could be wrong, though.)

    If you're very motivated, you could try using a generic macro program to hotkey ENTER/flyENTER. No guarantee it'd work, but it might be a fun experiment.
Sign In or Register to comment.