Theos
Theos
CC#
Created by Theos on 9/2/2024 in #help
Conveyor belts - having a weird problem
No description
2 replies
CC#
Created by Theos on 4/8/2024 in #help
List not returning all matching elements
No description
5 replies
CC#
Created by Theos on 3/28/2024 in #help
✅ Throw error without showing the call stack
No description
3 replies
CC#
Created by Theos on 2/8/2024 in #help
How to find coordinates of a region
No description
7 replies
CC#
Created by Theos on 9/28/2023 in #help
❔ Unity Zenject qustion
Hey, I have a question about Zenject. So I have a class
public class Test
{
public Something _Smth;
public Foo _Foo;
private int Id;

public Test(Somethnig smth, Foo foo)
{
_Smth = smth;
_Foo = foo;
}
}
public class Test
{
public Something _Smth;
public Foo _Foo;
private int Id;

public Test(Somethnig smth, Foo foo)
{
_Smth = smth;
_Foo = foo;
}
}
and I install it like this
Container.RegisterNewInstance<Foo>();
Container.RegisterNewInstance<Something>();
Container.RegisterNewInstance<Foo>();
Container.RegisterNewInstance<Something>();
then I have a list List<Test> Tests What I want to do is somehow make a for-loop that will create and add Test to Tests list. I want to make sure that _Smth and _Foo are installed using Zenject and I want to pass Id when I create this object. From my understanding of zenject if i do var test = new Test() it wont work cuz Something and Foo wont be installed right?
4 replies
CC#
Created by Theos on 9/20/2023 in #help
❔ LLVM problem with creating number
public (Context, LLVMValueRef) VisitNumber(Context ctx, NumberAST expr)
{
LLVMTypeRef typeRef = LLVMTypeRef.Double;
if (expr.Type == typeof(long)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(int)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(short)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(sbyte)) typeRef = LLVMTypeRef.Int8;

else if (expr.Type == typeof(ulong)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(uint)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(ushort)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(byte)) typeRef = LLVMTypeRef.Int8;


return new(ctx, LLVMValueRef.CreateConstIntOfString(typeRef, expr.Value, 10));
}
public (Context, LLVMValueRef) VisitNumber(Context ctx, NumberAST expr)
{
LLVMTypeRef typeRef = LLVMTypeRef.Double;
if (expr.Type == typeof(long)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(int)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(short)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(sbyte)) typeRef = LLVMTypeRef.Int8;

else if (expr.Type == typeof(ulong)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(uint)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(ushort)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(byte)) typeRef = LLVMTypeRef.Int8;


return new(ctx, LLVMValueRef.CreateConstIntOfString(typeRef, expr.Value, 10));
}
var res = VisitNumber(ctx, new("10")).Item2; for some reason the result is {i0 0} Any ideas why?
6 replies
CC#
Created by Theos on 9/18/2023 in #help
❔ LLVM problem with creating number
public (Context, LLVMValueRef) VisitNumber(Context ctx, NumberAST expr)
{
LLVMTypeRef typeRef = LLVMTypeRef.Double;
if (expr.Type == typeof(long)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(int)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(short)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(sbyte)) typeRef = LLVMTypeRef.Int8;

else if (expr.Type == typeof(ulong)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(uint)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(ushort)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(byte)) typeRef = LLVMTypeRef.Int8;


return new(ctx, LLVMValueRef.CreateConstIntOfString(typeRef, expr.Value, 10));
}
public (Context, LLVMValueRef) VisitNumber(Context ctx, NumberAST expr)
{
LLVMTypeRef typeRef = LLVMTypeRef.Double;
if (expr.Type == typeof(long)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(int)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(short)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(sbyte)) typeRef = LLVMTypeRef.Int8;

else if (expr.Type == typeof(ulong)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(uint)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(ushort)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(byte)) typeRef = LLVMTypeRef.Int8;


return new(ctx, LLVMValueRef.CreateConstIntOfString(typeRef, expr.Value, 10));
}
var res = VisitNumber(ctx, new("10")).Item2; for some reason the result is {i0 0} Any ideas why?
3 replies
CC#
Created by Theos on 9/13/2023 in #help
❔ Adjust lists
Hey, so I have
enum AIType { heor, courier, scout }
enum AIType { heor, courier, scout }
class Unit
{
public AIType aiType;
}


class Player
{
List<Unit> units;
}
class Unit
{
public AIType aiType;
}


