Skip to content

Instantly share code, notes, and snippets.

View gamerxl's full-sized avatar
🎰
Exploration of the unpredictable

Martin gamerxl

🎰
Exploration of the unpredictable
View GitHub Profile
@gamerxl
gamerxl / BlueprintScannerBlueprintLibrary.cpp
Last active January 17, 2024 10:34
A blueprint library for unreal engine with functions available in blueprints to scan blueprints which implementing nodes or in other words whether it contains logic in its event and function graphs. It can be for instance used in editor widget utilities for utilties to refactor your blueprints e.g. move blueprints to c++.
#include "BlueprintScannerBlueprintLibrary.h"
#if WITH_EDITOR
#include "AssetRegistry/IAssetRegistry.h"
#include "K2Node_FunctionEntry.h"
#include "K2Node_FunctionResult.h"
bool UBlueprintScannerBlueprintLibrary::DoesBlueprintImplementNodes(UBlueprint* Blueprint, const bool bVerbose)
{
@gamerxl
gamerxl / PlayFromBlueprintLibrary.cpp
Last active January 17, 2024 10:32
A blueprint library for unreal engine with functions available in blueprints to start a customized play session in the editor. It can be for instance used in editor widget utilities for quick actions... like starting a standalone session (with client and server) with a different map used for the client but the current map opened in the editor le…
#include "PlayFromBlueprintLibrary.h"
#if WITH_EDITOR
#include "LevelEditor.h"
void UPlayFromBlueprintLibrary::PlayFrom(
FString LevelName,
const EPlayNetMode PlayNetMode,
const int32 NumberOfClients,
@gamerxl
gamerxl / CustomGameInstance.cpp
Last active January 15, 2023 17:29
Re-enable settings ServerMapNameOverride from advanced play settings for dedicated servers in play in editor (PIE) mode from c++ in unreal engine. It reuses the existing editor user setting ServerMapNameOverride from advanced settings for play mode and play settings in editor.
// Add module "UnrealEd" to the PublicDependencyModuleNames in your module build rules.
// Example how to override map for dedicated servers in play in editor (PIE) mode and reuse the mentioned setting.
// Use a custom game instance and override method InitializeForPlayInEditor from UGameInstance.
FGameInstancePIEResult UDefaultGameInstance::InitializeForPlayInEditor(
int32 PIEInstanceIndex,
const FGameInstancePIEParameters& Params)
{
FGameInstancePIEParameters NewParams = Params;
@gamerxl
gamerxl / CustomGameInstance.cpp
Last active January 15, 2023 17:26
Register a custom console command from c++ in unreal engine.
// Example for registration of a custom console command.
// Use a custom game instance and override method Init from UGameInstance.
void UCustomGameInstance::Init()
{
Super::Init();
// Register a custom command to load a map.
if (!IConsoleManager::Get().IsNameRegistered(TEXT("LoadMap")))
{
// Remove existing command.
@gamerxl
gamerxl / CustomGameInstance.cpp
Last active January 15, 2023 17:28
Travel to server default map during game init (GameInstance) from c++ in unreal engine. You can get or set the server default map below "Maps & Modes" in Project Settings.
// Example how to travel to server default map during game init.
// Use a custom game instance and override method Init from UGameInstance.
void UCustomGameInstance::Init()
{
Super::Init();
if (IsDedicatedServerInstance())
{
FString ServerDefaultMap;
GConfig->GetString(
@gamerxl
gamerxl / ue4-call-blueprint.cpp
Last active October 2, 2023 10:51
Example for calling a blueprint event / function from c++ in unreal engine 4.
// This example shows how to call a blueprint event / function from c++ in unreal engine 4.
// In this example we call a blueprint event named "ServerRequestPossess" (see below).
// The current character for instance.
// This character must be implemented in blueprint and provides the blueprint event named "ServerRequestPossess".
ACharacter* CurrentCharacter = <instance of ACharacter>;
// Just an another character. It could by any object.
ACharacter* AnotherCharacter = Cast<class ACharacter>(Hit.Actor);
@gamerxl
gamerxl / compare.js
Created November 20, 2020 14:18
Visual site comparison (Core for visual regression testing with puppeteer and Node.js)
const fs = require('fs');
const { promisify } = require('util');
const puppeteer = require('puppeteer');
const looksSame = require('looks-same');
const mkdir = promisify(fs.mkdir);
const readdir = promisify(fs.readdir);
/**
@gamerxl
gamerxl / ue4-websocket-client.cpp
Last active January 6, 2024 04:17
How to create a websocket client / connection without setup third party libraries in ue4 c++ context.
/**
* Include the PrivateDependencyModuleNames entry below in your project build target configuration:
* // Depend on WebSockets library from UE4 (UE4 WebSockets implementation is built upon the libwebsockets library).
* PrivateDependencyModuleNames.AddRange(new string[] { "WebSockets" });
*/
#include "WebSocketsModule.h"
#include "IWebSocket.h"
{
@gamerxl
gamerxl / ue4-json-parsing.cpp
Last active January 13, 2024 11:49
How to parse a json response (e.g. a json array) in ue4 c++ context.
/**
* Include the PrivateDependencyModuleNames entries below in your project build target configuration:
* PrivateDependencyModuleNames.AddRange(new string[] { "Json", "JsonUtilities" });
*/
#include "Runtime/Online/HTTP/Public/Http.h"
#include "Serialization/JsonSerializer.h"
FHttpResponsePtr Response;
@gamerxl
gamerxl / excel-formula-parser.pegjs
Last active December 30, 2022 12:31
PEG.js based parser for excel formula. It's only a simple prototype for evaluation. Test online at https://pegjs.org/online
// PEG.js based parser for excel formula.
// Executable on https://pegjs.org/online
{
// Implementation of builtin core functionality and some demo stuff.
// TODO: Remove demo stuff.
const builtinFunctions = {
/**
* Returns a number (Demo function).
* TODO: Remove demo function.