-
You can type /we help for in-game help. Other than that, I just tried and it works, you can do either Source Code /we select /we clear abs or Source Code /we select /we fill air -c NOTE: the -c (or -clean is the same) is the same as doing /we clear abs before /we fill. Type /we help clear or /we help fill for more information.
-
In-game, in chat, type /we
where is one of the following : Commands help [command] : dipslay help. If command is specified, display help for that command. Ex: /we help fill select : start area selection cancel : cancel area selection fill [-c] : fill the selected area with the specified terrain. Add -c to clear everything, first. All available textures are air (id 0) dirt (id 1) grass (id 2) stone (id 3) gravel (id 4) rock (id 5) farmland (id 6) mud (id 7) snow (id 8) sand (id 9) desertdirt (id 10) desertstone (id 11) clay (id 12) dungeonwall (id 13) dungeonfloor (id 14) bonewall (id 15) hellstone (id 16) Ex: /we fill -c grass clear [obj|con|veg|all|abs] : clear the selected area of (obj)ects, (con)structions, (veg)etations, (all), or (abs)olutely everything. (Default all) Ex: /we clear veg place id [north|east|south|west [sideway|flipped]] : place a block with the given id, optionally facing the given direction and put sideway or flipped. Ex: /we place ramp 121 east flipped Block Types block (aliases: b, blk) cylinder (aliases: c, cyl) cylinderhalf (aliases: ch, cylh) stair (aliases: s, s1, stair1) stair2 (aliases: s2) stair3 (aliases: s3) staircorner (aliases: sc, stairc) stairinnercorner (aliases: sic, stairic) ramp (aliases: r) ramphalfcorner (aliases: rhc, ramphc, ramphalfc) rampinnercorner (aliases: ric, rampic) rampcorner (aliases: rc, rampc) halfblockbottom (aliases: hb, hb1, hbb, halfblk, halfblk1, halfblkb, halfblock, halfblock1 halfblockb) halfblockcenter (aliases: hb2, hbc, halfblk2, halfblkc, halfblock2, halfblockc) halfblocktop (aliases: hb3, hbt, halfblk3, halfblkt, halfblock3, halfblockt) pyramid (aliases: p, pyr) arc (aliases: a) -
6 .gitmodules @@ -0,0 +1,6 @@ +[submodule "i18n"] + path = i18n + url = https://github.com/RisingWorld/i18n +[submodule "command-parser"] + path = command-parser + url = https://github.com/RisingWorld/command-parser 2 README.md @@ -0,0 +1,2 @@ +# World Edit + 149 blocks.lua @@ -0,0 +1,149 @@ + +--- Thank you yahgiggle !! +--- https://forum.rising-world.net/index.php/Thread/1210-SCRIPT-World-Edit/?postID=12454#post12454 +local blockDef = { + block = { north = 0, east = 0, south = 0, west = 0 }, + + cylinder = { north = 3, east = 3, south = 3, west = 3 }, + cylindersideway = { north = 204, east = 207, south = 204, west = 207 }, + + cylinderhalf = { north = 6, east = 9, south = 12, west = 15 }, + + stair = { north = 39, east = 42, south = 45, west = 48 }, + stairsideway = { north = 273, east = 276, south = 279, west = 282 }, + stairflipped = { north = 285, east = 288, south = 291, west = 294 }, + + stair2 = { north = 51, east = 54, south = 57, west = 60 }, + + stair3 = { north = 63, east = 66, south = 69, west = 72 }, + + staircorner = { north = 75, east = 78, south = 81, west = 84 }, + staircornerflipped = { north = 297, east = 300, south = 303, west = 306 }, + + stairinnercorner = { north = 87, east = 90, south = 93, west = 96 }, + stairinnercornerflipped = { north = 309, east = 312, south = 315, west = 318 }, + + ramp = { north = 99, east = 102, south = 105, west = 108 }, + rampsideway = { north = 225, east = 228, south = 231, west = 234 }, + rampflipped = { north = 111, east = 113, south = 117, west = 120 }, + + ramphalfcorner = { north = 123, east = 126, south = 129, west = 132 }, + ramphalfcornerflipped = { north = 147, east = 150, south = 153, west = 156 }, + + rampinnercorner = { north = 135, east = 138, south = 141, west = 144 }, + rampinnercornerflipped = { north = 159, east = 162, south = 165, west = 168 }, + + rampcorner = { north = 171, east = 174, south = 177, west = 180 }, + rampcornerflipped = { north = 183, east = 186, south = 189, west = 192 }, + + halfblockbottom = { north = 195, east = 195, south = 195, west = 195 }, + halfblockcenter = { north = 198, east = 198, south = 198, west = 198 }, + halfblocktop = { north = 201, east = 201, south = 201, west = 201 }, + + pyramid = { north = 219, east = 219, south = 219, west = 219 }, + pyramidflipped = { north = 222, east = 222, south = 222, west = 222 }, + + arc = { north = 237, east = 240, south = 243, west = 246 }, + arcflipped = { north = 249, east = 252, south = 255, west = 258 }, + arcsideway = { north = 261, east = 264, south = 267, west = 270 } +}; + +--- Add any alias blocks may have to the blockDef table +local blockAliasMap = { + b = "block", + blk = "block", + + c = "cylinder", + cyl = "cylinder", + + ch = "cylinderhalf", + cylh = "cylinderhalf", + + s = "stair", + s1 = "stair", + stair1 = "stair", + + s2 = "stair2", + + s3 = "stair3", + + sc = "staircorner", + stairc = "staircorner", + + sic = "stairinnercorner", + stairic = "stairinnercorner", + + r = "ramp", + rhc = "ramphalfcorner", + ramphc = "ramphalfcorner", + ramphalfc = "ramphalfcorner", + + ric = "rampinnercorner", + rampic = "rampinnercorner", + + rc = "rampcorner", + rampc = "rampcorner", + + hb = "halfblockbottom", + hbb = "halfblockbottom", + hb1 = "halfblockbottom", + halfblkb = "halfblockbottom", + halfblockb = "halfblockbottom", + halfblock1 = "halfblockbottom", + hbc = "halfblockcenter", + hb2 = "halfblockcenter", + halfblkc = "halfblockcenter", + halfblockc = "halfblockcenter", + halfblock2 = "halfblockcenter", + hbt = "halfblocktop", + hb3 = "halfblocktop", + halfblkt = "halfblocktop", + halfblockt = "halfblocktop", + halfblock3 = "halfblocktop", + + p = "pyramid", + pyr = "pyramid", + + a = "arc" +}; + + +--- Return the absolute block id for the given variation, type, orientation and direction +-- @param id the variation texture id of the block +-- @param blockType a block type as string (see aliasses) +-- @param direction may be "north", "south", "east", or "west" +-- @param orientation may be "", "sideway" or "flipped" +-- @return a numeric id +function getBlockId(id, blockType, direction, orientation) + local idDef; + + if id == nil then + return nil; + end; + + blockType = blockType and blockAliasMap[blockType] or blockType; + direction = direction and direction or "north"; + orientation = orientation and orientation or ""; + + idDef = blockDef[blockType..orientation] or blockDef[blockType]; + + if idDef and idDef[direction] then + id = (idDef[direction] * 100) + id; + end + + return id; +end + + +--- Return all valid block types +-- @return table +function getBlockTypes() + local types = {}; + for key,val in pairs(blockDef) do + if string.sub(key, -7) ~= "flipped" and string.sub(key, -7) ~= "sideway" then + table.insert(types, key); + end + end + + return types; +end 1 command-parser @@ -0,0 +1 @@ +Subproject commit 73b8c17cc65b2544a714a0f5e4c53fccb25f6547 10 config.properties @@ -0,0 +1,10 @@ + + +# Comma-separated list of available locales. Each available locales +# should be specified in the locales directory. For example, +# en.properties represents the localization for 'English'. +i18n.availableLocales=en + +# Default locale +i18n.defaultLocale=en + 9 definition.xml @@ -0,0 +1,9 @@ +
+ 1 i18n @@ -0,0 +1 @@ +Subproject commit 6b02893db83ec5af7418adfda3314d36eb85f262 20 lc_messages/en.locale @@ -0,0 +1,20 @@ +# English +# Locale for World Edit script + +error.restricted=You don't have admin rights on this server. Request Admin rights or use /we-cancel to cancel the selection. + +cmd.no.selection=No selection +cmd.missing.arg=Missing argument: %s +cmd.unknown=Invalid command +cmd.use.args=Use one of the following arguments: %s + +select.start=Select the area to edit. Type "/we help" for help. +select.cancelled=Selection cancelled. + +help.usage=All commands can display help. Ex: %s +help.select.usage=Select an area to edit. +help.cancel.usage=Cancel any area selection in progress. +help.clear.usage=Clear the selected area of [obj]ects, [con]structions, [veg]egations, [all], or [abs]olutely everything. +help.fill.usage=Fill the selected area with terrain or ore. +help.place.usage=Fill the selected area with blocks (the last two arguments are optional) +help.place.blocktypes=%s should be one of : %s 197 listeners/commandListener.lua @@ -0,0 +1,197 @@ + +include("command-parser/parse-args.lua"); +include("security.lua"); +include("table-ext.lua"); + + +local fillAvailableArgs = {"air","dirt","grass","stone","#id"}; +local clearAvailableArgs = {"obj","con","veg","all","abs"}; +local textureAliasMap = { + air = 0, + dirt = 1, + stone = 2, + grass = 3 + --- TODO : add more textures! (update fillAvailableArgs, too) +}; + + +local function weHelp(event, args) + local helpContext = string.lower(args[1] or ""); + + if helpContext == "select" then + print("Showing /we select help"); + event.player:sendTextMessage("[#33FF33]/we select"); + event.player:sendTextMessage("[#FFFF00]"..i18n.t(event.player, "help.select.usage")); + elseif helpContext == "cancel" then + print("Showing /we cancel help"); + event.player:sendTextMessage("[#33FF33]/we cancel"); + event.player:sendTextMessage("[#FFFF00]"..i18n.t(event.player, "help.cancel.usage")); + elseif helpContext == "clear" then + print("Showing /we clear help"); + event.player:sendTextMessage("[#33FF33]/we clear ["..table.concat(clearAvailableArgs, '|').."]"); + event.player:sendTextMessage("[#FFFF00]"..i18n.t(event.player, "help.clear.usage")); + elseif helpContext == "fill" then + print("Showing /we fill help"); + event.player:sendTextMessage("[#33FF33]/we fill ["..table.concat(fillAvailableArgs, '|').."]"); + event.player:sendTextMessage("[#FFFF00]"..i18n.t(event.player, "help.fill.usage")); + elseif helpContext == "place" then + print("Showing /we place help"); + event.player:sendTextMessage("[#33FF33]/we place blocktype id [north|east|south|west] [sideway|flipped]"); + event.player:sendTextMessage("[#FFFF00]"..i18n.t(event.player, "help.place.usage")); + event.player:sendTextMessage("[#FFFF00]"..i18n.t(event.player, "help.place.blocktypes", "blocktype", table.concat(getBlockTypes(), ', '))); + else + print("Showing general help"); + event.player:sendTextMessage("[#33FF33]/we help|select|cancel|clear|fill|place [args]"); + event.player:sendTextMessage("[#FFFF00]"..i18n.t(event.player, "help.usage", "/we help clear")); + end +end + + +local function weSelect(event) + print("Area selection start"); + event.player:enableMarkingSelector(function() + + end); + event.player:sendYellMessage(i18n.t(event.player, "select.start")); +end + + +local function weCancel(event) + print("Area selection cancelled"); + event.player:disableMarkingSelector(function(markingEvent) + if markingEvent ~= false then + event.player:sendTextMessage("[#FF0000]"..i18n.t(event.player, "select.cancelled")); + end + end); +end + + +local function weClear(event, args, flags) + local clearObjType = string.lower(args[1] or "all"); + + event.player:disableMarkingSelector(function(markingEvent) + if markingEvent ~= false then + local coords = getCoordsFromMarkEvent(markingEvent); + + if clearObjType == "obj" then + print("Clearing area of objects"); + removeObjects(coords); + elseif clearObjType == "con" then + print("Clearing area of construction"); + removeConstr(coords); + elseif clearObjType == "veg" then + print("Clearing area of vegetation"); + removeVeg(coords); + elseif clearObjType == "all" then + print("Clearing area of all"); + removeAll(coords, false); + elseif clearObjType == "abs" then + print("Clearing area of absolutely everything"); + removeAll(coords, true); + else + return event.player:sendTextMessage("[#FF0000]"..i18n.t(event.player, "cmd.use.args", table.concat(clearAvailableArgs, ","))); + end + else + event.player:sendTextMessage("[#FF0000]"..i18n.t(event.player, "cmd.no.selection")); + end + end); + +end + + +local function wePlaceBlock(event, args, flags) + local blockType = args[1] and string.lower(args[1]); + local direction = args[3] and string.lower(args[3]) or "north"; + local orientation = args[4] and string.lower(args[4]) or ""; + local blockId = args[2] and getBlockId(tonumber(args[2]), blockType, direction, orientation); + + if blockType and blockId then + + if blockId 16 then + print("Terrain id adjusted from "..id.." to 0"); + id = 0; + end; + + event.player:disableMarkingSelector(function(markingEvent) + if markingEvent ~= false then + local coords = getCoordsFromMarkEvent(markingEvent); + + print("Filling area with id "..id..(cleanup ~= nil and " with cleanup" or "")); + + fillWith(coords, id, cleanup); + else + event.player:sendTextMessage("[#FF0000]"..i18n.t(event.player, "cmd.no.selection")); + end + end); + else + event.player:sendTextMessage("[#FF0000]"..i18n.t(event.player, "cmd.use.args", table.concat(fillAvailableArgs, ","))); + end +end + + + +local function onPlayerCommand(event) + local args, flags = parseArgs(event.command); + local cmd; + + if #args >= 1 then + + if string.lower(args[1]) == "/we" then + -- command handled + event:setCancel(true); + + cmd = string.lower(args[2] or ""); + + if cmd == "help" then + if checkPlayerAccess(event.player, "help") then weHelp(event, table.slice(args, 3)); end; + elseif cmd == "select" then + if checkPlayerAccess(event.player, "select") then weSelect(event); end; + elseif cmd == "cancel" then + weCancel(event); -- no player access necessary... + elseif cmd == "clear" then + if checkPlayerAccess(event.player, "clear") then weClear(event, table.slice(args, 3), flags); end; + elseif cmd == "fill" then + if checkPlayerAccess(event.player, "fill") then weFill(event, table.slice(args, 3), flags); end; + elseif cmd == "place" then + if checkPlayerAccess(event.player, "place") then wePlaceBlock(event, table.slice(args, 3), flags); end; + else + print("Unknown command: "..event.command); + event.player:sendTextMessage("[#FF0000]"..i18n.t(event.player, "cmd.unknown")); + end + end + end +end +addEvent("PlayerCommand", onPlayerCommand); 11 security.lua @@ -0,0 +1,11 @@ + + + +function checkPlayerAccess(player, permission) + if player:isAdmin() == false then + player:sendTextMessage("[#FF0000]"..i18n.t(player, "error.restricted")); + return false; + else + return true + end +end 22 table-ext.lua @@ -0,0 +1,22 @@ + + +--- Slice part of a table and return a new copy +--- +--- Note : This methods does not check if tbl is a table, it does not check +--- if first and last are valid... it is the responsibility of the caller +--- to make sure all args are valid. +--- +-- @param tbl the table to slice +-- @param first (optional) the starting index (default 1) +-- @param last (optional) the last index (default #tbl) +-- @param step (optinal) skip elements between first...last (default 1) +-- @return table +function table.slice(tbl, first, last, step) + local sliced = {} + + for i = first or 1, last or #tbl, step or 1 do + sliced[#sliced+1] = tbl[i] + end + + return sliced +end 89 worldedit.lua @@ -0,0 +1,89 @@ +--- +--- World Edit script +--- + +-- global variables; required by other modules +config = getProperty("config.properties"); + +-- load dependencies +include("i18n/i18n.lua"); +include("blocks.lua"); +include("listeners/commandListener.lua"); + + +local world = getWorld(); + + +function onEnable() + + i18n.init(config); + + -- The console already prepend the script name on every log output + print("Script v0.5.61 loaded."); +end + + + +function getCoordsFromMarkEvent(e) + return e ~= false and { + e.startChunkpositionX, + e.startChunkpositionY, + e.startChunkpositionZ, + + e.startBlockpositionX, + e.startBlockpositionY, + e.startBlockpositionZ, + + e.endChunkpositionX, + e.endChunkpositionY, + e.endChunkpositionZ, + + e.endBlockpositionX, + e.endBlockpositionY, + e.endBlockpositionZ + } or nil; +end + + + +function fillWith(c, texId, cleanup) + if cleanup then + removeAll(c, true); + end + world:setTerrainDataInArea(c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12], texId); +end + +function fillWithBlock(c, blockID) + world:setBlockDataInArea(c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12], blockID); +end + + +function removeObjects(c) + world:removeAllObjectsInArea(c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12]); +end + +function removeConstr(c) + world:removeAllConstructionsInArea(c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12]); +end + +function removeVeg(c) + world:removeAllVegetationsInArea(c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12]); +end + +function removePlayerBlocks(c) + fillWithBlock(c, 0); +end + +function removeTerrainBlocks(c) + world:setTerrainDataInArea(c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12], 0); +end + +function removeAll(c, clearTerrain) + removeObjects(c); + removeConstr(c); + removeVeg(c); + removePlayerBlocks(c); + if clearTerrain then + removeTerrainBlocks(c); + end +endWorld Edit +Allow editing world with ease. Based on andyzee's original script. +worldedit.lua +LordFoobar ++ + +
ZoomZap