+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: A simple E2 teleportation extension

  1. #1
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default A simple E2 teleportation extension

    Hey peoples, I decided I wanted an easy way to teleport with e2 so i pieced this together:


    Code:
    e2function void entity:warpStuff(vector DestVec)
    	DestVec = Vector(DestVec[1], DestVec[2], DestVec[3])
    	if(!validEntity(this)) then return end
    	if (!util.IsInWorld(DestVec)) then
    		while (!util.IsInWorld(DestVec)) do
    			DestVec = DestVec/1.05
    		end
    	end
    	if (this:IsPlayer()) then
    		if (!self.player == this) then return end
    		this:SetPos(DestVec)
    	else
    		if (!isOwner(self, this)) then return end
    		ConstrainedEnts = constraint.GetAllConstrainedEntities(this)
    		for _, v in pairs(ConstrainedEnts) do
    			EntPhy = v:GetPhysicsObject()
    			EntPhy:SetPos(DestVec + (EntPhy:GetPos() - v:GetPos()))
    			EntPhy:Wake()
    		end
    	end
    end
    Place in "\garrysmod\addons\wire\lua\entities\gmod_wire_exp ression2\core\custom"

    Use "Entity:warpStuff(vector)" in E2 to move players and props wherever. If its welded to something, you can use E2 to listen for the owner's right-click or something and it will port everything it's welded to. I use aimPos() so it ports wherever I'm aiming.

    I also tried it in conjunction with the find extension so it locates players and contraptions in a certain range and ports them to wherever, works great!

    Lemmie know if you have any ideas or suggestions, its pretty basic right now.
    Last edited by phreak314; 02-01-2010 at 07:25 PM.

  2. #2
    Wire Sofaking vexx21322's Avatar
    Join Date
    Dec 2008
    Location
    Co, united states
    Posts
    424

    Default Re: A simple E2 teleportation extension

    Nice, unfortunately there already is a teleporting extension, look for E:tele(V)
    Have you checked HERE first?

  3. #3
    Wire Sofaking Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Belgium OR BANland
    Posts
    1,965

    Default Re: A simple E2 teleportation extension

    No, this is far more complex, as it teleports whole contraption. But, use toWorld next time for the positions, it will save much trouble.

    edit: wouldn't work, you'd have to buffer up the toworld pos before the teleport, nevermind
    New server IP: 89.238.160.17:27018
    Hologram contraptions 1 Holo contraptions 2 EGP stuff Holo minigun Holo javelin rocket launcher
    Unsmart: I doubt the intelligence of some people.
    Drunkie: Nobody could have said that any better than Unsmart.

    Unsmart: Solece, I totally did your mom yesterday
    Solece: Who hasnt

    Divran: there are more retarded people than there are clever people in this world

  4. #4
    No u Divran's Avatar
    Join Date
    Jul 2008
    Location
    Sweden
    Posts
    4,582

    Default Re: A simple E2 teleportation extension

    A guy named DuneD already made a function like this, which teleports the entire contraption. Not sure if he has released it though.
    Oh and you should use e2function instead of registerFunction. It's a lot easier.
    SVN Tutorial
    My SVN:
    Code:
    http://divranspack.googlecode.com/svn/trunk/%20divranspack/
    Get dropbox and get 250 MB extra space: Dropbox

  5. #5
    Wire Sofaking Rybec's Avatar
    Join Date
    Apr 2008
    Location
    Denver
    Posts
    648

    Default Re: A simple E2 teleportation extension

    Code:
    if (!util.IsInWorld(Vec)) then
    		while (!util.IsInWorld(Vec)) do
    			Vec = Vec/1.05
    		end
    	end
    I just noticed this. That's rather clever, forcing it to just find a position in the world instead of erroring out.
    I think you should add a check to only teleport an entity if it belongs to you, and only be able to teleport yourself. Then, add a console command (that defaults to owner-only) so individual servers can disable that check and allow anyone to teleport anyone else and their stuff. Best of both worlds.

    Some sort of effect option might be nice too, like the Hoverdrive uses. With a separate function to toggle if it uses the effect or not.
    Last edited by Rybec; 01-30-2010 at 08:37 AM.

  6. #6
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default Re: A simple E2 teleportation extension

    Thanks for the input everyone. Rybec, i will look into your ideas, they would make the extension a bit more secure...

  7. #7
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default Re: A simple E2 teleportation extension

    Quote Originally Posted by Unsmart View Post
    No, this is far more complex, as it teleports whole contraption. But, use toWorld next time for the positions, it will save much trouble.

    edit: wouldn't work, you'd have to buffer up the toworld pos before the teleport, nevermind
    Just makin sure, were you able to get this workin? And your suggestion to use toWorld, i'm not sure what trouble i would be avoiding. Can you please elaborate?

  8. #8
    Wire Noob phreak314's Avatar
    Join Date
    Feb 2009
    Location
    US
    Posts
    25

    Default Re: A simple E2 teleportation extension

    I made a couple slight modifications. For a bit of added security, the owner of the expression can only teleport themselves and stuff they own. I've not fully tested the changes, all i know is I can teleport my own stuff. I've not tried in multiplayer.

    Code:
    registerFunction("warpStuff", "e:v", "", function(self, args)
    	local op1, op2 = args[2], args[3]
    	local rv1, rv2 = op1[1](self, op1), op2[1](self, op2)
    	if(!validEntity(rv1)) then print("Entity Not Valid") return end
    	local Vec = Vector(rv2[1], rv2[2], rv2[3])
    	if (!util.IsInWorld(Vec)) then
    		while (!util.IsInWorld(Vec)) do
    			Vec = Vec/1.05
    		end
    	end
    	if (rv1:IsPlayer()) then
    		if (!self.player == rv1) then return end
    		rv1:SetPos(Vec)
    	else
    		if (!rv1:GetOwner() == self.player) then return end
    		ConstrainedEnts = constraint.GetAllConstrainedEntities(rv1)
    		for _, v in pairs(ConstrainedEnts) do
    			phys = v:GetPhysicsObject()
    			phys:SetPos(Vec + (phys:GetPos() - v:GetPos()) + Vector(0,0,10))
    		end
    	end
    end)
    Still considering options for disabling this protection ingame. Was thinking of maybe implementing a way to allow specific players to have global rights to teleport anything. Not sure if that's really worth it. As it is, its simple and secure.

  9. #9
    No u Divran's Avatar
    Join Date
    Jul 2008
    Location
    Sweden
    Posts
    4,582

    Default Re: A simple E2 teleportation extension

    Please change it to use e2function instead of registerFunction. It's both easier for you to code and nicer on the eyes.

    Also, use "isOwner()" when checking ownership, not GetOwner(). I think GetOwner doesn't work correctly... not sure.

    And remove the print saying that the entity is not valid for two reasons: It's only printed to the server's console, so the user won't even notice it. And the server will get spammed with that error message if the user does something wrong.
    SVN Tutorial
    My SVN:
    Code:
    http://divranspack.googlecode.com/svn/trunk/%20divranspack/
    Get dropbox and get 250 MB extra space: Dropbox

  10. #10
    Wire Sofaking smellslike's Avatar
    Join Date
    May 2009
    Location
    in a lonley world
    Posts
    412

    Default Re: A simple E2 teleportation extension

    Dang, the only problem with good extensions is that few servers have them. This would be perfect for spacebuild so you don't HAVE to use asgard.(it gets annoying)
    Working on military pack.
    Remember
    amateurs build the ark....
    Professionals build the titanic

+ Reply to Thread
Page 1 of 3 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots