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

Thread: [E2] HUD-drawing functions

  1. #1
    Wire Sofaking SatansSimon's Avatar
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    513

    Default [E2] HUD-drawing functions

    Hi there, I wanted to write an extension for the E2 - gate, allowing you to draw things onto your HUD, just like the Adv. HUD Indicator. Now I've got several problems:

    1. The functions won't get registered and so the E2 can't use them.
    I get this error in the console:
    Code:
    entities\gmod_wire_expression2\core\custom/HUD-indication.lua:8: '<eof>' expected near 'end'
    2.
    Code:
    surface.drawText
    or every other surface.draw functions is clientside but E2 is operating serverside. How can I get the gate to draw this even if it's serverside?


    This is my LUA code so far:

    Code:
    AddCSLuaFile('HUD-indication.lua')
    
    	--HUD-Interface v0.1
    
    /****************************************************************************/
    registerType("screenpos", "sp", { 0, 0 })
    
    end)
    /****************************************************************************/
    
    registerFunction("screenpos", "", "sp" function(self, args)
      	return { 0, 0 }
    end)
    
    registerFunction("screenpos", "nn", "sp" function(self, args)
    	local op1, op2 = args[2], args[3]
    	local rv1, rv2 = op1[1](self, op1), op2[1](self, op2)
    	return {rv1, rv2}
    end)
    
    registerFunction("screencenter", "", "sp", function(self, args)
    	local rv1, rv2 =  surface.Screendwidth/2, surface.Screenheight/2
            return {rv1, rv2}
    end)
    /***************************************************************************/
    
    --rv1, rv2 			== position
    --rv3 	 			== height
    --rv4			 	== width
    --rv5, rv6, rv7		== RGB - vector
    --rv8				== Alpha
    
    registerFucntion("drawBox", "spnnvn", "" function(self, args)
    	local op1, op2, op3, op4, op5 = args[2], args[3], args[4], args[5], args[6]            
    	local rv1, rv2, rv3, rv4, rv5, rv6, rv7, rv8 = op1[1](self, op1), op1[2](self, op1), op2[1](self, op2), 
    	      op3[1](self, op3), op4[1](self, op4), op4[2](self, op4), op4[3](self, op4), op5[1](self, op5)                          
    	                                                                              
    	surface.SetDrawColor(rv5, rv6, rv7, rv8)                                      
    	surface.DrawRect(rv1, rv2, rv3, rv4)
    end)
    
    /**************************************************************************/
    Help would be very appreciated.
    Thanks in advance
    Last edited by SatansSimon; 03-10-2009 at 10:03 AM.

  2. #2
    I think I think too much -HP-'s Avatar
    Join Date
    Feb 2009
    Location
    Behind you with a very sharp knife.
    Posts
    2,466

    Default Re: [E2] HUD-drawing functions

    Quote Originally Posted by SatansSimon View Post
    Code:
    entities\gmod_wire_expression2\core\custom/HUD-indication.lua:8: '<eof>' expected near 'end'
    I *think* that means that there is one too much "end" in the code somewhere. Dont be sure though, I've only done some simple lua.

  3. #3
    Wire Sofaking SatansSimon's Avatar
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    513

    Default Re: [E2] HUD-drawing functions

    OK, this is line eight:
    Code:
    /****************************************************************************/
    registerType("screenpos", "sp", { 0, 0 })
    
    end) <--- here is the error
    /****************************************************************************/

  4. #4
    I think I think too much -HP-'s Avatar
    Join Date
    Feb 2009
    Location
    Behind you with a very sharp knife.
    Posts
    2,466

    Default Re: [E2] HUD-drawing functions

    There should not be an end there, should it? There are no ifs, and no "(" to close with the ")".

  5. #5
    Wire Sofaking Azrael's Avatar
    Join Date
    Aug 2007
    Posts
    1,946

    Default Re: [E2] HUD-drawing functions

    -HP- is right.
    Also, running the functions on the client would be a bit tricky. You'd have to set up a usermessage system and then make the server send the usermessage to the client. This could all be implemented in HUD-indication.lua, as the file is sent to the client and executed. So here's how the whole structure would look like, in pseudocode:
    Code:
    registerFunction("drawABigBox", function() usermessage.send('bigboxnaoplzplz') end )
    if CLIENT then
    usermessage.hook('bigboxnaoplzplz') drawABigBox() end
    end

  6. #6
    Wire Sofaking SatansSimon's Avatar
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    513

    Default Re: [E2] HUD-drawing functions

    Thank you Azrael, maybe you're not thials bad =)
    I'm not at home atm but I'll try it when I'm back home.

  7. #7
    Wire Sofaking Beer's Avatar
    Join Date
    Jul 2007
    Location
    Dallas, Texas
    Posts
    1,357

    Default Re: [E2] HUD-drawing functions

    I've been wanting something like this for a while now.. I think it would be great to have.

  8. #8
    Wire Sofaking moggie100's Avatar
    Join Date
    Dec 2007
    Posts
    416
    Blog Entries
    1

    Default Re: [E2] HUD-drawing functions

    He's in my base, stealing my lua creations! O.o

    I had to send my data to a clientside script via umesg's to update the screen ...hence the almost unreadable code... which is fine, except that I'm not sure that E2 -has- a hookable clientside component :/

  9. #9
    Wire Sofaking ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,391

    Default Re: [E2] HUD-drawing functions

    You can send code to clientside using E2 functions.

    The function files are run through both server and client to register the actual functions on the server, and register the funcion names + arguments on the clientside editor.

    If you use
    Code:
    if CLIENT then
    In an e2 function file it will work just fine.

    The problem is going in reverse, client-->server e2. Thankfully something like this wouldn't need that at all. So yes, it's totally possible.
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  10. #10
    Wire Sofaking SatansSimon's Avatar
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    513

    Default Re: [E2] HUD-drawing functions

    Hey moggie, I never wanted to stealanyones code and I would be glad if anybody else could do these functions because I know, well, in fact nothing about LUA and all I do is copy/paste work. But I will keep on working on it, let's who does better =)

+ Reply to Thread
Page 1 of 3 123 LastLast

Similar Threads

  1. Music Composer & Drawing Pad
    By Playzr in forum Finished contraptions
    Replies: 22
    Last Post: 08-26-2010, 02:33 PM
  2. E2 hud drawing
    By Riddler in forum Expression 2 Discussion & Help
    Replies: 12
    Last Post: 01-30-2010, 04:59 AM
  3. Pamento - Gpu For Drawing
    By Hitman271 in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 7
    Last Post: 12-29-2008, 12:26 PM
  4. Drawing pad
    By Beer in forum Installation and Malfunctions Support
    Replies: 3
    Last Post: 04-24-2008, 06:11 PM
  5. A html drawing
    By Noctune9 in forum Off-Topic
    Replies: 6
    Last Post: 03-10-2008, 01:51 PM

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