1. Post #201
    I'm cool because I have a title period
    Fleskhjerta's Avatar
    May 2009
    390 Posts
    I took a look at the client.command hook, but it seems it dosen't supports arguments.
    It returns a plain text of what you wrote in the console.

  2. Post #202
    Gold Member
    BlackAwps's Avatar
    July 2011
    768 Posts


    Changed the hook to provide the arguments table and the raw string.

  3. Post #203
    Map in a box's Avatar
    July 2009
    5,791 Posts


    Changed the hook to provide the arguments table and the raw string.
    Ninjerr
    Anywho:
    Added !(not), !=, <<, >>, |, ||, &, and &&.
    More glua like!
    Reply With Quote Edit / Delete Reply Windows XP Professional x64 United States Show Events Dumb Dumb x 3Informative Informative x 2Friendly Friendly x 1 (list)

  4. Post #204
    jrj996's Avatar
    July 2009
    1,571 Posts
    so whats the deal with console commands serverside, did you guys change how they work?

  5. Post #205
    Gold Member
    BlackAwps's Avatar
    July 2011
    768 Posts
    No

  6. Post #206
    I'm cool because I have a title period
    Fleskhjerta's Avatar
    May 2009
    390 Posts
    Just a question, is there anyway to detect whenever you are aiming at the specified block/entity/mob ?

  7. Post #207
    Crashty's Avatar
    January 2012
    57 Posts
    Please update the wiki guys, Can't wait to use the new input. hooks

  8. Post #208
    Map in a box's Avatar
    July 2009
    5,791 Posts
    I was thinking of networking the console commands like how its done in source, so on the server there would be a player argument. Would it be worth it?

  9. Post #209
    Gold Member

    December 2009
    1,263 Posts
    I cant find anything on the wiki and its starting to get annoying. How do I print text? I found that out by opening the ESP addon. How do I change the font though?

  10. Post #210
    Gold Member
    BlackAwps's Avatar
    July 2011
    768 Posts
    I cant find anything on the wiki and its starting to get annoying. How do I print text? I found that out by opening the ESP addon. How do I change the font though?
    You would have to make your own font PNG if you wanted to have a different looking font and create it via surface.CreateFont( "/path/to.png" )

    I did some in-code documentation so hopefully we will be able to reorganize and update the wiki soon.

    Anyway, while playing with some friends on a server I made a pretty bad xray and figured it would help if I added some threading capabilities and this is what I came up with..


    And the code behind it..

    concommand.Add( "scan", function( cmd, args )
    
    	local size = args[1] or 64
    
    	local thread = Thread( function()
    		local block
    		local pos = LocalPlayer():GetPos()
    		
    		local startTime = SysTime()
    		
    		Info( "Scanning.." )
    		
    		local scanningVecs = Vectors( pos + Vector( 1, 1, 0.25 ) * size, pos + Vector( -1, -1, -1 ) * size )
    		
    		Warning( string.format( "Looping through %i blocks!", #scanningVecs ) )
    		
    		for i = 1, #scanningVecs do
    			currentScanPos = scanningVecs[ i ]
    			block = Block( currentScanPos, LocalPlayer():GetWorld() )
    			if block:GetID() == 56 then
    				table.insert( foundBlocks, { vec = currentScanPos, col = Color( 0, 162, 232, 150 ) } )
    			end
    		end
    		
    		Info( string.format( "Scan complete.. (%f seconds)", SysTime() - startTime ) )
    		
    		Warning( string.format( "Found %i blocks of diamond!", #foundBlocks ) )
    		
    	end )
    	
    	thread:Start()
    	
    end )

    Best part is, since we are using a simulated Lua in java, we don't have to worry about fucking up a stack because there is none.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Winner Winner x 3Funny Funny x 2Useful Useful x 1 (list)

  11. Post #211
    vandooz's Avatar
    June 2010
    182 Posts
    I like this, but im requesting more information (and tutorials) on the wiki. I'm currently experimenting with this, and sometimes i don't even i know what i do wrong.
    Reply With Quote Edit / Delete Reply Windows 7 Netherlands Show Events Agree Agree x 1 (list)

  12. Post #212
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,300 Posts
    3D font rendering, woo :D

    Reply With Quote Edit / Delete Reply Windows 7 Austria Show Events Winner Winner x 4 (list)

  13. Post #213
    Gold Member
    thomasfn's Avatar
    July 2008
    2,640 Posts
    3D font rendering, woo :D

    Are you going to add the ability to register new block and item types? If there was some kind of gmod-sent-like API for adding new block and item types (both client & serverside, the lua script would need to be shared - this reminds me, do you have gmod-style server -> client script downloading yet?), I would start using this right away.

  14. Post #214
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,300 Posts
    Are you going to add the ability to register new block and item types? If there was some kind of gmod-sent-like API for adding new block and item types (both client & serverside, the lua script would need to be shared - this reminds me, do you have gmod-style server -> client script downloading yet?), I would start using this right away.
    I am hoping to get custom Items/Blocks ready soon. There are quite a few things to take care of (custom rendering, etc) so it's not too easy for us.
    Server->client net functions are done already, but we still have to add something like AddResource (that will work for any files, .lua will get exectued on the client)
    Reply With Quote Edit / Delete Reply Windows 7 Austria Show Events Winner Winner x 2 (list)

  15. Post #215
    Gold Member
    Lexic's Avatar
    March 2009
    5,782 Posts
    Not wishing to be a one-track record here, but any chance of having multiworld support soonish?
    Reply With Quote Edit / Delete Reply Mac United Kingdom Show Events Agree Agree x 1 (list)

  16. Post #216
    Gold Member
    BlackAwps's Avatar
    July 2011
    768 Posts
    I looked into it before and it looks like it would be pretty easy. It would require doing a lot of small edits to a lot of different things. I'll look into again tomorrow, since it is something I would like to see myself.

    Edited:

    Hahaha, I take that back. I could probably add multi-world support in a matter of minutes.
    The code has really gotten a lot cleaner and organized since notch stopped working on it.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Winner Winner x 4Funny Funny x 3 (list)

  17. Post #217
    vandooz's Avatar
    June 2010
    182 Posts
    how do timers even work, can i get a sample at least because im stuck.

    Hint: wikipage about timers has an phperror.

  18. Post #218
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,300 Posts
    how do timers even work, can i get a sample at least because im stuck.

    Hint: wikipage about timers has an phperror.
    I don't see a PHP error http://wiki.luacraft.com/LuaClient/timer.lua

    -- use once
    timer.Simple(2, function()
    	print("2 seconds elapsed!")
    end)
    
    -- use 5 times
    timer.Create("5 times", 1, 5, function()
    	print("5 times timer..")
    end)

  19. Post #219
    vandooz's Avatar
    June 2010
    182 Posts
    I don't see a PHP error http://wiki.luacraft.com/LuaClient/timer.lua

    -- use once
    timer.Simple(2, function()
    	print("2 seconds elapsed!")
    end)
    
    -- use 5 times
    timer.Create("5 times", 1, 5, function()
    	print("5 times timer..")
    end)
    Thanks, but i meant this page: http://wiki.luacraft.com/Timer

    And a infinite timer loop?

  20. Post #220
    VitalVirus's Avatar
    October 2011
    11 Posts
    I can see this becoming grealty famous, and the lot of Addons created in Lua Scripting by Awesome Modders here in Facepunch.. This is awesome..
    Reply With Quote Edit / Delete Reply Windows XP Brazil Show Events Friendly Friendly x 1 (list)

  21. Post #221
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,300 Posts
    ...
    And a infinite timer loop?
    timer.Create("abc", 2, 0, function() print("Endless..") end)

    Just replace the repetitions with 0
    Reply With Quote Edit / Delete Reply Windows 7 Austria Show Events Friendly Friendly x 1 (list)

  22. Post #222
    vandooz's Avatar
    June 2010
    182 Posts
    timer.Create("abc", 2, 0, function() print("Endless..") end)

    Just replace the repetitions with 0
    Thanks, last question of today: is there a function to check around a radius of an entity/block/player? if not take it as an request.

  23. Post #223
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,300 Posts
    Thanks, last question of today: is there a function to check around a radius of an entity/block/player? if not take it as an request.
    What to check? Entities? I'd guess you could use ents.GetClosestToEntity(ent, radius)
    Reply With Quote Edit / Delete Reply Windows 7 Austria Show Events Agree Agree x 1 (list)

  24. Post #224
    Gold Member
    Lexic's Avatar
    March 2009
    5,782 Posts
    Also, I asked before but didn't get an answer. Would it be possible to make blocks/entities react as if they had just been pushed by a piston?
    To create invisible pistons etc.

  25. Post #225
    vandooz's Avatar
    June 2010
    182 Posts
    What to check? Entities? I'd guess you could use ents.GetClosestToEntity(ent, radius)
    I think i ment for blocks, not entities.

  26. Post #226
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,300 Posts
    Also, I asked before but didn't get an answer. Would it be possible to make blocks/entities react as if they had just been pushed by a piston?
    To create invisible pistons etc.
    Never saw that question, will look into it (something like block:Push(dir) .. seems ok)

    I think i ment for blocks, not entities.
    I am not quite sure what you want :x sorry.
    Reply With Quote Edit / Delete Reply Windows 7 Austria Show Events Friendly Friendly x 1Disagree Disagree x 1 (list)

  27. Post #227
    vandooz's Avatar
    June 2010
    182 Posts
    Never saw that question, will look into it (something like block:Push(dir) .. seems ok)



    I am not quite sure what you want :x sorry.
    Ok, look i ment radius, something like GetClosestToBlock(block, radius).

  28. Post #228
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,300 Posts
    Ok, look i ment radius, something like GetClosestToBlock(block, radius).
    ents.GetClosestToVector(vec, radius)

    €dit: @Lexi

    _R.Block.Push = function(self, vec, len)
    	if (vec.x ~= 0 and (vec.y ~= 0 or vec.z ~= 0)) then return false end
    	if (vec.y ~= 0 and (vec.x ~= 0 or vec.z ~= 0)) then return false end
    	if (vec.z ~= 0 and (vec.x ~= 0 or vec.y ~= 0)) then return false end
    	
    	len = len or 12
    	local dir = Vector(math.Clamp(vec.x, -1, 1), math.Clamp(vec.y, -1, 1), math.Clamp(vec.z, -1, 1))
    	local id, meta = self:GetID(), self:GetMeta()
    	local prev_id, prev_meta = id, meta
    	
    	self:SetID(0)
    	
    	for i = 1, len do
    		local pos = self:GetPos() + dir * i
    		local block = Block(pos)
    		id, meta = block:GetID(), block:GetMeta()
    		
    		block:SetID(prev_id)
    		block:SetMeta(prev_meta)
    		
    		if (id == 0) then break end
    		if (pos.z <= 0 or pos.z >= 256) then break end
    		
    		prev_id, prev_meta = id, meta
    	end
    end
    Reply With Quote Edit / Delete Reply Windows 7 Austria Show Events Disagree Disagree x 1 (list)

  29. Post #229
    Gold Member
    thomasfn's Avatar
    July 2008
    2,640 Posts
    ents.GetClosestToVector(vec, radius)

    €dit: @Lexi

    _R.Block.Push = function(self, vec, len)
    	if (vec.x ~= 0 and (vec.y ~= 0 or vec.z ~= 0)) then return false end
    	if (vec.y ~= 0 and (vec.x ~= 0 or vec.z ~= 0)) then return false end
    	if (vec.z ~= 0 and (vec.x ~= 0 or vec.y ~= 0)) then return false end
    	
    	len = len or 12
    	local dir = Vector(math.Clamp(vec.x, -1, 1), math.Clamp(vec.y, -1, 1), math.Clamp(vec.z, -1, 1))
    	local id, meta = self:GetID(), self:GetMeta()
    	local prev_id, prev_meta = id, meta
    	
    	self:SetID(0)
    	
    	for i = 1, len do
    		local pos = self:GetPos() + dir * i
    		local block = Block(pos)
    		id, meta = block:GetID(), block:GetMeta()
    		
    		block:SetID(prev_id)
    		block:SetMeta(prev_meta)
    		
    		if (id == 0) then break end
    		if (pos.z <= 0 or pos.z >= 256) then break end
    		
    		prev_id, prev_meta = id, meta
    	end
    end
    I think he wants the animation of the block moving along the floor, just like a piston pushed it.

  30. Post #230
    Gold Member
    BlackAwps's Avatar
    July 2011
    768 Posts
    Welp, multi-world support is taking a lot longer than I thought it would. So far I can create the world and get it to run, but I can't actually get the player into it yet.

    This is how you would create a world though.

    local world = world.Create( {
    	name = "test_world", -- The name of the folder in which the world will reside in
    	gamemode = CREATIVE, -- The default gamemode
    	provider = WORLD, -- The type of world this is (WORLD,END,NETHER)
    	type = WORLD_TYPE_DEFAULT, -- The type of world to be generated (WORLD_TYPE_DEFAULT,WORLD_TYPE_FLAT)
    	viewdist = 10, -- Maximum view distance
    	difficulty = 1, -- Difficulty level
    	seed = "This be a test seed", -- The worlds seed
    	animals = false, -- Spawn animals
    	monsters = false, -- Spawn monsters
    	structures = false, -- Spawn structures
    } )
    
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Winner Winner x 3 (list)

  31. Post #231
    Map in a box's Avatar
    July 2009
    5,791 Posts

    Eek!
    Reply With Quote Edit / Delete Reply Windows XP United States Show Events Winner Winner x 1 (list)

  32. Post #232
    vandooz's Avatar
    June 2010
    182 Posts
    I've tried this:
    -- Experminal scripty #2
    Msg("start experminal regrowscript")
    
    -- Vars n shit
    regrow_id = 0
    
    hook.Add("player.breakblock", "regrow_breakblock", function(ply, block)
    	if block:GetID() == 16 then -- coal
    		print(block) --debug
    		block:SetID(7)
    		timer.Simple( 15, regrow_func, block, 16 )
    		Msg("digcode ... OK")
    		regrow_id = regrow_id + 1
    		return false
    	end 
    end)
    
    local function regrow_func(block, blockid)
    	if block:GetID(7) then
    		block:SetID(blockid)
    		Msg("digtimer ... OK")
    	end
    end
    got:
    Timer Error: lua/extensions/timer.lua:69: attempt to call nil
    Reply With Quote Edit / Delete Reply Windows 7 Netherlands Show Events Disagree Disagree x 1 (list)

  33. Post #233
    Gold Member
    thejjokerr's Avatar
    December 2007
    1,585 Posts
    Move the local function to above where you add the hook...
    Reply With Quote Edit / Delete Reply Windows 7 Netherlands Show Events Agree Agree x 4Useful Useful x 1 (list)

  34. Post #234
    cvbbot's Avatar
    April 2012
    12 Posts
    i am currently making a (amateur) HUD, but i have some issues with the experience bar, as in this example:
    print(LocalPlayer():GetExperience())
    all it returns is: 0
    for now i had to do with other solutions, as well as just not adding it for now
    i tested the function in both single- and multiplayer
    am i doing something wrong, won't it work clientside, or does this still have to be fixed?

    what i want, i as the wiki mentions:

    GetExperience()
    Return value: Number:exp
    Information: Returns a players experience for their current level

  35. Post #235
    Gold Member
    Kogitsune's Avatar
    September 2005
    2,468 Posts
    Could PropertyManager be added to the client? I use it in a server addon that would work just as well for the client, but I manage my data with PropertyManager.

    May as well cross post on the forums.

  36. Post #236
    Gold Member
    BlackAwps's Avatar
    July 2011
    768 Posts
    Could PropertyManager be added to the client? I use it in a server addon that would work just as well for the client, but I manage my data with PropertyManager.

    May as well cross post on the forums.
    Committed PropertyManager to the client.

    i am currently making a (amateur) HUD, but i have some issues with the experience bar, as in this example:
    print(LocalPlayer():GetExperience())
    all it returns is: 0
    for now i had to do with other solutions, as well as just not adding it for now
    i tested the function in both single- and multiplayer
    am i doing something wrong, won't it work clientside, or does this still have to be fixed?

    what i want, i as the wiki mentions:

    GetExperience()
    Return value: Number:exp
    Information: Returns a players experience for their current level
    I think I can fix this.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Winner Winner x 1 (list)

  37. Post #237
    cvbbot's Avatar
    April 2012
    12 Posts
    Committed PropertyManager to the client.



    I think I can fix this.
    Awesome thanks

  38. Post #238
    Gold Member
    BlackAwps's Avatar
    July 2011
    768 Posts
    A little late, but it's fixed and ready for the update.



    This update also includes some more precise errors.


  39. Post #239
    cvbbot's Avatar
    April 2012
    12 Posts
    A little late, but it's fixed and ready for the update.



    This update also includes some more precise errors.

    great, still is don't understand how GetExperience() would return 0.3333345, as in your example

  40. Post #240

    May 2011
    269 Posts
    great, still is don't understand how GetExperience() would return 0.3333345, as in your example
    I'd assume that it would be the progress from one level to the next. That would be a third of the way through, 33%.
    Reply With Quote Edit / Delete Reply Windows 7 Australia Show Events Agree Agree x 2 (list)