[ANY]Native function
Maybe I can ask about the principle of SourcePawn for native function implementation ?
No community like AlliedModders for a coder who likes squirrels is very unfortunately. I really enjoy using squirrel write the script of L4D2, I also use sourcepawn write plugins , although squirrel not as good as sourcepawn in many places, but this does not mean that squirrel is not good, just sometimes not so strong like sourcepawn. But now I have an urgent problem to solve: In L4D2's "include" folder, I find a file named "halflife.inc" and there are some print functions in this file such as: Code:
/** And, I also want to know the underlying implementation principle of this function. I browsed https://wiki.alliedmods.net/Creating_Natives_(SourceMod_Scripting). But, I don't think I really understand it. And I searched all the .inc files to find something about regarding implementation of these two functions but nothing I found. I want to implement them using squirrel, but I don't know how to do it. Functions are first class values like integer or strings and can be stored in table slots, local variables, arrays and passed as function parameters. Functions can be implemented in Squirrel or in a native language with calling conventions compatible with ANSI C. Maybe someone can explain the meaning of the above sentence, it is hard for me to understand it. Although I don't understand this sentence, I think squirrels can also implement native functions, but I can't. Squirrel can display HUD on the screen, so there must be no problem in displaying the text, but now the problem is that displaying HUD is for all players, and I hope to find a way to display different information for each specific survivor. If the community doesn't allow discussion about other languages, the administrator can delete this post directly, but I really hope to find a way to make squirrels work like sourcepawn. |
Re: [ANY]Native function
I'm glossing over a bit to keep things simple and I'm not too familiar with Squirrel, but I'll try to explain it.
Declaring a SourcePawn function as native means the plugin must use externally-provided code that isn't written in SourcePawn itself; it calls into code provided by SourceMod (which can in turn be engine functions, functions provided by extensions, or functions exposed by other plugins, which is what your link refers to -- it allows plugins to provide functions for other plugins to use). Those native functions you posted are implemented in SourceMod itself, calling the engine's functions to display text. Squirrel can also have functions that call into code provided by the Squirrel VM (or what application embeds that VM). The application has to register functions in Squirrel, which can be done by registering functions based on this manual entry. In the case of, say, L4D2, Valve provides additional functions for script authors to interact with the game. Both require machine "native" code (in particular C++ for SourcePawn VM, C for the Squirrel VM) to register new functions into their respective virtual machines (SourcePawn and Squirrel, respectively). You can't expose functions written in Squrrel to SourcePawn, or the other way around. |
Re: [ANY]Native function
Quote:
Thank you very much for your reply. Maybe I haven't fully understood squirrels. Although I have written a lot of scripts and used them to implement many functions of sourcepawn, my usage of squirrels is still superficial. Maybe my ability is not enough. Although I have read squirrels' documents carefully, I still don't understand a lot. For example, you replied about the usage of squirrels' registration functions.I have seen them many times before, I am still full of doubts. I don't understand the implementation of the PrintCenterText on GitHud you replied to. Sorry about that. |
Re: [ANY]Native function
Quote:
|
Re: [ANY]Native function
Quote:
|
Re: [ANY]Native function
Quote:
|
Re: [ANY]Native function
Quote:
This example is from a plugin & include file, but there's no compiled c++ code l4d2stats.inc
Spoiler
l4d2_stats.sp
Spoiler
|
Re: [ANY]Native function
Quote:
Quote:
Quote:
Quote:
I believe the native specifier started from Pawn and predates the ability to register natives through other SourcePawn plugins. SourceMod's native registration means it's closer to an extern, though again, that's a very simplified way of putting it. |
Re: [ANY]Native function
Quote:
Quote:
Maybe I didn't express the meaning clearly before. what I want is to implement the function of sourcepawn through vscript, not vscript through sourcepawn. but, thanks everyone. |
Re: [ANY]Native function
I was just pointing out something, not an answer to your question.
I still don't understand what you're trying to do. Why don't you write in SourcePawn? If you really need to call some VScript functions you can do for example: PHP Code:
|
All times are GMT -4. The time now is 19:35. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.