Skip to content

Lua / Scripted Entities - #177

Merged
marchc1 merged 18 commits into
mainfrom
lua
Oct 13, 2026
Merged

marchc1 merged 18 commits into
mainfrom
lua

Conversation

@callumok2004

Copy link
Copy Markdown
Member

No description provided.

Comment thread Game.Shared/GarrysMod/WeaponSWEP.cs Resolved
Comment thread Game.Shared/GarrysMod/WeaponSWEP.cs Resolved
Comment thread Game.Shared/GarrysMod/LuaWeapon.cs Resolved
base.Spawn();
bool allowPrecache = IsPrecacheAllowed();
SetAllowPrecache(true);
ScriptedEntity.CallFunction("Initialize", false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesnt look like Initialize gets called in here, or SENT_Point, AI, LuaNextBot; only happens here
You should implement it in the other scripted entities, accurately to gmods binary obv, not sure where it is in other parts

#if CLIENT_DLL
if (ParentEntity.EntIndex() != -1) {
C_BaseEntity.SetAllowPrecache(true);
CallFunction("Initialize", true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually now I see this Initialize, but its only being called clientside, not serverside?


StudioFlags drawnFlags = flags;
if ((flags & StudioFlags.Render) != 0 && weapon != null) {
drawnFlags = flags | StudioFlags.Transparency;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OldAnimationParity isnt used in gmod?

[LuaMethod]
static int Weapon__SetClip1(ILuaInterface lua) {
BaseCombatWeapon weapon = LuaEntity.Get_Weapon(1, false)!;
weapon.SetDropped();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the weapon dropped when setting clips?

public int EntityType;
public BaseEntity? ParentEntity;
[NetworkName("m_strScriptName")]
public InlineArray64<char> ScriptName;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is 64? Have you made sure this wont affect the network CRC? Double check


[NetworkName("m_strHoldType")]
public InlineArray64<char> HoldType;
public InlineArray80<char> HoldType;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is 80? Have you made sure this wont affect the network CRC? Double check


public static void QuaternionMult(in Quaternion p, in Quaternion q, out Quaternion qt) {
qt = Quaternion.Multiply(p, q);
QuaternionAlign(p, q, out Quaternion q2);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably add the original guard against &p == &qt (there's an Unsafe.Function for this that I can't remember right now)

@marchc1
marchc1 merged commit 69451cd into main Oct 13, 2026
5 checks passed
@marchc1

marchc1 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

The other issues I raised seem to be correct after double checking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants