--Everything here https://www.lua.org/manual/5.4/manual.html#6 All objects are implemented as tables. Clients, dynamics, and items in particular have a table like this: object={type="typeString",id=} setmetatable(object,typeMetatable) Bricks also have a light-userdata pointer: brick={type="brick",id=,pointer=} setmetatable(brick,BRICKMETATABLE) If bricks in particular are accessed after they are deleted, for example: brick=getBrickIdx(0) brick:remove() brick:setColor(0,0,0,0) the server will crash. Generic functions: (17) loadLodSave(filePath,offsetX,offsetY,offsetZ) -- Loads an .lbs Land of Dran binary save file loadBlocklandSave(filePath) -- Loads a .bls Blockland save file. clearAllBricks() -- More quickly clears all bricks on the server registerEventListener(eventName,functionName) -- Same purpose as a Torquescript Package unregisterEventListener(eventName,functionName) -- Reverses registerEventListener messageAll(text,category) -- Category optional, sends a chat message to all players bottomPrintAll(text,milliseconds) -- Displays message at bottom of screen for X milliseconds printNetIDs() -- Shows how many of each object type have been allocated so far this run echo(strng) -- Writes to the console and also shows output on client admin console gui scheduleID = schedule(milliseconds,functionName,args...) -- Executes function in X milliseconds. Arguments are optional and will be passed to the scheduled function cancel(scheduleID) -- Cancels a previous scheduled call to a function saveBuild(filePath,disableOwnership) -- Saves the entire build to a file as a binary LoD save. Defaults to saving ownership. typeID = getSpecialType(name) -- Takes the file name minus directory and extension *or* the uiName and returns the integer typeID for that special brick type setWaterLevel(height) --- This will be expanded upon soon, but figured I'd get this in here at least before release setColorPalette(idx,r,g,b,a) -- Sets a color of the colorset. This can be done at anytime, connected players will update their colorset instantly. setRespawnTime(milliseconds) -- How long to make players wait to respawn in milliseconds. Must be between 0 and 60000. radiusImpulse(xPos,yPos,zPos,radius,power,doDamage) -- Power can be between -1000 and 1000. Negative values are implosions, positive are explosions. Radius must be >0 and <100. setDNCTime(timeOfDay) -- Between -1.0 and 1.0. Both -1.0 and 1.0 are midnight, 0.0 is noon. setDNCSpeed(secondsInDay) -- Needs to be 1.0 or greater for now. fileID = addCustomFile(shortName,relativePath) -- Path is relative to add-ons folder. Name is used in the accept/deny downloads dialog. Path must meet the following requirements: >2 characters Only have a-z A-Z 0-9 underscore period dash (-) and slash (/) Only one period anywhere in the path Cannot start with a period or a slash Can not exceed 64 characters Example: music_coolsong/mySong.wav Name must be between 2 and 48 characters File itself must: Be a wav png obj or blb file type. (For now, more types will be added later) Be between 1 byte and 2 million bytes. (Will probably be increased later) addSoundType(fileID,scriptName) -- fileID is from addCustomFile. scriptName is used with playSound functions. addMusicType(fileID,scriptName) -- Same as above, but sound will be included in GUI drop downs for music bricks and such addSpecialBrickType(filePath,uiName,customColMesh) -- filePath relative to add-ons folder, uiName used for UI but also Blockland saves, customColMesh omitted or false for rect. prism mesh, true for convex hull mesh reloadEnvironment(textFilePath) -- Reloads an environment.txt file and sends updated DNC cycle / lighting info to clients. Only restriction is if switching between DNC and IBL connected clients will need to rejoin to see update Audio functions: (4) playSound(name,pitch,loudness) -- Plays a sound globally to all clients. Pitch optional, defaults to 1.0. Must be between 0.1 and 10.0. Loudness must be between 0.0 and 1.0, defaults to 1.0. playSound(name,x,y,z,pitch,loudness) -- Plays a sound at a given location. See note on pitch above. playSoundClient(client,name,pitch,loudness) -- Plays a sound to one client only, see note on pitch and loudness setAudioEffect(nameOfEffect,client) -- See reference for list of valid strings for effect name. If client argument is omitted it applies to everyone. Emitter functions: (8) table = getParticleTable(dbName) -- Returns a particle's settings as a Lua table table = getEmitterTable(dbName) -- Returns an emitter's settings as a Lua table addParticleType(dbName,table) -- Creates a particle type addEmitterType(dbName,table) -- Creates an emitter type emitter = addEmitter(dbName,x,y,z) -- Creates an emitter emitter:attachToDynamic(dynamic,nodeName) -- Nodename is what body part to use, optional emitter:attachToBrick(brick) -- If nil is passed emitter will stay put at its previous location emitter:remove() See bottom of this document for emitter and particle properties! Light functions: (8) light = addLight(x,y,z,r,g,b) light = addLight(brick,r,g,b) light:setPhi(angle) -- Changes if the light is a spotlight and how wide the spotlight is, 0 < x < 6.28 light:setSpotlightDirection(x,y,z) -- Only matters if light is a spotlight light:setBlinkSpeed(r,g,b) -- Sine wave if positive, cos if negative, lets you make lights change color over time. Value is the speed. -0.001>y>0.001 is not blinking light:setColor(r,g,b) light:setYawVel(speed) -- How fast a spotlight (only works for spotlights) changes horizontal direction light:remove() Client functions: (26) number = getNumClients() -- How many people are connected to the server client = getClientIdx(index) -- Get a client from 0 to getNumClients() - 1 client = getClientByName(name) -- Partial and case insenitive matches possible client = gcbn(name) -- Alias of the above client = brickCar:getOwner() -- Who built / loaded / sliced a car client = brick:getOwner() -- Gets who built a brick unless they left the server (for now) ping = client:getPing() -- Returns number of milliseconds ping name = client:getName() string = client:getIP() -- Returns IPv4 octects as string dynamic = client:getCameraTarget() -- What is the camera following client:kick() -- Disconnects a player bool = client:hasEvalAccess() -- Check if a player has logged into the admin gui clientside client:endAdminOrb() -- Ends admin orbing without teleporting player client:setJetsEnabled(bool) -- Yes, it is weird this is a client function, not a player function for now client:sendMessage(text,category) -- Same args as messageAll client:spawnPlayer(x,y,z) -- Spawns or respawns a client at a given position client:clearBricks() -- Clears all of a clients bricks more quickly client:bottomPrint(text,timeoutMS) -- Same args as bottomPrintAll client:setPlayer(dynamic) -- Change which object the client controls as a player client:bindCamera(dynamic) -- Independantly change which object the client looks at client:setCameraPosition(x,y,z) -- Unbinds camera from any objects and fixes it at a location client:setCameraDirection(x,y,z) -- Only has an effect if freelook == false and camera is unbound client:setCameraFreelook(bool) -- Sets if the client can turn their camera if unbound client:isGuest() -- Returns false if the player has logged into an account to join client:getID() -- If the client is logged in it will return the unique ID of their account, otherwise returns 0 client:setVignette(strength,r,g,b) -- Creates a colored ring around the player's screen. Strength is from 0 to 10. r,g,b is optional and will use last set value otherwise. client:allowBuilding(bool) (Players and projectiles are just dynamics with particular flags set) Dynamic functions: (34) dynamic = addProjectile(typeID,xPos,yPos,zPos,xVel,yVel,zVel,tagStr) -- tagStr is optional and passed to onProjectileHit dynamic = addDynamic(typeID) -- Will be changed to dbName soon number = getNumProjectiles() -- How many projectiles are there, will always be equal or smaller than getNumDynamics() dynamic = getProjectileIdx(index) -- From 0 to getNumProjectiles()-1 number = getNumDynamics() -- How many physics objects are on the server currently dynamic = getDynamicIdx(index) -- Get a physics object from 0 to getNumDynamics() - 1 dynamic = getPlayerByName(string) - Equivlent to gcbn(name):getPlayer() dynamic = client:getPlayer() -- Gets a client player or returns nil if none exists dynamic:setGravity(x,y,z) -- Indivdual objects gravity dynamic :setVelocity(x,y,z) -- Sets linear velocity dynamic:setAngularFactor(x,y,z) -- Sets artifical rotation limitation around each axis dynamic:setRotation(z,y,x,w) -- Sets the objects rotation with a quaternion dynamic:setRotation(yaw,pitch,roll) -- Sets objects rotation with eular angles in radians dynamic:setPosition(x,y,z) -- Moves the object dynamic:setRestitution(value) -- Sets how bouncy an object is. (doesn't work for players) dynamic:setAngularVelocity(x,y,z) -- Spins an object around various axis at the specified speeds dynamic:remove() x,y,z = dynamic:getPosition() dynamic:setNodeColor(nodeName,r,g,b) dynamic:attachByRope(otherDynamic,numberOfSegments,AposX,AposY,AposZ,BposX,BposY,BposZ) --numberOfSegments between 1 and 50, Apos should be in world space in or on the collision box for the first dynamic, Bpos likewise for otherDynamic dynamic:setShapeName(name,r,g,b) -- Sets text and color of text above object x,y,z = dynamic:getAngularVelocity() x,y,z, = dynamic:getVelocity() w,x,y,z, = dynamic:getRotation() -- Quaternion bool = dynamic:isProjectile() -- Was this object created with addProjectile? bool = dynamic:isPlayer() -- Is dynamic == getClientIdx(idx):getPlayer() true for at least one value of idx. dynamic:setCanTakeDamage(bool) -- Can this object take damage? Default is false. Health starts at 100 for dynamics on creation. dynamic:applyDamage(amount,tagStr) -- tagStr is optional and passed to dynamicDeath event if it dies. Creates pain emitter, pain sounds, and sets pain vignette. Non-players simply dissapear on death by default. dynamic:giveItem(item) -- Gives a specific item to a dynamic (player). (You have to create the item first) Returns true if it was succesful. dynamic:switchHeldSlot(slot) -- Choose which inventory slot is used on a player/dynamic. dynamic:setWalking(bool) -- Plays the walking animation and flags the dynamic as a player, even if not controlled by anyone. dynamic:setHeadPitch(pitch) -- Pitch between -1 and 1. Flags the dynamic as a player, even if not controlled by anyone. dynamic:fireHeldGun() -- If the dynamic/player is holding a weapon, will fire onWeaponFire for that dynamic/item. Could crash the server if the onWeaponFire also causes a call to fireHeldGun. dirX,dirY,dirZ = dynamic:getCamDir() -- Gets direction of the player/dynamic dynamic:setHealth(amount) -- Amounts <= 0 will trigger death event dynamic:clearRopes() -- Destroys all ropes attached to the dynamic (Items are essentially built on top of a dynamic. You can tell if a dynamic reference corresponds to an item reference by compairng their IDs) (i.e. dynamic = getDynamicIdx(0) item = getItemIdx(0) if dynamic.id == item.id then ...) Item functions: (12) numItems = getNumItems() item = getItemIdx(index) -- From 0 to getNumItems() - 1. Includes items on the ground and in inventories. item = addItem(uiName,x,y,z) -- Creates an item and drops it in the world. uiName is case sensitive. item:remove() -- Deletes the item, both from player inventories and the ground. dynamic = item:getHolder() -- Returns a dynamic (player) that is holding this tool, or nil if its on the ground. uiName = item:getName() -- Returns uiName of the type of this tool item:setFireSound(soundName,pitch,gain) -- Sets the item to play a sound when the player fires it ahead of time. See playSound for pitch and gain description. item:setFireAnim(animName,speed) -- Sets which animation will play when the player fires the item. Speed is between 0 and 10. item:setItemCooldown(milliseconds) -- Sets how often the item can be fired in milliseconds item:setFireEmitter(emitterName,meshName) -- meshName is optional, but will position the emitter in the center of that specific mesh if set. item = dynamic:getHeldTool() -- Which tool is this player holding? Returns nil if none item:setPerformRaycast(doRaycast,doBulletTrail,bulletTrailRed,Green,Blue,bulletTrailSeconds) -- If the gun should attempt a raycast when fired, triggering raycastHit event on hit Brick functions: (23) brickCount = getNumBricks() brick = getBrickIdx(index) -- From 0 to getNumBricks() - 1 count = getNumNamedBricks(name) -- Gets number of bricks with that name brick = getNamedBrickIdx(name,index) -- From 0 to getNumNamedBricks(name) - 1 brick = getBrickAt(x,y,z) -- Dimensions in number of studs name = brick:getName() width,length,height = brick:getDimensions() r,g,b,a = brick:getColor() x,y,z = brick:getPosition() bool = brick:isSpecial() -- Does it have a custom model or is a generic resizable rectangle id = brick:getTypeID() -- Only use if brick is special brick:remove() -- Don't call functions on this brick after you remove it or server crashses brick:setColliding(bool) -- Enable or disable collision brick:setColor(r,g,b,a) -- Not limited to color palette brick:setPosition(x,y,z) -- Pretty buggy, might not update collision shape brick:setAngleID(angleID) -- Same as above, pretty buggy, may not update collision shape numBricks = client:getNumBricks() brick = client:getBrickIdx(index) -- From 0 to client:getNumBricks() - 1 id = brick:getOwnerID() -- Gets actual ID of the builder of a brick even if they're offline. Guests all have ID 0 brick = addBasicBrick(x,y,z,red,green,blue,alpha,width,length,height,angleID,material) -- Adds a basic brick and returns it or nil on failure. angleID must be between 0 and 3. Material increments by 1 for each colorFx (pearl, hologram, chrome...), and by 1000 for each shapeFx (bouncy, undulo...) brick = addSpecialBrick(x,y,z,red,green,blue,alpha,typeID,angleID,material) -- See notes for addBasicBrick. Use getSpecialType for getting the typeID from a brick name brick:setName(name) -- Can be empty string to remove name brick:setPrint(printName,printMask) -- printName is a string, see Blockland's print names. Printmask is optional, defaults to all faces (255). 1=top,2=bottom,4=north,8=south,16=east,32=west. mask=0 or name="" removes print. Brick car function: (15) numBrickCars = getNumBrickCars() brickCar = getBrickCarIdx(index) numBricks = brickCar:getNumBricks() -- You cannot iterate through these bricks yet... howMany = client:getNumVehicles() -- How many cars the client has at the moment x,y,z, = brickCar:getPosition() x,y,z = brickCar:getVelocity() brickCar:setPosition(x,y,z) brickCar:setVelocity(x,y,z) client = brickCar:getDriver() -- Get the client currently in the car brickCar:setGravity(x,y,z) brickCar:setAngularVelocity(x,y,z) brickCar:setRotation(w,x,y,z) -- Quaternion w,x,y,z = brickCar:getRotation() x,y,z = brickCar:getAngularVelocity() id = brickCar:getOwnerID() -- Same as above Events: raycastHit -- This might be called when a gun that has setPerformRaycast(true) called on it is fired Arguments: dynamic -- The player who fired the item item -- The item that was fired dynamic/brick -- What was hit posX -- Where in the world the hit occured posY posZ dynamicDeath Arguments: dynamic -- The player (or non-player dynamic that died) tagStr -- What killed it? The tag string from applyDamage, addRaycastProjectile, or "explosion" if from radiusImpulse Returns: cancelled -- If set to true, object will be pegged to a minimum of 1 health. If false, players respawn and non-player objects are simply deleted. onWeaponFire -- When a player clicks (assuming cooldown is over) or dynamic:fireHeldGun is called Arguments: (remind me to double check if this is right) item -- The item being fired dynamic -- The player firing the item camDirX -- What direction the player is looking in while firing camDirY camDirZ Returns: None onProjectileHit -- When a dynamic created with addProjectile hits something Arguments: (remind me to double check if this is right) dynamic -- The projectile that is about to be deleted posX -- The world position where the projectile hit an object posY posZ tagStr -- Passed from addProjectile Returns: None clientAdminOrb -- Called upon anyone? pressing F7 or F8 or whatever they rebound those keys to Arguments: client startOrStop -- Bool, determines if the start admin orb or stop orb key pressed cancelled -- Bool x y z Returns: Cancelled -- Set to true to cancel this event x y z clientChat Arguments: client message Returns: message cancelled clientTryLoadCar Arguments: client brickCar loadCarAsCar -- True for create vehicle, false for load bricks of vehicle Returns: cancelled -- This will delete the car before anyone sees it clientLeave Arguments: Client spawnPlayer Arguments: client x y z Returns: cancelled x y z clientClickBrick Arguments: client brick x y z isLeft Returns: (nothing) clientPlantBrick -- Called after the brick is planted... Arguments: client brick Returns: (nothing) clientJoin Arguments: client Returns: (nothing) Emitter table members: particles -- A string of dbNames of particles to eject, separated by spaces ejectionOffset -- How far away from the ejection position to spawn particles on average ejectionPeriodMS -- How many MS between ejection events ejectionVelocity -- How fast to eject particles away from the center periodVarianceMS -- Randomness for ejectionPeriodMS phiReferenceVel -- How fast the position to ejection particles at revolves around the center phiVariance -- How much randomness is added to the up/down portion of the spherical coords of the ejection thetaMax -- What longitude to start ejection thetaMin -- What loggitude to end ejection at, random between these points uiName -- Used for menus Particle table members: texture -- Can be any image inside of the assets or add-ons folder or subdirectories for now color0-3 -- RGBA floats separted by spaces size0-3 -- Floats time0-3 -- Time keys for interpolating size and color keys, 0.0 to 1.0 drag -- 3 dimensional drag coefficient, keep low but never exactly 0! gravity -- 3 dimension gravity coefficient, keep low but never exactly 0! inheritedVelFactor -- How much of a mounted object (car, player)'s velocity to spawn with lifetimeMS -- How long the particle lives for lifetimeVarianceMS -- Randomness for lifetimeMS spinSpeed -- How fast each particle spins around useInvAlpha -- Changes the equation for blending, recommend smoke+fire type stuff be true needsSorting -- If these particles should be sorted for distance each frame, very expensive! But necesairy for anything that has transparency values other than 0 and 1 in its texture. See add-ons/emitter_defaults/server.lua (BUT DONT CHANGE!) for examples of particles and emitters! Default sound strings passable to playSound: (Astrisks indicate music loops) BrickBreak ClickMove ClickPlant ClickRotate FastImpact HammerHit Jump PlayerConnect PlayerLeave PlayerMount ToolSwitch WrenchHit WrenchMiss *Zero Day *Vehicle Hover *Police Siren *Birds Chirping *Euphoria Death Win Splash Spawn NoteFs5 NoteA6 Beep Rattle Spray ClickChange Admin *Analog *Drugs C5Bass C5Brass C5Flute C5Guitar C5Piano C5Saw C5Square C5SteelDrum C5String C5Synth C5Timpani C5Vibraphone DrumsetClap DrumsetCymbal DrumsetDrumSnare DrumsetESnare DrumsetKick DrumsetPedalC DrumsetPowerSnare DrumsetTom Explosion Launch oof1 oof2 oof3 oof4 berettaShot berettaReload Audio effect strings: generic paddedcell auditorium concerthall cave forest plain underwater drugged dizzy psychotic outhouse heaven hell memory dustyroom waterroom racer tunnel