• Can Lua variables be changed in Hammer by marking them in an FGD file.
    8 replies, posted
If you set Lua flags in an entity, would it be possible to change them in Hammer by adding them to the FGD file so they can be read by Hammer.
[QUOTE=NostalgicBird;52379580]If you set Lua flags in an entity, would it be possible to change them in Hammer by adding them to the FGD file so they can be read by Hammer.[/QUOTE] Hammer deals in entity keyvalues, not Lua variables. If you write Lua code, you can interpret these entity keyvalues however you want, including (but not limited to) setting a Lua variable. [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/KeyValue]ENT:KeyValue[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityKeyValue]GM:EntityKeyValue[/url]
So an Lua variable can be interpreted as an entity keyvalue if I am not mistaken?
No clue what you on about, but since entities in Hammer can be assigned any custom key value pair, including spawnflags, you can create custom entities in Hammer with whatever keyvalues and when those custom entities spawn in-game (Provided they exist on the server i.e. they are coded), all the key-values set in hammer can be captured and saved via Lua using the callbacks/hooks mentioned above. [editline]20th June 2017[/editline] But no, you cannot set Lua variables directly from hammer, not without coding some Lua.
Here is what I do in my jump pad entity on the workshop: [Lua]function ENT:KeyValue( key, value ) // print(bit.band(31,1),bit.band(31,2),bit.band(31,4),bit.band(31,8),bit.band(31,16)) if ( string.Left( key, 2 ) == "On" ) then self:StoreOutput( key, value ) end if ( key == "angles" ) then local Sep = string.Explode(" ", value) local ang = (Angle(Sep[1], Sep[2], Sep[3])) self.angle = ang end if ( key == "target" ) then self:SetTargetName(value) -- Support for any map using the old way end if ( key == "z_modifier" ) then -- NetworkVar keyvalues now working? self:SetHeightAdd(value) end if ( key == "effect_col" ) then local Sep = string.Explode(" ", value) local Col = (Vector(Sep[1], Sep[2], Sep[3])) self:SetEffectColor(Col) end if ( key == "enabled" ) then self:SetEnabled(value) end if ( key == "model" ) then self:SetWorldModel(value) end if ( key == "target_name" ) then self:SetTargetName(value) end if ( key == "spawnflags" ) then if value == "1" then self.Frozen = true end end end[/Lua] With this code, when the entity spawns in the world it will go through the key values and assign them to Lua variables and other useful tasks I need
[QUOTE=Robotboy655;52380326]No clue what you on about, but since entities in Hammer can be assigned any custom key value pair, including spawnflags, you can create custom entities in Hammer with whatever keyvalues and when those custom entities spawn in-game (Provided they exist on the server i.e. they are coded), all the key-values set in hammer can be captured and saved via Lua using the callbacks/hooks mentioned above. [editline]20th June 2017[/editline] But no, you cannot set Lua variables directly from hammer, not without coding some Lua.[/QUOTE] That, plus highvoltage's reply answered my question (I know you can't set Lua variables in Hammer, I meant can Hammer edit Lua variables for a certain entity, for example, you set a variable in a custom entity for whether or not an entity should be Blue instead of its normal color. In Hammer, there would be a flag to configure this)
Here is the entry in my fgd file for the entity that code is for: [Code] @PointClass base(Targetname, Angles) studio() cylinder(255 255 255, targetname, target, 0, targetname, targetname, 0) = ut2k4_jumppad : "An entity used to build paths for other entities to follow. Each path_track is a node on the path, each holding the name of the next path_track in the path." [ model(studio) : "Base model" : "models/HighVoltage/UT2K4/PickUps/jump_pad.mdl" target(target_destination) : "Landing point" : : "Where we hope to land." effect_col(color255) : "Spawn effect color" : "255 128 0" : "The color of the spawn effect." z_modifier(float) : "Z Modifier" : "1" : "A number representing how much extra hight should be added. A number slightly above one should be ideal." output OnLaunch(void) : "Fires when it launches something" input TurnOn(void) : "Activates the jumppad" input TurnOff(void) : "Disables the jumppad" input ChangeTarget(string) : "Changes the target of the jumpad" ] [/Code] Hopefully that will help [editline]20th June 2017[/editline] That's not a updated version but it should still work with the code
I'm not a mapper, but isn't there some sort of "lua_run" entity that you can use to set globals?
He wants to make Lua entities for hammer and be able to set values on them, not just run code from hammer
Sorry, you need to Log In to post a reply to this thread.