1. Post #41
    Gold Member
    BlackAwps's Avatar
    July 2011
    763 Posts
    You can put them pretty much anywhere. The surface.GetTexureID starts in the .luacraft directory.
    If you wanted the default terrain.png as a texture, you can just do surface.GetTexureID( "/terrain.png" )
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Friendly Friendly x 1 (list)

  2. Post #42
    I gave enough money to buy a soda.
    Funley's Avatar
    May 2010
    1,404 Posts
    I just updated LuaCraft and when i start a world, ESP works for a second, then stops working and the console says
    Code:
    addons/luastoned.esp.zip/lue/init.lua:27: attempt to call nil Hook 'Game - Render Overlay:NORMAL' failed: addons/luastoned.esp.zip/lua/init.lua:27: attempt to call nil

  3. Post #43
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,350 Posts
    I just updated LuaCraft and when i start a world, ESP works for a second, then stops working and the console says
    Code:
    addons/luastoned.esp.zip/lue/init.lua:27: attempt to call nil Hook 'Game - Render Overlay:NORMAL' failed: addons/luastoned.esp.zip/lua/init.lua:27: attempt to call nil
    Please re-download the ESP addon. I fixed a small bug regarding IsAlive() and IsLiving() yesterday!
    Also addons always worked, I just made it very unclear if they were enabled or not, sorry for the confusion :D

  4. Post #44
    Gold Member
    ruarai's Avatar
    December 2009
    1,356 Posts
    This is great. Making an addon for finding wolves based on ESP, but why cant you load addons without having to restart?

  5. Post #45
    @@
    @@'s Avatar
    January 2012
    138 Posts
    This is great. Making an addon for finding wolves based on ESP, but why cant you load addons without having to restart?
    Go into the addons menu and double click the addon you want to reload. ( It'll disable and then re-enable it. )

  6. Post #46
    Gold Member
    ruarai's Avatar
    December 2009
    1,356 Posts
    Go into the addons menu and double click the addon you want to reload. ( It'll disable and then re-enable it. )
    Thanks.

    Edited:

    Got the console hook worked out. strCommand has the entire command in it (a little useless.) and tbl is like this:
    0: nil
    1: the actual command
    2: arguments
    3: so on

    If i knew how to wiki I probably would add it.

  7. Post #47
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,350 Posts
    Thanks.


    I hopefully stopped the confusion about addons being enabled or not.

  8. Post #48
    Gold Member
    ruarai's Avatar
    December 2009
    1,356 Posts
    Just requested a wiki account, but its so srs business it even asks you for a resume.
    Reply With Quote Edit / Delete Reply Windows 7 Australia Show Events Funny Funny x 3 (list)

  9. Post #49
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,350 Posts
    Just requested a wiki account, but its so srs business it even asks you for a resume.
    Heh, trying to keep them bots out.

  10. Post #50
    Gold Member
    ruarai's Avatar
    December 2009
    1,356 Posts
    A possibility for a function to get the players FPS? I'm making a cleaner HUD.

  11. Post #51
    @@
    @@'s Avatar
    January 2012
    138 Posts
    A possibility for a function to get the players FPS? I'm making a cleaner HUD.


    Will be in the next build.

    Edited:



    i am good programmer
    Reply With Quote Edit / Delete Reply Windows 7 United Kingdom Show Events Informative Informative x 1Winner Winner x 1Funny Funny x 1Agree Agree x 1 (list)

  12. Post #52

    January 2012
    6 Posts
    Finally client has been updated! ESP works! YAY! I love you ;D

  13. Post #53
    Gold Member
    bobthe2lol's Avatar
    July 2007
    1,370 Posts
    Does /lua work clientside as well? Also, why is 'Console' disabled?
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Agree Agree x 1 (list)

  14. Post #54
    Diehard55's Avatar
    May 2010
    61 Posts
    Does /lua work clientside as well? Also, why is 'Console' disabled?
    It got disabled because it was bugged I suppose. Also, if you want to code in-game press the ` or ~ key, depends on your keyboard.. But press that key, and then type lua "Code Here" No Quotations... Cheers.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Informative Informative x 1 (list)

  15. Post #55
    I gave enough money to buy a soda.
    Funley's Avatar
    May 2010
    1,404 Posts
    Just noticed that the particles that fall from blocks when there is water over it are lava particles :P

  16. Post #56
    Gold Member
    bobthe2lol's Avatar
    July 2007
    1,370 Posts
    Getting some odd apparently non-lua errors. Code:

    function makeCrater(size)
    	size = size or 2
    	if(size<=0) then size = 1 end
    	local me = LocalPlayer()
    	local trace = me:Trace(100)
    	local hitb = trace.HitBlock
    	Chat("HitBlock: ",hitb)
    	local hitpos = hitb:GetPos()
    	Chat("HitPos: ",hitpos)
    	x = size * -1
    	y = x
    	z = y
    	while(z <= 1) do
    		if(x<size) then
    			x = x + 1
    		else
    			x = size * -1
    			if(y<size) then
    				y = y + 1
    			else
    				y = size * -1
    				z = z + 1
    			end
    		end
    		fblock = Block(Vector(x,y,z)+hitpos)
    		if(fblock:IsValid() and fblock:isEntity()) then
    			fblock:Break(100)
    		end
    	end
    end
    
    Without the if check for validentity, the jvm throws a nullpointer exception on fblock:Break, and as it is, lua says that I'm trying to call nil. Any ideas?

  17. Post #57
    @@
    @@'s Avatar
    January 2012
    138 Posts
    Are you doing this clientside or serverside?

  18. Post #58
    Gold Member
    bobthe2lol's Avatar
    July 2007
    1,370 Posts
    Are you doing this clientside or serverside?
    client

  19. Post #59
    @@
    @@'s Avatar
    January 2012
    138 Posts
    IsEntity() isn't a function, you don't need it for your script either.

    Edited:

    Neither is IsValid(), every block should be valid. It's block type is air if it's not a placed block.

    Edited:



    Edited:

    Okay, going to add a IsValid() that basically does: ( Block:GetID() != 0 )

  20. Post #60
    jrj996's Avatar
    July 2009
    1,656 Posts
    Hey what're the keypressed enums?

    Edited:

    Night-Vision


    And the message thing at the top is a scrolling hint board.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Winner Winner x 1 (list)

  21. Post #61
    Gold Member
    bobthe2lol's Avatar
    July 2007
    1,370 Posts
    Oh. You should add some sort of checks in there for checking if there is any block there at all. I was on a superflat world, and it was trying to use a block that was in the Void.

  22. Post #62
    Gold Member
    Bellmanator's Avatar
    August 2008
    1,622 Posts
    How would I go about finding the block that the player is looking at ( serverside )?

  23. Post #63
    Gold Member
    bobthe2lol's Avatar
    July 2007
    1,370 Posts
    How would I go about finding the block that the player is looking at ( serverside )?
    player.GetByName("yourname"):Trace(distance).HitPos
    --or 
    player.GetByName("yourname"):Trace(distance).HitBlock
    

  24. Post #64
    Gold Member
    Bellmanator's Avatar
    August 2008
    1,622 Posts
    player.GetByName("yourname"):Trace(distance).HitPos
    --or 
    player.GetByName("yourname"):Trace(distance).HitBlock
    
    Thanks, I had the trace in my code, just didn't specify the .HitBlock.

  25. Post #65
    Gold Member
    Anderen2's Avatar
    May 2010
    352 Posts
    Does this mean that you can send lua files from the server, to the client now?

  26. Post #66
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,350 Posts
    Does this mean that you can send lua files from the server, to the client now?
    To Clients using LuaCraft, yes!
    Reply With Quote Edit / Delete Reply Austria Show Events Winner Winner x 1 (list)

  27. Post #67
    @@
    @@'s Avatar
    January 2012
    138 Posts
    Does this mean that you can send lua files from the server, to the client now?
    Ignore ^'s post. You can't do this yet. :P You can however use Player:SendLua() serverside.

    hook.Add("PlayerSpawn", "SendLua", function(ply)
    	ply:SendLua[[
    		print("Hello there " .. LocalPlayer():Name() .. "! :)")
    	]]
    end)
    

  28. Post #68
    Gold Member
    Anderen2's Avatar
    May 2010
    352 Posts
    Ignore ^'s post. You can't do this yet. :P You can however use Player:SendLua() serverside.

    hook.Add("PlayerSpawn", "SendLua", function(ply)
    	ply:SendLua[[
    		print("Hello there " .. LocalPlayer():Name() .. "! :)")
    	]]
    end)
    
    Ahh, well, better than nothing :)
    Is a solution similar to GMod's way planned?
    Reply With Quote Edit / Delete Reply Windows 7 Norway Show Events Agree Agree x 1 (list)

  29. Post #69
    @@
    @@'s Avatar
    January 2012
    138 Posts
    Is a solution similar to GMod's way planned?
    Yes it is.
    Reply With Quote Edit / Delete Reply Windows 7 United Kingdom Show Events Winner Winner x 2Friendly Friendly x 1 (list)

  30. Post #70
    jrj996's Avatar
    July 2009
    1,656 Posts
    Yes it is.
    Take my babies.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Optimistic Optimistic x 1 (list)

  31. Post #71
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    Wait, the client simply tells the server that it's broken a block?
    Couldn't you knock out the entire map with that?
    Reply With Quote Edit / Delete Reply Mac United Kingdom Show Events Disagree Disagree x 1 (list)

  32. Post #72
    Gold Member
    BlackAwps's Avatar
    July 2011
    763 Posts
    Luckily no. The server has checks to prevent that.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Informative Informative x 1 (list)

  33. Post #73
    Gold Member
    ruarai's Avatar
    December 2009
    1,356 Posts
    How do i simply get the local player in a client script?

  34. Post #74
    Gold Member
    BlackAwps's Avatar
    July 2011
    763 Posts
    LocalPlayer()

  35. Post #75
    Gold Member
    bobthe2lol's Avatar
    July 2007
    1,370 Posts
    -snip-

  36. Post #76
    Gold Member
    ruarai's Avatar
    December 2009
    1,356 Posts
    Code:
    local font = surface.GetFont()
    local name = LocalPlayer() 
    
    hook.Add("render.gameoverlay", "Game - Render Overlay", function()
    
    	if doscan == true then
    		for _, ent in pairs(ents.GetByClass("Wolf")) do
    			if (ent ~= LocalPlayer()) then
    				local pos = ent:EyePos()
    				local x, y, vis = pos:ToScreen()
    				local dist = pos:Distance(LocalPlayer():EyePos())
    	
    				if dist < 62 and vis then
    					local alpha = math.Clamp( 1 - (dist/64), 0, 1 ) * 255
    	
    					if (ent:IsMob()) then
    						surface.SetDrawColor(255, 0, 0, alpha)
    					elseif (ent:IsAnimal()) then
    						surface.SetDrawColor(0, 255, 0, alpha)
    					else
    						surface.SetDrawColor(0, 0, 255, alpha)
    					end
    	
    					surface.DrawRect(x, y, 1, 1)
    					surface.SetDrawColor(255, 255, 255, alpha)
    					local w, h = font:GetTextSize(ent:GetClass())
    					font:DrawText(ent:GetClass(), x - w / 2, y - 16)
    	
    					if (ent:IsLiving()) then
    						local healthPerc = ent:GetHealth() / ent:GetMaxHealth()
    						surface.SetDrawColor(0, 0, 0, alpha)
    						surface.DrawRect(x - 8, y - 8, 16, 2)
    						surface.SetDrawColor( (1 - healthPerc) * 255, healthPerc * 255, 0, alpha)
    						surface.DrawRect(x - 8, y - 8, 16 * healthPerc, 2)
    					end
    				end
    			end
    		end
    	end	
    
    	-- 10 y spacing in text
    
    	font:DrawText("Running Rdebug. Type rhelp in console for more info.",5, 5)
    	if rdebug == true then
    		
    		font:DrawText("Health: " .. name:GetHealth() .. "/20",5, 15)
    		font:DrawText("Armor: " .. name:GetArmor() .. "/20",5, 25)
    		font:DrawText("Air: " .. name:GetAir() .. "/300",5, 35)
    		font:DrawText("X:" .. round(name:GetPos().x) .. " Y:" .. round(name:GetPos().y) .. " Z:" .. round(name:GetPos().z),5, 45)
    		font:DrawText("XP: " .. name:GetExperience()  ,5, 55)
    	end
    	
    
    
    end)
    
    function round(num) return math.floor(num+.5) end
    
    
    hook.Add("console.command", "LuaCraft - Command", function(tbl, strCommand)
    	print("Console: " .. strCommand)
    	
    	if rpdebug == true then
    		for key,value in pairs(tbl) do print(key,value) end
    	end
    	if tbl[1] == "rpdebug" then
    		if tbl[2] == '1' then
    			rpdebug = true
    		elseif tbl[2] == '0' then
    			rpdebug = false
    		end
    	end
    	
    	if tbl[1] == "rdebug" then
    		if tbl[2] == '1' then
    			rdebug = true
    		elseif tbl[2] == '0' then
    			rdebug = false
    		end
    	end
    	if tbl[1] == rgive then
    		name:Give(ItemStack(tbl[2], tbl[3]))
    	
    	
    	end
    	
    	
    	
    	if tbl[1] == "rhelp" then
    		print("Rdebug script commands:")
    		print("Type name [your username] in console to begin.")
    		print("rpdebug with arg 1/0 for toggle. Enables console command debugging.")
    		print("rdebug with arg 1/0 for toggle. Enables simple GUI debugging helper.")
    		print("rgive with arg id and arg amount. Gives you the item specified.")
    	
    	end
    	
    
    	
    end)

    None of the functions that use the localplayer name work. No errors come up.

    Edited:

    Actually, wait I get a single java error when I load the world.
    http://i.cubeupload.com/WtAI8q.png

  37. Post #77
    @@
    @@'s Avatar
    January 2012
    138 Posts
    Define name at the start of the hook:

    hook.Add("render.gameoverlay", "Game - Render Overlay", function()
    	local font = surface.GetFont()
    	local name = LocalPlayer() 
    
    	if doscan == true then
    		for _, ent in pairs(ents.GetByClass("Wolf")) do
    			if (ent ~= LocalPlayer()) then
    				local pos = ent:EyePos()
    				local x, y, vis = pos:ToScreen()
    				local dist = pos:Distance(LocalPlayer():EyePos())
    	
    				if dist < 62 and vis then
    					local alpha = math.Clamp( 1 - (dist/64), 0, 1 ) * 255
    	
    					if (ent:IsMob()) then
    						surface.SetDrawColor(255, 0, 0, alpha)
    					elseif (ent:IsAnimal()) then
    						surface.SetDrawColor(0, 255, 0, alpha)
    					else
    						surface.SetDrawColor(0, 0, 255, alpha)
    					end
    	
    					surface.DrawRect(x, y, 1, 1)
    					surface.SetDrawColor(255, 255, 255, alpha)
    					local w, h = font:GetTextSize(ent:GetClass())
    					font:DrawText(ent:GetClass(), x - w / 2, y - 16)
    	
    					if (ent:IsLiving()) then
    						local healthPerc = ent:GetHealth() / ent:GetMaxHealth()
    						surface.SetDrawColor(0, 0, 0, alpha)
    						surface.DrawRect(x - 8, y - 8, 16, 2)
    						surface.SetDrawColor( (1 - healthPerc) * 255, healthPerc * 255, 0, alpha)
    						surface.DrawRect(x - 8, y - 8, 16 * healthPerc, 2)
    					end
    				end
    			end
    		end
    	end	
    
    	-- 10 y spacing in text
    
    	font:DrawText("Running Rdebug. Type rhelp in console for more info.",5, 5)
    	if rdebug == true then
    		font:DrawText("Health: " .. name:GetHealth() .. "/20",5, 15)
    		font:DrawText("Armor: " .. name:GetArmor() .. "/20",5, 25)
    		font:DrawText("Air: " .. name:GetAir() .. "/300",5, 35)
    		font:DrawText("X:" .. round(name:GetPos().x) .. " Y:" .. round(name:GetPos().y) .. " Z:" .. round(name:GetPos().z),5, 45)
    		font:DrawText("XP: " .. name:GetExperience()  ,5, 55)
    	end
    end)
    
    function round(num) return math.floor(num+.5) end
    
    hook.Add("console.command", "LuaCraft - Command", function(tbl, strCommand)
    	print("Console: " .. strCommand)
    	
    	if rpdebug == true then
    		for key,value in pairs(tbl) do print(key,value) end
    	end
    	if tbl[1] == "rpdebug" then
    		if tbl[2] == '1' then
    			rpdebug = true
    		elseif tbl[2] == '0' then
    			rpdebug = false
    		end
    	end
    	
    	if tbl[1] == "rdebug" then
    		if tbl[2] == '1' then
    			rdebug = true
    		elseif tbl[2] == '0' then
    			rdebug = false
    		end
    	end
    
    	if tbl[1] == rgive then
    		name:Give(ItemStack(tbl[2], tbl[3]))
    	end
    	
    	if tbl[1] == "rhelp" then
    		print("Rdebug script commands:")
    		print("Type name [your username] in console to begin.")
    		print("rpdebug with arg 1/0 for toggle. Enables console command debugging.")
    		print("rdebug with arg 1/0 for toggle. Enables simple GUI debugging helper.")
    		print("rgive with arg id and arg amount. Gives you the item specified.")
    	end
    end)

    Edited:

    Actually, wait I get a single java error when I load the world.
    http://i.cubeupload.com/WtAI8q.png
    You get that error because the player isn't initialized when the script loads. ( Same as in Garry's Mod. )
    Reply With Quote Edit / Delete Reply Windows 7 United Kingdom Show Events Agree Agree x 1 (list)

  38. Post #78
    Gold Member
    bobthe2lol's Avatar
    July 2007
    1,370 Posts
    I suddenly want to write a game mode like thing. Hmm...
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Winner Winner x 1Informative Informative x 1 (list)

  39. Post #79
    miceiken's Avatar
    September 2008
    182 Posts
    Code:
    		for _, ent in pairs(ents.GetByClass("Wolf")) do
    			if (ent ~= LocalPlayer()) then
    When is local player ever a wolf?
    Reply With Quote Edit / Delete Reply Windows 7 Norway Show Events Funny Funny x 8Agree Agree x 4Zing Zing x 1 (list)

  40. Post #80
    Gold Member
    bobthe2lol's Avatar
    July 2007
    1,370 Posts
    Is there some way to include other lua files? For example, I have a lua file named arena.lua in the same folder as my init.lua. Inside arena.lua I stuck module(..., package.seeall) at the top, but on requiring 'arena', I get a lua error telling me that arena.lua does not exist, even though I can obviously see it right there. Is there some sort of directory structure or include directory that I should use?