• Entity Outputs
    9 replies, posted
[b]If you aren't a developer then this release won't have any value to you.[/b] I'm not sure whether this has already been done or not, but I noticed that you can't trigger entity outputs through lua. This script allows you to simulate an output from any entity, scripted or otherwise. This means you can easily write entities that will work in hammer's entity I/O system, or fire outputs of existing entities (firing "OnSetupFinished" of team_round_timer on cp_well will cause the gates to open and the trains to start running, for example). Goes in lua/autorun/server. [b]DOWNLOAD:[/b] [url]http://www.mediafire.com/?202tmgwvtng[/url] [b]functions:[/b] ent:GetEntOutputs() ent:FireEntOutput(outputname) You may or may not have to create a FGD file so Hammer will recognize your entity's outputs. For help with authoring FGDs, check here: [url]http://developer.valvesoftware.com/wiki/Fgd[/url] I understand that the uses for this script are fairly limited, so if you need to create a single entity or something and don't really want to include this script feel free to use code from it. If you have any questions, bugs to report, or suggestions, feel free to let me know.
I think flood mod uses some map ent in/out when build phase ends...
Hey, I am new to posting on these forums but I have been reading them for quite some time. I am surprised this was never made earlier and if it has sorry if I missed it. I am quite new to Lua but can understand a fair amount. My question to you is if I could have an example of an admin specific button in a map which would open a door. I have come up with a simple button for Rp which heals only Cp this is the code: [lua]if team.GetName(TRIGGER_PLAYER:Team()) == ('Civil Protection') then ACTIVATOR:SetArmor(100) else ACTIVATOR:PrintMessage( HUD_PRINTTALK,'You need to be a CP to recharge.'); end[/lua] I have many ideas how this can be used but am not sure how your outputs code needs to be set out I would appreciate your assistance or just a simple example so I know how to use it.
[QUOTE=Ghor;22506617][B]If you aren't a developer then this release won't have any value you to.[/B] [/QUOTE] :sigh: ...Maybe next time...
[QUOTE=aaron_5238;22649257]Hey, I am new to posting on these forums but I have been reading them for quite some time. I am surprised this was never made earlier and if it has sorry if I missed it. I am quite new to Lua but can understand a fair amount. My question to you is if I could have an example of an admin specific button in a map which would open a door. I have come up with a simple button for Rp which heals only Cp this is the code: [lua]if team.GetName(TRIGGER_PLAYER:Team()) == ('Civil Protection') then ACTIVATOR:SetArmor(100) else ACTIVATOR:PrintMessage( HUD_PRINTTALK,'You need to be a CP to recharge.'); end[/lua] I have many ideas how this can be used but am not sure how your outputs code needs to be set out I would appreciate your assistance or just a simple example so I know how to use it.[/QUOTE] should be something like this: [lua]if ACTIVATOR:IsAdmin() then self:FireEntOutput("OnPressed") else ACTIVATOR:PrintMessage( HUD_PRINTTALK,'You need to be an admin to use this button.') end[/lua] You will need to set up the button to fire the door's "Open" input on its "OnPressed" output in Hammer for this code to work. You may or may not also have to create a FGD file so Hammer will recognize your entity (not a problem) and its outputs (probably necessary for this) as valid. For help with authoring FGDs, check here: [url]http://developer.valvesoftware.com/wiki/Fgd[/url]
Thankyou for the fast reply. I thought this code could make it possible to edit map entities values for example changing the value's of a light_spot so it changes colour or gains brightness. My example was set up with a func_button and a lua_run entity and when the button gets pressed the code is ran. Like i said i am quite new to lua this is what i came up with of what it may look like[lua]if (TRIGGER_PLAYER:IsAdmin()or TRIGGER_PLAYER:IsSuperAdmin()) for _,ent in ipairs(ents.FindByName('admindoor')) do ent:FireEntOutput("OnPressed")else ACTIVATOR:PrintMessage( HUD_PRINTTALK,'You need to be an admin to use this button.')end[/lua] I have noticed you did an edit whilst i was posting this message are the get or set value no longer avaliable?
[QUOTE=aaron_5238;22694364]Thankyou for the fast reply. I thought this code could make it possible to edit map entities values for example changing the value's of a light_spot so it changes colour or gains brightness. My example was set up with a func_button and a lua_run entity and when the button gets pressed the code is ran. Like i said i am quite new to lua this is what i came up with of what it may look like[lua]if (TRIGGER_PLAYER:IsAdmin()or TRIGGER_PLAYER:IsSuperAdmin()) for _,ent in ipairs(ents.FindByName('admindoor')) do ent:FireEntOutput("OnPressed")else ACTIVATOR:PrintMessage( HUD_PRINTTALK,'You need to be an admin to use this button.')end[/lua] I have noticed you did an edit whilst i was posting this message are the get or set value no longer avaliable?[/QUOTE] The methods for the EntOutput object are still available, I just removed them from the post to reduce clutter. If you're using the combination of a func_button and a lua_run entity, this script probably isn't necessary. Here is a fixed version of the code that doesn't use the output functions: [lua]if TRIGGER_PLAYER:IsAdmin() then for _,ent in ipairs(ents.FindByName('admindoor')) do ent:Fire("Open",nil,0) end else ACTIVATOR:PrintMessage( HUD_PRINTTALK,'You need to be an admin to use this button.') end[/lua] If you're using the new functions I've provided, it would be in a new scripted entity you would author, like func_adminbutton or something. When the SENT is used and the presser is an admin, you would have it fire off its "OnPressed" output using self:FireEntOutput("OnPressed") which would execute all of the outputs you had assigned to the button's "OnPressed" output in Hammer. Either way is perfectly valid. The first method requires more work in Hammer for each button/door pair, but the second is reusable in something like a gamemode and means you don't have to screw around with lua_run entities constantly to achieve the same result.
Thankyou so much you have been very helpful. I will end up using this but make sure to give you full credit. Much apreciated!! [editline]11:40AM[/editline] WORKS fantastic when it searches for the name it does not search for the entity func name it finds anything with the name 'admindoor' worked fine when i named a func_rotating_door *admindoor* made it fire 'Toggle' instead and works great. I did not need to make a new fgd file which was good. here is a zip or my example the zip contains the .vmf and .bsp its a button which can be activated only by admin and then opens the door the door has use opens also active but is just an example. Thanks Again!! [url]http://www.megaupload.com/?d=A4VQCAL3[/url]
Sorry for the bump, but it seemed kinda related to this, It would be great with being able to hook entity outputs to Lua if you know what I mean. When a output is triggered, it also runs a function in Lua, making it possible to do stuff when it's fired.
[QUOTE=aurum481;22516035]I think flood mod uses some map ent in/out when build phase ends...[/QUOTE] Close but no cake, All flood mod does is trigger them using "toggle" or "open"/"close".
Sorry, you need to Log In to post a reply to this thread.