Raised This Month: $51 Target: $400
 12% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 02-19-2015 , 02:25   Re: New API and Syntax
Reply With Quote #351

gotcha make sense, I will test this, thanks allot for the information. So if I understand, on the source side the native look like this?

CreateNative("ConVar.BoolValue.set", Native_ConVarBoolValueSet);
Mathias. is offline
BAILOPAN
Join Date: Jan 2004
Old 02-19-2015 , 13:04   Re: New API and Syntax
Reply With Quote #352

Yup, exactly.
__________________
egg
BAILOPAN is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 02-20-2015 , 15:36   Re: New API and Syntax
Reply With Quote #353

Do you plan on adding classes in sm 1.9? I heard that sm 1.8 would have structures, and from methodmaps cross structures is only "short" way to classes.
KissLick is offline
BAILOPAN
Join Date: Jan 2004
Old 02-20-2015 , 15:54   Re: New API and Syntax
Reply With Quote #354

Methodmaps are a long way from classes. Methodmaps are just small syntactic transformations. Classes have a bunch of semantics and need a lot of VM support.

I will probably attempt structs in 1.8, not immediately though, it'll depend on how transitional syntax gets used.
__________________
egg
BAILOPAN is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 02-21-2015 , 02:35   Re: New API and Syntax
Reply With Quote #355

Quote:
Originally Posted by BAILOPAN View Post
I will probably attempt structs in 1.8, not immediately though, it'll depend on how transitional syntax gets used.
FINALLY we can haz structs!

I'll prepare my plugins!
__________________
nergal is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 02-21-2015 , 08:58   Re: New API and Syntax
Reply With Quote #356

Quote:
Originally Posted by BAILOPAN View Post
I will probably attempt structs in 1.8, not immediately though, it'll depend on how transitional syntax gets used.
Structs and classes are the main things why I would use new API :-D
KissLick is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 02-21-2015 , 10:34   Re: New API and Syntax
Reply With Quote #357

Quote:
Originally Posted by KissLick View Post
Structs and classes are the main things why I would use new API :-D
That reminds me to ask, will these be C-style structs or C++-style structs that are similar to classes?
__________________

Last edited by nergal; 02-21-2015 at 10:35.
nergal is offline
ClassicGuzzi
Veteran Member
Join Date: Oct 2013
Location: Argentina
Old 02-21-2015 , 12:18   Re: New API and Syntax
Reply With Quote #358

I don't want to bother anyone but, do you have any idea on when this structs would be done? Because I want to rewrite a really big plugin to add features and update the syntax, but I really need structs (either that or use the old enum or static vectors). Thanks
ClassicGuzzi is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 02-21-2015 , 15:08   Re: New API and Syntax
Reply With Quote #359

Quote:
Originally Posted by ClassicGuzzi View Post
I don't want to bother anyone but, do you have any idea on when this structs would be done? Because I want to rewrite a really big plugin to add features and update the syntax, but I really need structs (either that or use the old enum or static vectors). Thanks
Pretty sure that that is how everyone feels - I would just wait patiently, it is most certainly a "it is done when it is done" sort of thing.
necavi is offline
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 02-22-2015 , 02:29   Re: New API and Syntax
Reply With Quote #360

Quote:
Originally Posted by ClassicGuzzi View Post
I don't want to bother anyone but, do you have any idea on when this structs would be done? Because I want to rewrite a really big plugin to add features and update the syntax, but I really need structs (either that or use the old enum or static vectors). Thanks
Here's an approach you can use to making your code struct-ready.

Code:
// toss this methodmap junk into an include file somewhere

int g_BackingField[ MAXPLAYERS + 1 ];

methodmap MyPlayerStruct
{
	public MyPlayerStruct( int index )
	{
		return view_as<MyPlayerStruct>( index );
	}

	// helper to get client index value
	property int Index
	{
		public get() { return view_as<int>( this ); }
	}


	property int Field
	{
		public get() { return g_BackingField[ this.Index ]; }
		public set( int value ) { g_BackingField[ this.Index ] = value; }
	}
}

// the rest in your plugin's implementation

MyPlayerStruct g_PlayerFields[ MAXPLAYERS + 1 ];

public void OnPluginStart()
{
	// init struct compat gunk
	for ( int i = 1 ; i <= MaxClients ; ++i )
	{
		g_PlayerFields[ i ] = MyPlayerStruct( i );
	}

	// set client index 20's field value to 1
	g_PlayerFields[ 20 ].Field = 1;
}
Wrapping methodmaps around global fields is ugly, but it'll help port your code easily in the future when structs are implemented.
__________________
VoiDeD is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode