+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3
Results 21 to 27 of 27

Thread: registerFunc->e2function

  1. #21
    hat full of head

    Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael's Avatar
    Join Date
    Aug 2007
    Posts
    1,947

    Default Re: registerFunc->e2function

    Quote Originally Posted by TomyLobo View Post
    it requires a standalone lua interpreter
    considering I'm about the only wire dev to have one of those, it is very unlikely that the converter is of any use to any of you.
    I have a standalone lua interpreter. It's so useful.

    windows+R, cmd, lua5.1 and then just go wild.

  2. #22
    Bug Buster

    TomyLobo has a spectacular aura about TomyLobo has a spectacular aura about TomyLobo's Avatar
    Join Date
    Feb 2009
    Posts
    2,786

    Default Re: registerFunc->e2function

    windows+R lua and go wild, here

    Edit:
    I attached the converter. conv(source,target)
    source and target can be the same, but in the case of errors, you might have broken your source code

    make sure there are NO WARNINGS AND ERRORS AT ALL before replacing your file with the converted version.
    Attached Files
    Last edited by TomyLobo; 11-26-2009 at 01:39 AM.
    "It's easy to win forgiveness for being wrong; being right is what gets you into real trouble." - Bjarne Stroustrup

    Lífið læðist lúmskt áfram

  3. #23
    Wire Sofaking Unsmart will become famous soon enough Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Slovakia OR BANland
    Posts
    1,169

    Default Re: registerFunc->e2function

    ok, since Im a horrible fail at lua, how can I make something like this:

    I have a entity like the E2.
    I have 3 files: init, cl_init, shared

    How could I make a variable in init readable from cl_init? I imagine it something like this:

    init:
    Code:
    variable = 0
    
    cl_init
    Code:
    function ENT:draw()
      draw....
    
    print(ENT.variable+"\n")
    end
    
    Last edited by Unsmart; 11-27-2009 at 12:06 AM.

  4. #24
    hat full of head

    Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael's Avatar
    Join Date
    Aug 2007
    Posts
    1,947

    Default Re: registerFunc->e2function

    Networked vars, Unsmart. Networked vars.

    Or DTVars if you wanna be efficient.

  5. #25
    Wire Sofaking Unsmart will become famous soon enough Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Slovakia OR BANland
    Posts
    1,169

    Default Re: registerFunc->e2function

    Quote Originally Posted by Azrael View Post
    Networked vars, Unsmart. Networked vars.

    Or DTVars if you wanna be efficient.
    thanks, and I see that it also supports VECTORS


    Also, sorry, but I updated my post, is there any better way than that? As at time of your post you probably haven't seen my edit.

  6. #26
    hat full of head

    Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael's Avatar
    Join Date
    Aug 2007
    Posts
    1,947

    Default Re: registerFunc->e2function

    Learn how to use what I told you, you silly sausage you.

  7. #27
    Wire Sofaking Unsmart will become famous soon enough Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Slovakia OR BANland
    Posts
    1,169

    Default Re: registerFunc->e2function

    Ok, enough talking, here is work:
    selfaware.lua
    +added setColor(r,g,b,a)
    ~persisted math.clamp, you say its faster


    Quote Originally Posted by Syranide View Post
    Sure, as long as the code behaves the same way, I'd say it's a plus.
    However, as for using math.ceil, it is way slower, but it seems that if you alias all the math-functions locally (within the file) then the difference is less noticeable and the code readability becomes preferable. I believe we already do this in some extension, vectors I think.
    I did exactly that now!


    player.lua

    only up to line 83, due to the fact that this wount probably get SVN'ed, had talk with mods at IRC.

    here is the edited part of user:
    Code:
    local validEntity = E2Lib.validEntity
    local isOwner = E2Lib.isOwner
    registerCallback("e2lib_replace_function", function(funcname, func, oldfunc)
    	if funcname == "isOwner" then 
    		isOwner = func
    	elseif funcname == "validEntity" then
    		validEntity = func
    	end
    end)
    
    /******************************************************************************/
    
    __e2setcost(5) -- temporary
    
    e2function number entity:isAdmin()
    	if not validEntity(this) then return 0 end
    	if not this:IsPlayer() then return 0 end
    	if this:IsAdmin() then return 1 else return 0 end
    end
    
    e2function number entity:isSuperAdmin()
    	if not validEntity(this) then return 0 end
    	if not this:IsPlayer() then return 0 end
    	if this:IsSuperAdmin() then return 1 else return 0 end
    end
    
    /******************************************************************************/
    
    e2function vector entity:shootPos()
    	if(!validEntity(this)) then return {0,0,0} end
    	if(this:IsPlayer() or this:IsNPC()) then
    		return this:GetShootPos()
    	else return {0,0,0} end
    end
    
    e2function vector entity:eye()
    	if (!validEntity(this)) then return {0,0,0} end
    	if (this:IsPlayer()) then
    		return this:GetAimVector()
    	else
    		return this:GetForward()
    	end
    end
    
    --- Returns a local angle describing player <this>'s view angles.
    e2function angle entity:eyeAngles()
    	if not validEntity(this) then return { 0, 0, 0} end
    	local ang = this:EyeAngles()
    	return { ang.p, ang.y, ang.r }
    end
    
    /******************************************************************************/
    
    e2function string entity:name()
    	if(!validEntity(this)) then return "" end
    	if(!this:IsPlayer()) then return "" end
    	return this:Name()
    end
    
    e2function string entity:steamID()
    	if(!validEntity(this)) then return "" end
    	if(!this:IsPlayer()) then return "" end
    	return this:SteamID()
    end
    
    e2function number entity:armor()
    	if(!validEntity(this)) then return 0 end
    	if(this:IsPlayer() or this:IsNPC()) then return this:Armor() else return 0 end
    end
    
    /******************************************************************************/
    
    e2function number entity:height()
    	if(!validEntity(this)) then return 0 end
    	if(this:IsPlayer() or this:IsNPC()) then
    		local pos = this:GetPos()
    		local up = this:GetUp()
    		return this:NearestPoint(Vector(pos.x+up.x*100,pos.y+up.y*100,pos.z+up.z*100)).z-this:NearestPoint(Vector(pos.x-up.x*100,pos.y-up.y*100,pos.z-up.z*100)).z
    	else return 0 end
    end
    
    Attached Files
    Last edited by Unsmart; 01-26-2010 at 10:16 AM.

+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3

Similar Threads

  1. Replies: 0
    Last Post: 10-07-2009, 09:10 AM
  2. Replies: 0
    Last Post: 09-22-2009, 09:10 PM
  3. Replies: 0
    Last Post: 09-04-2009, 09:50 AM
  4. Replies: 1
    Last Post: 07-01-2009, 02:30 AM
  5. [E2] E:freeze() function with e2function syntax?
    By S1L3NT in forum Wiremod Lua Coding
    Replies: 2
    Last Post: 06-19-2009, 06:18 AM

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