Jump to content

RTFC

MVPs
  • Posts

    1,056
  • Joined

  • Last visited

  • Days Won

    18

Community Answers

  1. RTFC's post in Unreal Editor - automation help was marked as the answer   
    I have trouble understanding why you would wish to automate Unreal Editor; that's like wanting to automate Scite to write an AutoIt script. If you have access to the uncooked, unpackaged project, it makes more sense to directly edit the blueprints (or add your own BPs to run alongside, or edit/add to project source code) to achieve your goals:
    JSON: there are several JSON plugins available out of the (UE) box to interact with JSON data (Edit->Plugins->Search "JSON", and several more on the marketplace start/stop: just run the editor headless from the cmdline with the appropriate settings (e.g., if you launch the editor with -game this would act the same as choosing the standalone launch option in the editor) the output log is already written to file (in <YourProjectFolder>\Saves\Logs), or in the Output Log window, click Settings->Open in External editor. Moreover, automating UE editor seems a terrible idea to me anyway, because its GUI layout/ menu organsiation tends to change (sometimes drastically) with almost every engine update (of which there are several a year).
  2. RTFC's post in DllStructCreate("SHORT") returns a INT was marked as the answer   
    There are two separate issues here, 1. struct element retrieval and 2. Hex representation.
    ad 1. struct dot notation won't tell you this, but if you check the help page for DllStructGetData, you'll see:
    ad 2. Reading up on the Hex function in the Help, you'll find:
  3. RTFC's post in Fastest way to read binary file and compare two large arrays? was marked as the answer   
    @RAMzor I get 15 ms on my crappy old laptop, with a little matrix magic:
    #include "Eigen4AutoIt.au3" $rows = 640 $cols = 512 $colsInt = 512/4 ; has to be divisible by four $elements = $rows * $cols _Eigen_StartUp("int") _Eigen_ResetLogicalBit0only() ; this means use all 32 bits when masking (do not reduce to true/false) ; create work buffers (do this once, prior to any number of file comparisons thereafter) $matA = _Eigen_CreateMatrix($rows, $colsInt) $refA = DllStructCreate("byte[" & $elements & "]", _Eigen_GetPtr($matA, "A", False, False)) $matAx4 = _Eigen_CreateMatrix($rows, $cols) $matB = _Eigen_CreateMatrix($rows, $colsInt) $refB = DllStructCreate("byte[" & $elements & "]", _Eigen_GetPtr($matB, "B", False, False)) $matBx4 = _Eigen_CreateMatrix($rows, $cols) Global $matMask = _Eigen_CreateMatrix_Constant($rows, $cols, 255) _Eigen_CwiseScalarOp_Block_InPlace ($matMask,0,$colsInt,$rows,$colsInt,"shl",8) _Eigen_CwiseScalarOp_Block_InPlace ($matMask,0,$colsInt*2,$rows,$colsInt,"shl",16) _Eigen_CwiseScalarOp_Block_InPlace ($matMask,0,$colsInt*3,$rows,$colsInt,"shl",24) ; file comparison starts here $sPath1 = "TestPtrn_1.raw" $sPath2 = "TestPtrn_2.raw" $hFileOpen = FileOpen($sPath1, BitOR($FO_READ, $FO_BINARY)) DllStructSetData($refA, 1, FileRead($hFileOpen)) FileClose($hFileOpen) $hFileOpen = FileOpen($sPath2, BitOR($FO_READ, $FO_BINARY)) DllStructSetData($refB, 1, FileRead($hFileOpen)) FileClose($hFileOpen) $t1 = TimerInit() ; with expansion _ExpandBytesToInt32($matA, $matAx4) _ExpandBytesToInt32($matB, $matBx4) $t2 = TimerInit() ; without expansion _Eigen_CwiseBinaryOp_InPlace($matAx4, "-", $matBx4) _Eigen_CwiseUnaryOp_InPlace($matAx4, "abs") $iMaxDiff = _Eigen_GetMaxVal($matAx4) ConsoleWrite("MAX DIFF: " & $iMaxDiff & " digital level" & @CRLF) ConsoleWrite("Time with byteToIntExpansion: " & Round(TimerDiff($t1)) & " ms" & @CRLF) ConsoleWrite("Time without byteToIntExpansion: " & Round(TimerDiff($t2)) & " ms" & @CRLF) _Eigen_CloseDown() Func _ExpandBytesToInt32($mat1, $mat4) _Eigen_CreateMatrix_FromA_Tiled ($mat1, 1, 4, $mat4) ; duplicate 4x horizontally _Eigen_CwiseLogicalOp_InPlace($mat4,"and",$matMask) ; remove unwanted bits ; SHR to LSByte _Eigen_CwiseScalarOp_Block_InPlace ($mat4,0,$colsInt,$rows,$colsInt,"shr",8) _Eigen_CwiseScalarOp_Block_InPlace ($mat4,0,$colsInt*2,$rows,$colsInt,"shr",16) _Eigen_CwiseScalarOp_Block_InPlace ($mat4,0,$colsInt*3,$rows,$colsInt,"shr",24) EndFunc Of course, if you can store the binary files as proper int32 in the first place (i.e., 4 times more file space needed) you wouldn't have to do all the masking and shifting here, reducing the processing (at my end) to 3 ms per file comparison. Even faster would be if you could store all binary files in a single dataset which you then block-divide and process.
  4. RTFC's post in AutoIt Function For Cosine Similarity (Vector Embeddings)? was marked as the answer   
    looks okay, but you should really look into E4A's DotProduct (section: Multiplication) and GetNorm (section: Reduction) functions.
  5. RTFC's post in Send macros like @TAB or @CRLF twice or more was marked as the answer   
    #include <String.au3> MsgBox(0,"",_StringRepeat(@TAB,2) & "hello")  
  6. RTFC's post in Splitting a 8-digit hex value into 2 @ 4-digits was marked as the answer   
    Local $iValFull = 0x12345678 Local $iVal1 = BitShift($iValFull,16) Local $iVal2 = BitAND($iValFull,0xffff) ; Display split in both hex and decimal formats to confirm that we end up with numeric values MsgBox(0, "Split Hex", _ "HEX: 0x" & Hex($iValFull) & " --> 0x" & Hex($iVal1, 4) & " and 0x" & Hex($iVal2, 4) & _ @CRLF & @CRLF & _ "DEC: " & $iValFull & " --> " & $iVal1 & " and " & $iVal2)  
  7. RTFC's post in Replace multiple if statements with for statements was marked as the answer   
    #include <MsgBoxConstants.au3> Local $a[]=[33,5,3,4,4,'a4',2,22,66,234,'a4',234,31,34,55,'a4',22,44] Local $c[]=['a4',22,44] Local $lastrow=UBound($a)-1 Local $lastcol=UBound($c)-1 Local $d=$c[0] & "/" For $cc=1 To $lastcol $d&= $c[$cc] & "/" ; this ensures 1/23 and 12/3 are not confused Next Local $e For $rc=0 To $lastrow-$lastcol ; no need to search beyond what would fit $e=$a[$rc] & "/" For $cc=1 To $lastcol $e&=$a[$rc+$cc] & "/" Next ; NB performing a STRING comparison on values (is this intended?) If $d==$e Then MsgBox($MB_SYSTEMMODAL, "", $rc &"th value (base-0)" ) Next A different way:
    #include <Array.au3> #include <MsgBoxConstants.au3> Local $a[]=[33,5,3,4,4,'a4',2,22,66,234,'a4',234,31,34,55,'a4',22,44] Local $c[]=['a4',22,44] Local $aStr=_ArrayToString($a) & "|" Local $cStr=_ArrayToString($c) & "|" Local $found=StringInStr($aStr,$cStr) if $found>0 Then Local $pos=0 For $b=1 To $found-1 $pos+=(StringMid($aStr,$b,1)="|") Next MsgBox($MB_SYSTEMMODAL, "", $pos &"th value (base-0)" ) EndIf Incorporating Nine's suggestion in the next post, this is shorter still (but does not contain a For-loop as requested by OP):
    #include <Array.au3> #include <MsgBoxConstants.au3> Local $a[]=[33,5,3,4,4,'a4',2,22,66,234,'a4',234,31,34,55,'a4',22,44] Local $c[]=['a4',22,44] Local $aStr=_ArrayToString($a) & "|" Local $found=StringInStr($aStr,_ArrayToString($c) & "|") If $found>0 Then StringReplace(StringLeft($aStr,$found-1),"|","|") MsgBox($MB_SYSTEMMODAL, "", (($found>0)?(@extended & "th value (base-0)"):("not found"))) EDIT: There was an edge-case that wasn't properly handled in all my examples (final substring part was unterminated so could trigger a false-positive), now fixed.
  8. RTFC's post in Changing languages (Visual C) was marked as the answer   
    Hi McLEMUR,
    A decent starting point with lots of simple examples is http://www.cplusplus.com/doc/tutorial/, or try https://www.learncpp.com/
    Two other reference sites I've found useful in the past are http://en.cppreference.com/w/cpp and http://www.java2s.com/Tutorial/Cpp/CatalogCpp.htm
    But coming from AutoIt, diving into C++ will be an uphill struggle (if you'll forgive me the metaphor mixing ). There is a lot of basic functionality that you'd expect any sophisticated language to have (*cough* garbage collection *cough*), that you'll either have to add yourself or find a good library for. An immense help for me has been the (free!) Boost libraries, see http://www.boost.org/, (and tutorials I found here, although I didn't use these much myself). Boost has really saved me acres of time, and it's quite intuitive to use.
    You'll need plenty of perseverance though, and think of your C++ compiler as simultaneously retarded and autistic. Every typo  will likely crash your code, and the error messages you get may have nothing whatsoever to do with what actually went wrong, or be so generic that they don't help you.
    Of course, there's always http://stackoverflow.com/ if when you get stuck, but in my experience, some C++ forum members take on some of the same attributes as C++ compilers, i.e., being unforgiving towards beginners. Just google "I hate C++" to get an idea of what people run up against in your position. On second thought, maybe you'd better not, to remain motivated.
    Personally, I use C++ only for tasks that require speed and a reasonably high-level of complexity (CUDA interfacing in parallel computing, matrix computing with Eigen), but user-friendly it ain't, nor will it ever be. Can't really tell you much about the transition from AutoIt, because I started from the other end (Assembly), so it was more a question of mapping the concepts used there onto the C++ framework. I fear that coming from AutoIt, it'll be much harder.
    As far as compilers are concerned, CodeBlocks is much easier to start with, but at some point you'll run into situations where you'll need the extra control of literally hundreds of compiler/linker settings that MSVC offers. So you either start easy and have the extra pain of switching later, or bite the bullet now (although these newer versions of MSVC are more user-friendly than the earlier stuff).
    Hope it works out for you (but please do not PM me if you get stuck, okay? )
×
×
  • Create New...