Package: mlogpp
mlog++statically typed high level mindustry logic languageInstallation:pip install mlogppUsage:python -m mlogpp <file(s) to compile> [options]Options:-o:f,--output-file- output to file-o:s,--output-stdout- output to stdout-o:c,--output-clip- output to clipboard (default)-v,--verbose- output more information-l,--lines- print line numbers when output is stdout-a,--assembly- compile as mlog++ assembly-V,--version- print version and exitExamples:Hello, World:Blockmessage1print("Hello, World!")printflush(message1)PrintsHello, World!Constants:constx=5constlety="constant"constnuma,ba=5b=3For loops:for(numi=1;i<11;i+=1){print(i)if(i<10){print(", ")}}Blockmessage1printflush(message1)Prints1, 2, 3, 4, 5, 6, 7, 8, 9, 10Ranges:for(i:1..5){print(i+1)print(" ")}Blockmessage1printflush(message1)Prints2 3 4 5Functions:functionlength(numx,numy)->num{returnsqrt(x*x+y*y)}print(length(3,4))Blockmessage1printflush(message1)Prints5Memory cell access:Blockcell1,message1cell1[0]=10print(cell1[0])printflush(message1)Prints10Subcommands:ubind(@mega)ucontrol.move(@thisx,@thisy)Makes all@megaunits move to the processorScopes:numa=0#useletfortypeinferenceletb=0functiontest(numx){leta=xb=x}test(10)print(a)print(" ")print(b)Blockmessage1printflush(message1)Prints0 10Structures:Blockmessage1structVec2{numxnumystaticsize=2staticget_size(){returnVec2::size}functionincrease_x(self,numn){self.x+=n}}letvec=Vec2(10,20)vec.increase_x(5)#staticpropertiescanbeaccessed#using`.`fromaninstance#orusing`::`fromthetypevec.y+=vec.size+Vec2::get_size()print(vec.x)print(" ")print(vec.y)printflush(message1)Prints15 24Assembly:${LOOP_LENGTH=2+3}i=0loop_start:i+=1print(i)print("\n"):loop_start(i<${LOOP_LENGTH})Blockmessage1printflush(message1)Prints1 2 3 4 5Longer examples can be found inexamples/Features:variablesnum x = 1type inferencelet x = 2constantsconst x = 2const num y = 3const let z = 5typesnum,strBlock,Unit,BlockType,UnitType,ItemType,LiquidType,Controller,Teamcomments# commentmemory cell accesscell1[0] = cell1[1]functionsfunction f(num x, num y) -> num { return x + y }subcommandsucontrol.move(1, 2)if / elseif (a == b) { print("a") } else { print("b") }while loopswhile (a > b) { b += 1 }for loopsfor (num i = 0; i < 10; i += 1) { print(i) }rangesfor (i : 5) { print(i) }break / continuenative functionsubind(@mega)constantsconst VALUE = 30inline python subset${x = 7 ^ 2}print(${y = x // 2})${"cell" + x}[0] = youtput from builtin functions directly to new variables (can be constants)ulocate.building(core, true, x: num, y: num, building: const Block)structures with inheritancestruct Vec2 { num x, y }struct Vec3 : Vec2 { num z }colors for effectseffect.hit(x, y, %_35adc8)Native functions:readresult,cell,positionRead data fromcellatpositiontoresultwritedata,cell,positionWritedatatocellatpositiondrawoperation,arg0...arg5Add a drawoperationto the draw bufferOperations:clearred,green,bluecolorred,green,blue,alphastrokewidthlinex1,y1,x2,y2rectx,y,width,heightlineRectx,y,width,heightpolyx,y,sides,radius,rotationlinePolyx,y,sides,radius,rotationtrianglex1,y1,x2,y2,x3,y3imagex,y,image,size,rotationdrawflushdisplayFlush the draw buffer todisplayprintmessageAddmessageto the draw bufferprintflushmessageFlush the draw buffer tomessagegetlinkresult,nPut thenth link toresultcontrolcommand,block,arg0...arg2ControlblockCommands:enabledblock,enabledshootblock,x,y,shootshootpblock,unit,shootconfigblock,configurationcolorblock,red,green,blueradarfilter0...filter2,sort,block,order,resultFind a unit nearblockand store it inresultFilters:anyenemyallyplayerattackerflyingbossgroundSort:distancehealthshieldarmormaxHealthsensorresult,block,parameterGetparameterofblockand store it inresultopoperation,result,op0,op1Perform a mathematical operationOperations:Basic: add, sub, mul, div, idiv (integer division), mod, pow, lessThan, lessThanEq, greaterThan, greaterThanEq, max, min, abs, log, log10, floor, ceil, sqrt, sin, cos, tan, asin, acos, atan, equal, notEqualBitwise: shl (shift left), shr (shift right), or, and, xor, notSpecial:strictEqual - doesn't coerce typesland - logic andangle - angle of vectorlen - length of vectornoise - simplex noiserand - random numberwaittimeWaittimesecondslookuptype,result,idLook uptypebyidTypes:blockunititemliquidendEnd the programjumpposition,condition,op0,op1Jump topositionifconditionis metConditions:equalnotEquallessThanlessThanEqgreaterThangreaterThanEqstrictEqualalwaysubindtypeBind next unit of typetypeand store it in@unitucontrolcommand,op0...op4Control the bound unitCommands:idlestopmovex,yapproachx,y,radiusboostenablepathfindtargetx,y,shoottargetpunit,shootitemDropto,amountitemTakefrom,item,amountpayDroppayTaketakeUnitsminex,yflagvaluebuildx,y,block,rotation,configurationgetBlockx,y,type,buildingwithinx,y,radius,resulturadarfilter0...filter2,sort,___,order,resultSame as radar, exceptblockis replaced by@unitulocatetype,arg0...arg2,outx,outy,found,buildingLocate block of typetypeTypes:ore___,___,oreTypebuildinggroup,enemy,___spawn___,___,___damaged___,___,___Building groups:corestoragegeneratorturretfactoryrepairrallybatteryreactormathematical functions (replacement forop):modpowand, or, xor, notmax, minabslog, log10ceil, floorsqrtsin, cos, tanasin, acos, atan