How do I use GetName() to find an entity's name? Entity:GetName() returns the index a global (a function value)....note this is a vehicle fyi
[QUOTE=Blakestr;48841444]How do I use GetName() to find an entity's name? Entity:GetName() returns the index a global (a function value)....note this is a vehicle fyi[/QUOTE]
What do you mean by "returns the index a global (a function value)"
[QUOTE=JasonMan34;48841547]What do you mean by "returns the index a global (a function value)"[/QUOTE]
I use Entity:GetName() in the vehicle script of the vehicle I want and it returned that. I am just now starting to about learn using Entity commands but I was hoping using it in the script would reference, um, itself and give me the right name?
[QUOTE=Blakestr;48841694]I use Entity:GetName() in the vehicle script of the vehicle I want and it returned that. I am just now starting to about learn using Entity commands but I was hoping using it in the script would reference, um, itself and give me the right name?[/QUOTE]
Ok, let me rephrase what I wrote.
Show us the part of the code, and show us the error/output you are getting
[QUOTE=JasonMan34;48841755]Ok, let me rephrase what I wrote.
Show us the part of the code, and show us the error/output you are getting[/QUOTE]
Just a disclaimer, I KNOW this is the wrong way to use this... I just don't know the correct way. This is from the vehicle's lua file which is running. (that's how I get the error message)
[CODE]
Entity:GetName()
local V = {
// Required information
Name = name,
Class = "prop_vehicle_jeep",
Category = "AAAA Test Menu",
// Optional information
Author = "LoneWolfie, Schmal",
Information = "vroom vroom",
Model = "models/LoneWolfie/chev_suburban_pol.mdl",
KeyValues = {
vehiclescript = "scripts/vehicles/LWCars/chev_suburban.txt"
},
IsEMV = true,
EMV = EMV,
HasPhoton = true,
Photon = "lw_suburban"
}
list.Set( "Vehicles", V.Name, V )
[/CODE]
Error message in console [QUOTE]attempt to index global 'Entity' (a function value)
[/QUOTE]
'Entity' isn't even in that part of the code...
[QUOTE=JasonMan34;48841810]'Entity' isn't even in that part of the code...[/QUOTE]
sorry, edited the above post
[QUOTE=Blakestr;48841836]sorry, edited the above post[/QUOTE]
Oh ok, where is Entity defined then?
[QUOTE=JasonMan34;48841946]Oh ok, where is Entity defined then?[/QUOTE]
That's just it... I don't understand the process, should I check wherever it is used to spawn in the custom spawn menu? Is that where the "entity" name comes from?
Is there a way of setting a ragdoll's colour (citizen jumpsuit set by SetPlayerColor)? I tried SetColor and it just sets the head to the colour.
[QUOTE=mib999;48842163]Is there a way of setting a ragdoll's colour (citizen jumpsuit set by SetPlayerColor)? I tried SetColor and it just sets the head to the colour.[/QUOTE]
You'll have to use the net library or something, and then on the client's end, do this to the ragdoll:
[code]ragdoll.GetPlayerColor() = function() return Vector(r, g, b) end[/code]
R G B are clamped 0-1
[QUOTE=Blakestr;48842038]That's just it... I don't understand the process, should I check wherever it is used to spawn in the custom spawn menu? Is that where the "entity" name comes from?[/QUOTE]
instead of "Entity", you're supposed to use a variable of the entity you want to get the name of.
edit: wait, what are you even trying to do in the first place?
unrelated: does anyone know of a way to change the way the [url=http://garry.tv/2012/02/25/poster-screenshots/]poster command[/url] works, or alternatively, emulate/copy it through Lua? The goal is to get loads of individual files (preferably PNGs) as seen in the first screenshot of the blog post, rather than one huge PNG. I'm pretty sure that it's done in the C++ code rather than lua in vanilla gmod, so I can't even see any of the code to get an idea.
For the specific purpose of what I need, it doesn't matter if all the screenshots aren't taken at the exact same tick. That is, it's perfectly fine if it takes some parts of the screenshots at different ticks.
In anyone can point me to it, it would be great!
Edit: nevermind, problem solved some other way. But it seems to be impossible to do in lua, which is a bit disappointing. You can't render anything without the view-angle being in the very center of the render.
[QUOTE=Neat-Nit;48842435]instead of "Entity", you're supposed to use a variable of the entity you want to get the name of.
edit: wait, what are you even trying to do in the first place?[/QUOTE]
I tried that an got a bad index error... (used the variable from script that was thruster above (V) I think.
I'm trying to use SetMaterial to change vehicles skin but I need to know how to reference it.
[QUOTE=Blakestr;48842471]I tried that an got a bad index error... (used the variable from script that was thruster above (V) I think.
I'm trying to use SetMaterial to change vehicles skin but I need to know how to reference it.[/QUOTE]
Please post the entirety of your script, otherwise it's really hard to help :/
[QUOTE=Neat-Nit;48842486]Please post the entirety of your script, otherwise it's really hard to help :/[/QUOTE]
Thanks for helping.
[CODE]Entity:GetName()
local V = {
// Required information
Name = name,
Class = "prop_vehicle_jeep",
Category = "AAAA Test Menu",
// Optional information
Author = "LoneWolfie, Schmal",
Information = "vroom vroom",
Model = "models/LoneWolfie/chev_suburban_pol.mdl",
KeyValues = {
vehiclescript = "scripts/vehicles/LWCars/chev_suburban.txt"
},
IsEMV = true,
EMV = EMV,
HasPhoton = true,
Photon = "lw_suburban"
}
list.Set( "Vehicles", V.Name, V ) [/CODE]
[QUOTE=Blakestr;48842495]Thanks for helping.
[CODE]Entity:GetName()
local V = {
// Required information
Name = name,
Class = "prop_vehicle_jeep",
Category = "AAAA Test Menu",
// Optional information
Author = "LoneWolfie, Schmal",
Information = "vroom vroom",
Model = "models/LoneWolfie/chev_suburban_pol.mdl",
KeyValues = {
vehiclescript = "scripts/vehicles/LWCars/chev_suburban.txt"
},
IsEMV = true,
EMV = EMV,
HasPhoton = true,
Photon = "lw_suburban"
}
list.Set( "Vehicles", V.Name, V ) [/CODE][/QUOTE]
Is that the WHOLE file?
[QUOTE=Neat-Nit;48842521]Is that the WHOLE file?[/QUOTE]
No but I'm mobile now and can't access it... Any case, it was a photon script for lights and I read through it looking for anything that looks like an object name... But what I gave you was it.. It might sound silly but that's the only script the vehicle is using AFAIK
[QUOTE=Blakestr;48842495]Thanks for helping.
[CODE]Entity:GetName()
local V = {
// Required information
Name = name,
Class = "prop_vehicle_jeep",
Category = "AAAA Test Menu",
// Optional information
Author = "LoneWolfie, Schmal",
Information = "vroom vroom",
Model = "models/LoneWolfie/chev_suburban_pol.mdl",
KeyValues = {
vehiclescript = "scripts/vehicles/LWCars/chev_suburban.txt"
},
IsEMV = true,
EMV = EMV,
HasPhoton = true,
Photon = "lw_suburban"
}
list.Set( "Vehicles", V.Name, V ) [/CODE][/QUOTE]
You don't have Entity defined anywhere in the script. There's a [URL="http://wiki.garrysmod.com/page/Global/Entity"]function included by default named Entity[/URL] that makes you get that error. As a side note, it's usually poor practice to name variables after existing functions or libraries.
[QUOTE=AK to Spray;48842568]You don't have Entity defined anywhere in the script. There's a [URL="http://wiki.garrysmod.com/page/Global/Entity"]function included by default named Entity[/URL] that makes you get that error. As a side note, it's usually poor practice to name variables after existing functions or libraries.[/QUOTE]
Where do I find where the entity is defined? In the script that creates the spawn menu item?
[QUOTE=Blakestr;48842673]Where do I find where the entity is defined? In the script that creates the spawn menu item?[/QUOTE]
You're not supposed to use the actual word Entity in there. Besides, I don't see any reason for GetName() to be there at all.
When you can, post your whole code, otherwise we can't help at all.
[QUOTE=Z0mb1n3;48842434]You'll have to use the net library or something, and then on the client's end, do this to the ragdoll:
[code]ragdoll.GetPlayerColor() = function() return Vector(r, g, b) end[/code]
R G B are clamped 0-1[/QUOTE]
I'd like to note that the ragdolls are prop_ragdoll, so that they have collisions with players etc. It says SetPlayerColor is a nil value on the entity. Are you sure this function exists?
[QUOTE=mib999;48842843]I'd like to note that the ragdolls are prop_ragdoll, so that they have collisions with players etc. It says SetPlayerColor is a nil value on the entity. Are you sure this function exists?[/QUOTE]
That is perfectly fine. If you define the function as a member of the actual ragdoll entity's table, such that
[code]
if SERVER then
local rag = ents.Create("prop_ragdoll")
rag:SetModel("model")
rag:SetPos(Vector(0,0,0))
rag:Spawn()
rag:Activate()
net.Start("ragColor")
net.WriteInt(rag:EntIndex(), 16)
net.WriteVector(Vector(1,0,0))
net.Broadcast()
else
net.Receive("ragColor", function(len)
local rag = Entity(net.ReadInt(16))
local col = net.ReadVector()
rag.GetPlayerColor = function() return col end
end)
end
[/code]
it will color the ragdoll red, if it supports player colors. I promise you.
[QUOTE=Z0mb1n3;48842887]That is perfectly fine. If you define the function as a member of the actual ragdoll entity's table, such that
[code]
if SERVER then
local rag = ents.Create("prop_ragdoll")
rag:SetModel("model")
rag:SetPos(Vector(0,0,0))
rag:Spawn()
rag:Activate()
net.Start("ragColor")
net.WriteInt(rag:EntIndex(), 16)
net.WriteVector(Vector(1,0,0))
net.Broadcast()
else
net.Receive("ragColor", function(len)
local rag = Entity(net.ReadInt(16))
local col = net.ReadVector()
rag.GetPlayerColor = function() return col end
end)
end
[/code]
it will color the ragdoll red, if it supports player colors. I promise you.[/QUOTE]
Oh! Thank you. That works fab.
-snip-
I want to hide the input in my DTextEntry and replace it with *. (Just like when you register somewhere and you need to enter the password)
Is there any way to do this?
[QUOTE=P4sca1;48843794]I want to hide the input in my DTextEntry and replace it with *. (Just like when you register somewhere and you need to enter the password)
Is there any way to do this?[/QUOTE]
These are just concepts, not actual code.
Hold the actual value in a seperate variable,
set the text value to string.rep( "*", utf8.len(actual_value_here) )
When the value changes, append the actual value with the last character of input. Check if the length is shorter. If it is, make the actual value smaller
Is there an alternate way for SetFOV and SetNoDraw.
As SetNoDraw is serverside I cannot use it in many ways.
Same as FOV.
[QUOTE=deinemudda32;48845849]Is there an alternate way for SetFOV and SetNoDraw.
As SetNoDraw is serverside I cannot use it in many ways.
Same as FOV.[/QUOTE]
Uh, SetNoDraw works on the client, too. However, certain physics interactions may cause items to re-draw, so you can always use a Think hook to perpetuate their invisiblity.
As for FOV, you can use the "CalcView" hook and only edit the FOV part of the CamData structure.
I meant DrawViewModel, Im sorry.
[code]hook.Add("TTTPrepareRound", "weather", function()
if SERVER then
chance = math.random(0,100)
weathertime = math.random(0,24)
RunConsoleCommand( "ulx", "settime ".. weathertime.."" )
if chance < 600 then
tableweather = {
("rain"),
("fog"),
("blizzard"),
("snow"),
("storm")}
weatherchoice = table.Random(tableweather)
RunConsoleCommand("ulx", "weather ".. weatherchoice.."")
RunConsoleCommand("say", "weather test")
else RunConsoleCommand("ulx", "weather none")
end
end
end)
[/code]
this doesn't work but still prints the text fine
i've got another piece of code hooking into the same thing and that works fine, this doesn't
[editline]7th October 2015[/editline]
nor does this
[code]--
hook.Add("TTTPrepareRound", "weather", function()
if SERVER then
chance = math.random(0,100)
weathertime = math.random(0,24)
weathertimestring = "weather "..weathertime
RunConsoleCommand( "ulx", weathertimestring)
if chance < 600 then
tableweather = {
("weather rain"),
("weather fog"),
("weather blizzard"),
("weather snow"),
("weather storm")}
weatherchoice = table.Random(tableweather)
RunConsoleCommand("ulx", weatherchoice)
RunConsoleCommand("say", "weather test")
else RunConsoleCommand("ulx", "weather none")
end
end
end)[/code]
Sorry, you need to Log In to post a reply to this thread.