class Player
{
List<Unit> units;
}
class Settings
{
List<AIType> neededUnits;
}
class Settings
{
List<AIType> neededUnits;
}
10 replies
CC#
Created by Theos on 9/6/2023 in #help
❔ Zenject (Unity) doesn't fire when i do new()
Hey, I have a class which looks like this
public class Something
{
private A _a;

private B _b;

public Something(A a)
{
_a = a;
}

[Inject]
public void Construct(B b)
{
_b = b;
}
public class Something
{
private A _a;

private B _b;

public Something(A a)
{
_a = a;
}

[Inject]
public void Construct(B b)
{
_b = b;
}
public class Test : MonoBehaviour
{

public void Start()
{
var smth = new Something(_a);
}
}
public class Test : MonoBehaviour
{

public void Start()
{
var smth = new Something(_a);
}
}
and _b is null for some reason?
14 replies
CC#
Created by Theos on 8/15/2023 in #help
❔ Unable to load libLLVM
7 replies
CC#
Created by Theos on 8/12/2023 in #help
❔ LLVMSharp create signed and unsigned constants.
Hey, I'm trying to create a constant using this function
LLVMValueRef.CreateConstIntOfString(LLVMTypeRef.Int64, "195894", 10);
LLVMValueRef.CreateConstIntOfString(LLVMTypeRef.Int64, "195894", 10);
How can I specify the LLVMTypeRef to be signed or unsigned? Should I use a different function?
2 replies
CC#
Created by Theos on 8/5/2023 in #help
❔ LLVMSharp weird function
Hey, so I'm trynig to convert my class into a LLVM const. I have a class callled NumberAST:
class NumberAST
{
public NumberType type = NumberType.Int64;
public string value = "100000";
}
class NumberAST
{
public NumberType type = NumberType.Int64;
public string value = "100000";
}
And I was wondering how to convert it into llvm const. I found this thingy LLVMValueRef.CreateConstIntOfString() but I can't find it in the docs so i'm not sure how to use it
20 replies
CC#
Created by Theos on 8/4/2023 in #help
❔ Switch case on Int type
Hey, so I have a class with variable _type and I want to store a variable type in it (long, int, short, ubyte etc etc). Later I want to do a switch on _type something like
switch(_type)
{
case long:
case int:
}
switch(_type)
{
case long:
case int:
}
How can I do this?
41 replies
CC#
Created by Theos on 7/30/2023 in #help
❔ Pass variable type as class parameter
Hey, so basically I have a class
class Number
{
public string Type;
public string Value;

public Number(string type, string value)
{
Type = type;
Value = value;
}
}
class Number
{
public string Type;
public string Value;

public Number(string type, string value)
{
Type = type;
Value = value;
}
}
What I want to do is if I do this for example
var num = new Number("long", "10000");
var num = new Number("long", "10000");
Number.Type shouldnt be string but rather a long; and Number.Value should contain the value
39 replies
CC#
Created by Theos on 7/14/2023 in #help
❔ Split 2D array into 4 chunks.
11 replies
CC#
Created by Theos on 7/14/2023 in #help
❔ Maximum path sum in matrix
Given a M x N grid filled with some values I need to find a path from a target node which maximizes the sum of all values along its path. I can move in any direction. How can I do this? I've found some solutions online but they all go only from the top row to the bottom row when I need to go in all directions from any node.
93 replies
CC#
Created by Theos on 7/13/2023 in #help
Convert 2D grid into graph
Hey, as in the title, I have a simple Vector2Int[,] grid that I want to convert into a graph. How can I do this?
10 replies
CC#
Created by Theos on 4/27/2023 in #help
❔ What technology to use?
Hey, I'm working on a MUD type of game, client side will be developed in Unity and server in .NET (most likely). What technology/frameworks would you recommend me to use to communicate with database - server - client? Also what type of database? Thanks!
14 replies
CC#
Created by Theos on 3/5/2023 in #help
❔ [Unsolved] Call a function whenever I change variable in a struct
Hey, so I have a hue struct public Statistics stats; with many functions and variables in it. I need to do stats = stats whenever I call a function inside stats or just change a variable in it. How can I do this?
28 replies
CC#
Created by Theos on 12/21/2022 in #help
❔ SSH.Net commands not working
using (var client = new SshClient(_IP, _USER, _PASSWORD))
{
client.Connect();

using (var command = client.CreateCommand("ls && history"))
{
Console.Write(command.Execute());
}

client.Disconnect();
}
using (var client = new SshClient(_IP, _USER, _PASSWORD))
{
client.Connect();

using (var command = client.CreateCommand("ls && history"))
{
Console.Write(command.Execute());
}

client.Disconnect();
}
And when I run it it prints "snap". When I connect to my machine with putty and i run history after it I don't see "ls" nor "history".
7 replies