Hey guys can you help me with this,
[code]
lua_run for k,v in pairs(file.Find( "gamemodes/TacoScript/gamemode/items/*.lua", "GAME" ) ) do print( ITEM.Name ) end
[/code]
If I use that it just returns the ITEM.Name of the last item in the folder.
[QUOTE=C0MMUNIZT;38230030]Hey guys can you help me with this,
[code]
lua_run for k,v in pairs(file.Find( "gamemodes/TacoScript/gamemode/items/*.lua", "GAME" ) ) do print( ITEM.Name ) end
[/code]
If I use that it just returns the ITEM.Name of the last item in the folder.[/QUOTE]
for k, v in pairs(file.Find("gamemodes/TacoScript/gamemode/items/*.lua", "GAME")) do print(v) end
What exactly are you trying to do? Just debugging?
(Also sounds like ITEM isn't getting set to nil after TacoScript loads the items, you might want to take a look at that.)
it doesnt open up the file and read it. all you are doing here is printing whatever ITEM.Name is outside of the files.
Thanks Jetboom and Josh. It works perfectly!
[QUOTE=Failure;38224953]Hm I had to miss something, but self.Entity:SetUseType(SIMPLE_USE) gives me errors
[code]
[ERROR] lua/entities/gb_base.lua:57: attempt to call method 'SetUseType' (a nil value)
1. unknown - lua/entities/gb_base.lua:57
[/code]
This is the part of my code
[code]
self.Entity:SetModel(self.Model)
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetSolid( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
self.Entity:SetUseType( SIMPLE_USE )
[/code][/QUOTE]
I'm wondering about this too. There doesn't appear to be a page on the wiki about this either. Fuck..
[QUOTE=Lapito;38223475]Hello, I have an entity, and everything works fine, but when I undone this, I get this error.
[CODE][Drivable Halo Pelican] lua/entities/pelican/init.lua:55: attempt to index field 'Pilot' (a nil value)
1. DoKill - lua/entities/pelican/init.lua:55
2. unknown - lua/entities/pelican/init.lua:80[/CODE]
If anyone can help me please, here's the init.lua:[/QUOTE]
You keep getting this error, because self.Pilot is probably nil.
You should change line 48 to 81 into this:
[lua]function ENT:DoKill()
self.Pilot:UnSpectate()
self.Pilot:DrawViewModel(true)
self.Pilot:DrawWorldModel(true)
self.Pilot:Spawn()
self.Pilot:SetNetworkedBool("isDriveShuttle",false)
self.Pilot:SetPos(self.Entity:GetPos()+Vector(0,0,100))
end
function ENT:OnTakeDamage(dmg)
if self.Inflight and DESTROYABLE and not self.Done then
local health=self.Entity:GetNetworkedInt("health")
self.Entity:SetNetworkedInt("health",health-dmg:GetDamage())
local health=self.Entity:GetNetworkedInt("health")
if health<1 then
self.Entity:DoKill()
self.Done=true
self.Entity:Remove()
end
end
end
function ENT:OnRemove()
if (self.Sound) then
self.Sound:Stop()
end
local effectdata = EffectData()
effectdata:SetOrigin( self.Entity:GetPos() )
util.Effect( "Explosion", effectdata, true, true )
if self.Pilot then self.Entity:DoKill() end
end[/lua]
Your code is pretty messy btw. You really should clean it up "a bit"..
[QUOTE=Failure;38224953]Hm I had to miss something, but self.Entity:SetUseType(SIMPLE_USE) gives me errors
[code]
[ERROR] lua/entities/gb_base.lua:57: attempt to call method 'SetUseType' (a nil value)
1. unknown - lua/entities/gb_base.lua:57
[/code]
This is the part of my code
[code]
self.Entity:SetModel(self.Model)
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetSolid( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
self.Entity:SetUseType( SIMPLE_USE )
[/code][/QUOTE]
Well.. That function works fine for me.
In which case do you call gb_base.lua, respectively that part of the code? Serverside or Clientside? Because unlike the other functions, [I]SetUseType[/I] can only be called serverside, and will cause errors if not called serverside.
[QUOTE=RP-01;38230978]
Well.. That function works fine for me.
In which case do you call gb_base.lua, respectively that part of the code? Serverside or Clientside? Because unlike the other functions, [I]SetUseType[/I] can only be called serverside, and will cause errors if not called serverside.[/QUOTE]
We use the same lua here. His gb_base is called chappi_gib for me. What I just recently did was get rid of AddCSLuaFile(), which was in chappi_gib.lua. I don't get this error anymore, but now the gibs this is supposed to create are invisible.
The lua this entity is being called from is:
[CODE] function Gib(ent,pos,gibsamount,force,direction)
for i=1, gibsamount do
if (GetGlobalInt("gibsnum") >= GetConVar("g_maxgibs"):GetInt() ) then return end
local gib = ents.Create("chappi_gib")
gib:SetPos(pos)
gib:Spawn()
gib:Activate()
gib:SetMaterial("models/flesh")
local phys = gib:GetPhysicsObject()
phys:ApplyForceCenter(direction/4 + Vector(0,0,force))
gib:Fire( "kill", "", math.random(GibLifetimemin,GibLifetimemax ))
end
end[/CODE]
Simply deleting SetUseType, causes the gibs to not work at all as well as produce errors. EDIT: We are using this server side I believe, although there's no specification in the entirety of the lua itself.
[QUOTE=Drakehawke;38221728]Is render.SetScissorRect supposed to work in 3D2D?[/QUOTE]
This is a trap a lot of people fall into. The scissor rect is alwyas a rect on the screen. That's why VGUI clipping stuff doesn't work in 3D2D. The only real way I can think to get around this would be to use stencils to fake the scissor stuff.
[QUOTE=garry;38232625]This is a trap a lot of people fall into. The scissor rect is alwyas a rect on the screen. That's why VGUI clipping stuff doesn't work in 3D2D. The only real way I can think to get around this would be to use stencils to fake the scissor stuff.[/QUOTE]
Yea stencils is pretty much the only way...
[QUOTE=garry;38232625]This is a trap a lot of people fall into. The scissor rect is alwyas a rect on the screen. That's why VGUI clipping stuff doesn't work in 3QDD2D. The only real way I can think to get around this would be to use stencils to fake the scissor stuff.[/QUOTE]
Not worth the effort for what it is, thanks for the reply though!
[editline]29th October 2012[/editline]
Another question, how do we get around the size limit of DLabel? It seems to cut off after a large number of characters. I have a feeling there's a more advanced control we're supposed to use instead but I can't remember the name.
How does the env_skypaint work?
Does anyone have a sample script that uses it or is there documentation about it somewhere?
[QUOTE=ollie;38233817]How does the env_skypaint work?
Does anyone have a sample script that uses it or is there documentation about it somewhere?[/QUOTE]
This might be of help: [url]http://www.facepunch.com/showthread.php?t=1215271&p=38223223&viewfull=1#post38223223[/url]
[QUOTE=Drakehawke;38233822]This might be of help: [url]http://www.facepunch.com/showthread.php?t=1215271&p=38223223&viewfull=1#post38223223[/url][/QUOTE]
Yep, already saw that one. But that only activates the entity? How do i interact with it like in this post:
[url]http://www.facepunch.com/showthread.php?t=1215271&p=38221675&viewfull=1#post38221675[/url]
or
[url]http://www.facepunch.com/showthread.php?t=1215271&p=38214198&viewfull=1#post38214198[/url]
I'm really just trying to make a neat day and night cycle.
[QUOTE=ollie;38233883]Yep, already saw that one. But that only activates the entity? How do i interact with it like in this post:
[url]http://www.facepunch.com/showthread.php?t=1215271&p=38221675&viewfull=1#post38221675[/url]
or
[url]http://www.facepunch.com/showthread.php?t=1215271&p=38214198&viewfull=1#post38214198[/url]
I'm really just trying to make a neat day and night cycle.[/QUOTE]
[url]http://www.glua.me/bin/?path=/gamemodes/base/entities/entities/env_skypaint.lua[/url]
Maybe ent:SetStarTexture?
I figured out how to use that entity, because I had a look into the [I]garrysmod/garrysmod/garrysmod.fgd[/I] file. You can just set the KeyValues found there, which was the easiest way in my opinion.
Does anybody know what button:GetSelected got changed to?
I have a problem with a trip-mine, here's the error:
[lua]
[ERROR] lua/includes/modules/draw.lua:74: attempt to perform arithmetic on local 'w' (a nil value)
1. SimpleText - lua/includes/modules/draw.lua:74
2. unknown - ...pon_ttt_mine_addons/lua/entities/ent_ttt_mine/shared.lua:59
[/lua]
Here is Draw.lua
[lua]
function SimpleText(text, font, x, y, colour, xalign, yalign)
font = font or "DermaDefault"
x = x or 0
y = y or 0
xalign = xalign or TEXT_ALIGN_LEFT
yalign = yalign or TEXT_ALIGN_TOP
local w, h = 0, 0
surface.SetFont(font)
if (xalign == TEXT_ALIGN_CENTER) then
w, h = surface.GetTextSize( text )
x = x - w/2
elseif (xalign == TEXT_ALIGN_RIGHT) then
w, h = surface.GetTextSize( text )
x = x - w
end
[/lua]
Here is the trip-mine's code:
[lua]
if self.DrawText then
cam.Start3D2D(TargetPos, FixAngles, 0.15)
draw.SimpleText("LOL", "HUDNumber5", TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, Color(255,0,0,a),1,1)
cam.End3D2D()
end
end
[/lua]
Help is appreciated, thanks in advance :-)
Make sure your font exists
-snip-
[QUOTE=ollie;38233817]How does the env_skypaint work?
Does anyone have a sample script that uses it or is there documentation about it somewhere?[/QUOTE]
[url=https://github.com/samuelmaddock/skypaint/blob/master/skypaint.lua]Samm's skypaint module[/url] is the easiest way to do anything relating to skypaint I've found
[QUOTE=my_hat_stinks;38234576]Make sure your font exists[/QUOTE]
It exists, you can see here [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5b6d.html[/url]
Also, this worked before GMOD13, something new is messing it up. ;-)
[QUOTE=Apozen;38234747]It exists, you can see here [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5b6d.html[/url]
Also, this worked before GMOD13, something new is messing it up. ;-)[/QUOTE]
I'm sure some of those fonts no longer exist, and in gmod12 it wouldn't error if the font didn't exist so that's not really relevant
Edit: Ninja'd
[QUOTE=my_hat_stinks;38234760]I'm sure some of those fonts no longer exist, and in gmod12 it wouldn't error if the font didn't exist so that's not really relevant
Edit: Ninja'd[/QUOTE]
Ahh, I see.
I changed the font to something basic such as "DefaultSmall" and it worked!
The only remaining problem is that when I go to actually trip the mine, it beeps and goes on forever.
Also, the next round won't begin and the timer is stuck at 0:00.
I'll mess around and see what I can find.
P.S. Thanks banana for that helpful link
I'm having trouble with lua_run_cl in console; when I input [code]lua_run_cl print("Hello World")[/code] I get nothing
[QUOTE=Grondo4;38236010]I'm having trouble with lua_run_cl in console; when I input [code]lua_run_cl print("Hello World")[/code] I get nothing[/QUOTE]
Is sv_allowcslua set to 1?
[QUOTE=Drakehawke;38236043]Is sv_allowcslua set to 1?[/QUOTE]
That fixed it thank you
-snip-
Wow Grondo Just Give It Up If You Cant Print Hello World Then You Fail Hard At Lua
Ripping off of the official dynamite script still doesn't do much good in figuring out how to have certain effects have variables that are compliant with menu settings
[lua]TOOL.ClientConVar["damage"] = 200
function TOOL:LeftClick( trace )
local ttable =
{
Damage = Damage
}
local pl = self:GetOwner()
local _damage = math.Clamp( self:GetClientNumber( "damage" ), 0, 1500 )
exploderizer.Damage = _damage
util.BlastDamage( pl, pl, trace.HitPos, 300, exploderizer.Damage )
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
util.Effect( "Explosion", effectdata, true, true )
return true
end[/lua]
Sorry, you need to Log In to post a reply to this thread.