Codex Gamicus
Explore
Main Page
Discuss
All Pages
Interactive Maps
navigation
Main page
Community portal
Recent changes
Random page
Admin noticeboard
Forums
Company Index
Character Index
Hardware Index
In-Game Index
Ratings Index
Video Game Index
Fandom
Gamepedia support
Report a bad ad
Help Wiki
Contact us
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Fandom's centric source of video game knowledge
42,423
pages
Explore
Main Page
Discuss
All Pages
Interactive Maps
navigation
Main page
Community portal
Recent changes
Random page
Admin noticeboard
Forums
Company Index
Character Index
Hardware Index
In-Game Index
Ratings Index
Video Game Index
Fandom
Gamepedia support
Report a bad ad
Help Wiki
Contact us
Editing
NWScript
(section)
Back to page
Edit
VisualEditor
View history
Talk (0)
Edit Page
NWScript
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Syntax== While based on C, NWScript does not have many functions from the C family, excluding [[Logical connective|logical]] and [[Binary operation|binary]] / [[Ternary operation|ternary]] operators and some [[Function (mathematics)|mathematical functions]]. Function [[source code]] is not accessible to the [[end-user (computer science)|end-user]], but the correct [[Syntax of programming languages|syntax]] is defined in a script file called nwscript.nss. The users can create their own [[Subroutine|functions]], and these can be included in other scripts through the [[Header file|#include]] [[Directive (programming)|directive]], which works slightly differently than in [[C++]]. ===Hello world=== NWScript has no way to directly target the screen for output. Instead, for instance, in-game characters such as the player character can be made to speak the typical "[[Hello world program|Hello world]]" example message. This script puts a "Hello world" message in the player's message log. For it to work, it should be placed in the OnClientEnter [[Event-driven programming|event]] of the [[Adventure (role-playing games)|module's]] [[property (programming)|properties]]. <source lang="csharp"> void main() { SendMessageToPC(GetEnteringObject(), "Hello world"); } </source> The first line is the void main [[Subroutine|function]] which is the function that a NWScript will start at. In the third line, the text ''Hello world'' is sent to the player's in-game message log. ===Data types=== NWScript allows [[Object composition|structs]], but not [[object-oriented programming|objects]]. The following common [[data type]]s are available in NWScript: * [[Integer|integer (int)]] * [[IEEE 754-1985|float]] * [[string (computer science)|string]] * [[Object composition|struct]] NWScript has also introduced some data types for purposes of the Neverwinter Nights game: * object (refers to game objects, such as [[Non-player character|NPCs]] and placeable objects). * location (refers to the in-game location of an object). * talent (refers to [[Magic (paranormal)|spells]] and abilities). * vector (refers to [[Coordinate system|coordinates]] of an object, and is a construct of three floats). * itemproperty (refers to abilities on items such as [[weapon]]s for use in the game).
Summary:
Please note that all contributions to the Codex Gamicus are considered to be released under the CC BY-SA 3.0
Cancel
Editing help
(opens in new window)
Follow on IG
TikTok
Join Fan Lab