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:
2.Code:entities\gmod_wire_expression2\core\custom/HUD-indication.lua:8: '<eof>' expected near 'end'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?Code:surface.drawText
This is my LUA code so far:
Help would be very appreciated.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) /**************************************************************************/
Thanks in advance
Last edited by SatansSimon; 03-10-2009 at 10:03 AM.
OK, this is line eight:
Code:/****************************************************************************/ registerType("screenpos", "sp", { 0, 0 }) end) <--- here is the error /****************************************************************************/
There should not be an end there, should it? There are no ifs, and no "(" to close with the ")".
-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
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.
I've been wanting something like this for a while now.. I think it would be great to have.
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 :/
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
In an e2 function file it will work just fine.Code:if CLIENT then
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
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 =)
Bookmarks