• LuaCraft | Minecraft with a taste of Lua
    383 replies, posted
[QUOTE=BlackAwps;35130539]Odd, figured it would work because you can do stuff like this. [lua]print( "1" * 3 )[/lua][/QUOTE] That ones makes more sense. As the multiplcation operator shouldn't work on a string really, it can detect a string datatype and convert it into a number. Keys can of course be strings though, so you can't really do the same thing
Well, I made it so it you can index numbers as strings. Think this will cause any problems for anyone? :v: [lua] local testTbl = { ["1"] = "ABC123" } print( testTbl[1] ) ABC123 local testTbl = { [1] = "ABC123" } print( testTbl["1"] ) ABC123 [/lua]
[QUOTE=BlackAwps;35130712]Well, I made it so it you can index numbers as strings. Think this will cause any problems for anyone? :v: [lua] local testTbl = { ["1"] = "ABC123" } print( testTbl[1] ) ABC123 local testTbl = { [1] = "ABC123" } print( testTbl["1"] ) ABC123 [/lua][/QUOTE] Well, if you're going to do it you might as well do it before you build up a userbase that does things like having tables full of both string number keys and number keys. Not sure how good of an idea that is though, how exactly are you doing it?
Well, in LuaJava, when doing a rawset/get it checks if the value is a true integer and not a string integer like my "1" * 3 example. I just changed it to check if it was a possible integer instead of strictly checking if it was a true integer. :v:
We will test this and revert changes if needed.. The server is on 1.2 now, lets hope everything works :v:
After several hours of royal pain in the butt, I present you the new console: [img]http://img.luastoned.com/luacraft_console_v3.png[/img] [img]http://img.luastoned.com/luacraft_console_v4.png[/img] Happy crafting!
BlackAwps, I'm not sure if this was intentional but if you only have a certain amount of keys, the entire JSON string is put onto one line. Aside from that, numeric keys are not preserved - ie if you set a key to 0, it will be 1 when decoded. As you've made it so that index[1] is equal to index["1"], you also can't convert numeric keys to string keys to preserve their order as it will just think it's a numeric key. EDIT: Unrelated to JSON issues but if your position is set to a great distance away by the server using SetPos, it will kick you with the moved too fast error.
[QUOTE=Elspin;35169841].. EDIT: Unrelated to JSON issues but if your position is set to a great distance away by the server using SetPos, it will kick you with the moved too fast error.[/QUOTE] I see, we have had this problem before once. I know howto fix it, lets see if MCP updated the function name already.
[QUOTE=Elspin;35169841]BlackAwps, I'm not sure if this was intentional but if you only have a certain amount of keys, the entire JSON string is put onto one line. [/QUOTE] Mind posting some code that I can use to replicate it? Also, as a side note, json.Encode accepts a second argument as a number. It will be the number of spaces it uses to indent the encoded string, which defaults to 4 if nothing is passed. I'm guessing this may have something to do with your issue. [QUOTE=Elspin;35169841]Aside from that, numeric keys are not preserved - ie if you set a key to 0, it will be 1 when decoded. As you've made it so that index[1] is equal to index["1"], you also can't convert numeric keys to string keys to preserve their order as it will just think it's a numeric key.[/QUOTE] I will probably revert the changes to the indexing, seems to cause more problems than it solves. Also, I think I fixed this. [lua]local enc = json.Encode( { [-1]=false,[0]="purple",[1]=1.337, } ) print( enc ) local dec = json.Decode( enc ) table.Print( dec )[/lua] [code]{ "1": 1.337, "0": "purple", "-1": false } 1 = 1.337 0 = purple -1 = false[/code]
[QUOTE=BlackAwps;35180787]Mind posting some code that I can use to replicate it? Also, as a side note, json.Encode accepts a second argument as a number. It will be the number of spaces it uses to indent the encoded string, which defaults to 4 if nothing is passed. I'm guessing this may have something to do with your issue.[/QUOTE] It's not that it's not indenting it enough, it's that it's not indenting it at all. Some example output is here, the home file for our server: [code] { "epaulepp": { "overworld": "-235.08103438105024,100.0,112.26332330855735", "endworld": "99.44148277300152,49.0,1.7783805922070617", "nether": "194.116975555491,65.0,-64.97782159787346" }, "ashigaru7": {"overworld": "626.0697296857445,66.0,1121.1052450177972"}, "Weedragonslayer": {"overworld": "490.3979184202929,87.0,-325.343141961538"}, "Balimbanana": { "overworld": "203.90625,25.0,123.5", "nether": "42.92440847200222,51.0,14.994434759316356" }, "Narkvic": {"overworld": "-35.65284134560561,64.0,57.9137702542554"}, "charliemanboy": {"overworld": "322.09375,72.0,-458.875"}, "Adrian383": {"overworld": "391.69999998807907,111.0,-197.07445852790516"}, "Jackle15": {"overworld": "426.1845855098571,85.0,-285.91814087474296"}, "Elspin": {"overworld": "490.53723,-426.9176,75"}, "andrewman123": {"overworld": "414.34560230975666,71.0,-15.907128261796156"} } [/code] Basically any table with only one key is put into one line - and this may be intentional like I said, but it makes adding keys in manually a bit annoying for large tables. This should be able to reproduce it: [code] tbl = {} tbl["test"] = 5 print( json.Encode( test ) ) [/code] As a side note, this is really some great work - we're officially switching all of our server files as you can probably see from above to luacraft and I'll probably post the recreated bukkit plugins on the luacraft forums once they're proven to work.
Ah ok, so it's just not indenting single keys. I'll see what I can do. [editline]17th March 2012[/editline] Fixed
Is the Addon central supposed to show only ESP?
[QUOTE=MeltingData;35197656]Is the Addon central supposed to show only ESP?[/QUOTE] Pretty sure it's a work in progress
Yesss!! [code] hook.Add( 'entity.spawn', 'NoCreeper - Spawn', function(ent) if( ent:GetClass() == "Creeper" ) then ent:Remove() return false end end) [/code] No more dying all the fucking time because of random 'splosions from creepers! [QUOTE=MeltingData;35197656]Is the Addon central supposed to show only ESP?[/QUOTE] It's not working yet, and only shows addons installed.
[QUOTE=T3hGamerDK;35200832]Yesss!! [code] hook.Add( 'entity.spawn', 'NoCreeper - Spawn', function(ent) if( ent:GetClass() == "Creeper" ) then ent:Remove() return false end end) [/code] No more dying all the fucking time because of random 'splosions from creepers! It's not working yet, and only shows addons installed.[/QUOTE] Just posted something like that in another thread :v:. You don't need the ent:Remove() by the way, you can just return true to stop the entity from spawning
[QUOTE=T3hGamerDK;35200832]Yesss!! No more dying all the fucking time because of random 'splosions from creepers![/QUOTE] You could, instead of removing the creepers all together, just stop them from exploding. [lua]hook.Add( "entity.explosion", "Stop Creeper Explosions", function( ent, pos, size ) if ent:GetClass() == "Creeper" then return false end end[/lua]
[QUOTE=MeltingData;35197656]Is the Addon central supposed to show only ESP?[/QUOTE] It shows installed addons as of now, we are working on rolling out the proper addon central soon.
[QUOTE=LuaStoned;35204518]It shows installed addons as of now, we are working on rolling out the proper addon central soon.[/QUOTE] Oh sweet. Was a bit confused since it didn't say WIP or anything on the screen, and then "All" button said 1337. Guess that's a joke or reference that flew over my head.
[QUOTE=BlackAwps;35203417]You could, instead of removing the creepers all together, just stop them from exploding. [lua]hook.Add( "entity.explosion", "Stop Creeper Explosions", function( ent, pos, size ) if ent:GetClass() == "Creeper" then return false end end[/lua][/QUOTE] That was actually our first thought, but then we realized people would just put on some armor, make a dark cave and farm gunpowder :v:
Any expected date for 1.2.4 to be out?
The script I posted no longer works. Latest update, running Skyblock 2.1 as the map and creepers DO spawn and they DO explode as well (even though I added in Elspins script too, ALONG with my anti-spawn script)
[QUOTE=T3hGamerDK;35301069]The script I posted no longer works. Latest update, running Skyblock 2.1 as the map and creepers DO spawn and they DO explode as well (even though I added in Elspins script too, ALONG with my anti-spawn script)[/QUOTE] It's your script breaking something, sorry. My script is working without error on my server, and it's at the latest update.
Add math.Floor, math.Ceil, and math.Truncate.
[QUOTE=Aide;35308760]Add math.Floor, math.Ceil, and math.Truncate.[/QUOTE] [code]> lua print( math.ceil( 0.2 ) ) 1 > lua print( math.floor( 0.2 ) ) 0[/code] Math ceil/floor are in lua by default. And wouldn't flooring the number basically be truncating it? Unless you meant rounding to a specific decimal, which can also be done already. [code]> lua print( math.Round( 0.12345, 2 ) ) 0.12[/code]
I can't fathom scripting, could someone please code me a mod to remove hunger? or at least make the rate you get hungry at much smaller.
[QUOTE=hoodoo456;35312134]I can't fathom scripting, could someone please code me a mod to remove hunger? or at least make the rate you get hungry at much smaller.[/QUOTE] Just go look up tutorials. There are literally tons of them, and Lua is not hard. I'm learning it right now, there's no reason you can't too.
Can you add a function to push a block as if it had been pushed by a piston? To make invisible pistons basically.
I'd use this all the time if it was updated to the newest Minecraft version quicker.
If I were to, say, use hitbox detection so when a player points at something (using a normal minecraft client) and presses the E button, could he open up a menu, where the menu would have several options such as teleporting or giving out items? Would normal client be able to do this? Or would said player need to seperately come here, download the lua version, and then run it?
[QUOTE=jackool;35417584]I'd use this all the time if it was updated to the newest Minecraft version quicker.[/QUOTE] We skipped 1.2.4 and update directly to 1.2.5 today or tomorrow! (which is the official release date anyway)
Sorry, you need to Log In to post a reply to this thread.