User:Gorgon/Sandbox/Sandbox Beta/SbB01: Difference between revisions

From Avlis Wiki
Jump to navigation Jump to search
m (Temp storage of the only copy I could find of a fairly good nwserver/nwnx setup guide, after the lexicon died)
m (Cleared again (Lexicon version returned - hosted via the vault, and this is now in history).)
 
Line 1: Line 1:
<noinclude>{{<!-- sec -->User:Gorgon/Sandbox/Sandbox_Beta | User:Gorgon/Sandbox | 1 }}</noinclude>
<noinclude>{{<!-- sec -->User:Gorgon/Sandbox/Sandbox_Beta | User:Gorgon/Sandbox | 1 }}</noinclude>
G-Note: I'm tossing this here, since it is the only copy I could find of a useful page, after the lexicon site died without any cached version of it. It needs fixing, and I'm not sure where to stick it, but at least it is here. Might be missing a bit at the end, since this was an edit copy,...
==Squatting Monk's Testing Ground==
===Two-Column Article Layout===
<div style="min-width: 1000px;">
<div style="width: 300px; float: right; margin: 0 0 15px 30px; border: solid 1px #cccccc; padding: 0 15px;">
Sidebar content goes over here. Don't use headings in the sidebar; if you do, the wiki will start acting funky. Instead, mark your headings with bold text:
'''Resizing the Sidebar'''
By default, the sidebar is 300px in width. To change this, you need to change both the width property of the sidebar div and the margin-right property of the main column's div. The main column's right margin should always be 50px larger than the
sidebar in order to give adequate room for the sidebar's padding and border.
</div>
<div style="margin-right: 350px;">
This is an example of a two-column layout. You can use it in an article to show a sidebar with extra information. The sidebar is a fixed width (default: 300px), so it will always be the same size even on smaller screens or when the window is resized. The content in the main column, however, is fluid: its text will wrap based on the size of the reader's screen or window. Both the left and right columns are wrapped by a div element. The wrapper has a minumum width (default: 1000px) in order to ensure there's enough room for the content in the main column. This means the minimum amount of room in the main content area is 650px (1000px - 350px margin = 650px). If your content has images with a greater width than this, you may want to modify it. However, doing so may mean readers using small screens have to scroll to the right to read the sidebar. It is therefore recommended that you keep your main content to &lt; 650px in width.
It is okay to have headings in the main column, just not in the sidebar column:
====Standard Two-Column Code====
<pre>
<div style="min-width: 1000px;">
    <div style="width: 300px; float: right; margin: 0 0 15px 30px; border: solid 1px #cccccc; padding: 0 15px;">
        Sidebar content goes here.
    </div>
    <div style="margin-right: 350px;">
        Main content goes here.
        <div style="clear: both;"></div>
    </div>
</div>
</pre>
Note the final bit of code: <nowiki><div style="clear: both;"></div></nowiki> This stops the sidebar from overflowing into the next section if it is longer than the main content area. Only move or remove it if you want following content to start flowing around the right column. As is, text will not wrap around the right column at all (as you can see here). If you ''do'' want text wrapping, see the next section.
<div style="clear: both;"></div>
</div>
</div>
====Wrapping Two-Column Code====
<div style="min-width: 1000px;">
<div style="width: 300px; float: right; margin: 0 0 15px 30px; border: solid 1px #cccccc; padding: 0 15px;">
'''Another Sidebar'''
This is just another sidebar with a little bit of text. Lorem ipsum dolor sit amet.
</div>
A variation on this code will let you wrap content in the main column around the sidebar. This can make the article look nicer if the content on the left is much longer than the sidebar on the right.
<pre>
<div style="min-width: 1000px;">
    <div style="width: 300px; float: right; margin: 0 0 15px 30px; border: solid 1px #cccccc; padding: 0 15px;">
        Sidebar content goes here.
    </div>
    Main content goes here.
    <div style="clear: both;"></div>
</div>
</pre>
In this variation, there is no <nowiki><div></nowiki> element surrounding the main content area. The minimum width concept still applies, but the lack of the additional div means the text will be able to wrap around easily. Note that code blocks may overflow into the sidebar using this method (as seen above). To fix this, add the following style attribute to any <nowiki><nwscript></nowiki> or <nowiki><pre></nowiki> elements that may overflow into the sidebar: <span class="code">style="margin-right: 350px;"</span>, replacing 350 with the width of your sidebar + 50px. Thus, a fixed <nowiki><nwscript></nowiki> element would look like this:
<pre>
<nwscript style="margin-right: 350px;">
void main()
{
    // Do something here...
}
</nwscript>
</pre>
And its output would be...
<nwscript style="margin-right: 350px;">
void main()
{
    // Do something here...
}
</nwscript>
<div style="clear: both;"></div>
</div>
===NWScript Code Formatting===
{| class="wikitable" border="1" width="100%"
|-
! Standard Code Formatting
! NWScript Syntax Highlighting
|-style="vertical-align: top;"
| style="padding-left: 10px; padding-right: 10px;" |
// cutscene_1_1
/* multi
  line
  comment! */
#include "nw_i0_plot"
const int MY_CONST = 0x01;
void main()
{
    object oGuard  = OBJECT_SELF;
    object oPC    = GetLastPerceived();
    object oLeader = GetObjectByTag("leader");
    object oDoor  = GetObjectByTag("guard_door");
    if (GetIsPC(oPC))
    {
        SetCommandable(FALSE, oPC);
        DelayCommand(10.0,    SetCommandable(TRUE, oPC));
        AssignCommand(oPC,    SpeakString("Lead the way!"));
        AssignCommand(oPC,    ActionForceFollowObject(oGuard));
        AssignCommand(oGuard, ActionOpenDoor(oDoor));
        AssignCommand(oGuard, ActionForceMoveToObject(oLeader, FALSE));
        AssignCommand(oPC,    ClearAllActions());
    }
}
| style="padding-left: 10px; padding-right: 10px;" |
<nwscript>
// cutscene_1_1
/* multi
  line
  comment! */
#include "nw_i0_plot"
const int MY_CONST = 0x01;
void main()
{
    object oGuard  = OBJECT_SELF;
    object oPC    = GetLastPerceived();
    object oLeader = GetObjectByTag("leader");
    object oDoor  = GetObjectByTag("guard_door");
    if (GetIsPC(oPC))
    {
        SetCommandable(FALSE, oPC);
        DelayCommand(10.0,    SetCommandable(TRUE, oPC));
        AssignCommand(oPC,    SpeakString("Lead the way!"));
        AssignCommand(oPC,    ActionForceFollowObject(oGuard));
        AssignCommand(oGuard, ActionOpenDoor(oDoor));
        AssignCommand(oGuard, ActionForceMoveToObject(oLeader, FALSE));
        AssignCommand(oPC,    ClearAllActions());
    }
}
</nwscript>
|}
===Sortable Tables===
{| class="wikitable sortable"
|-
! Fruit  !! Price
|-
| Apples  || £0.95
|-
| Oranges || £0.85
|-
| Pears  || £1.15
|}
===Citations===
This is a citation. <ref>Whatsit</ref>
==NWN Dedicated Server Installation Guide==
This will be a tutorial on installing a 1.69 Dedicated Server on Ubuntu 12.04. Yay!
This step-by-step guide to installing the Linux dedicated server is based on [http://nwn.wikia.com/wiki/User:Arek75/Installing_the_Linux_Dedicated_Server Arek75's installation guide] as found on the NWN Wiki.
===Assumptions===
# You have a Linux box with a dedicated internet connection. I use Ubuntu 12.04 Server Edition. If you use a different distro, then I assume...
# You know how to use basic console commands, use the package manager, etc.
# You have physical access to the machine or can remotely access it over SSH (preferred).
# You have root access.
Formatting note: when commands appear on two separate lines, they are two separate commands. Enter them individually.
===Preparation===
Before we install NWN, we want to create an unprivileged user ("nwn") to run the server.
<pre>sudo adduser --system --group --shell /bin/bash nwn</pre>
We'll add ourselves to nwn's group, ensuring that we can add, remove, and modify all files in our NWN installation. Repeat this step for each user you wish to have access to NWN, replacing "squattingmonk" for the username.
<pre>sudo gpasswd -a squattingmonk nwn</pre>
Next, we need to ensure we have access to the program needed to unzip the dedicated server archive. Ensure your install is up-to-date, then install unzip.
<pre>sudo apt-get update && sudo apt-get upgrade
sudo apt-get install unzip</pre>
Next, we make a folder in which to install NWN.
<pre>sudo mkdir /opt/nwn</pre>
Set the folder's owner to our new nwn user. Set the permissions so as to allow nwn and everyone in its group to read, write, and execute files.
<pre>sudo chown nwn:nwn /opt/nwn
sudo chmod ug+rwx /opt/nwn</pre>
Now we need to set the Group ID bit on the install directory in order to make sure any new directories or files we create are associated with the nwn group.
<pre>sudo chmod g+s /opt/nwn</pre>
Next, we need to switch to our nwn user. Note that we never set a password for nwn. Instead, we switch users using sudo:
<pre>sudo -i -u nwn</pre>
Whenever we log in as nwn, we want to set our umask to 002. This ensures that any files we create will be readable, writable, and executable by anyone in our group.
<pre>umask 002</pre>
===Installation===
If you were already logged in as nwn, ensure you are in nwn's home directory:
<pre>cd</pre>
Otherwise, log in now:
<pre>sudo -i -u nwn
umask 002</pre>
Download the NWN Dedicated Server 1.69 archive from the BioWare website:
<pre>wget http://files.bioware.com/neverwinternights/updates/windows/server/NWNDedicatedServer1.69.zip</pre>
Change to your NWN install directory:
<pre>cd /opt/nwn</pre>
Unzip the Dedicated Server archive into this directory:
<pre>unzip ~/NWNDedicatedServer1.69.zip</pre>
Remove all the files specific to other operating systems:
<pre>rm macdedserver169.zip nwserver.exe nwupdate.exe Patchw32.dll readme.macserver.txt</pre>
Next, unpack the Linux dedicated server, overwriting everything:
<pre>tar xzvf linuxdedserver169.tar.gz</pre>
Now we need to ensure that all files in the NWN install have the correct permissions.
<pre>chmod -R ug+w *</pre>
Now, set the execute permission on fixinstall and run it.
<pre>chmod ug+x fixinstall
./fixinstall</pre>
You should see the following output
<blockquote><pre>Checking for required files
PASSED: data directory exists
PASSED: nwm directory exists
PASSED: chitin.key exists
PASSED: dialog.tlk exists
PASSED: nwserver exists
Fixing case
data
................................
dmvault
.
hak
.
localvault
.
override
..........
portraits
.
Checking for problem files
Checking for permissions
PASSED: nwn.ini is writable
PASSED: nwnplayer.ini is writable
PASSED: saves is writable
PASSED: localvault is writable
PASSED: dmvault is writable
PASSED: /opt/nwn is writable
You are ready to run Neverwinter Nights.
</pre></blockquote>
Now we need to create a script to start the nwserver process:
<pre>nano start</pre>
In nano, enter the following:
<pre>#!/bin/bash
umask 002
cd /opt/nwn
./nwserver $@</pre>
Save by pressing CTRL+O and pressing ENTER. Exit by pressing CTRL+X.
Make the startup script executable:
<pre>chmod ug+x start</pre>
Next we need to set the SUID (Set User ID) and SGID (Set Group ID) bits on nwserver. This will make sure nwserver always runs as nwn, rather than the user that started it (which would probably be root if it's run at system startup).
<pre>chmod ug+s nwserver</pre>
Switch back to your regular user:
<pre>exit</pre>
===Hosting Your First Game===
Now it's time to host a test module to ensure everything works correctly.
Ensure you're not logged in as nwn. This is important because we need to make sure the server process will run as nwn even when executed as another user. Next, execute the startup script we made earlier:
<pre>/opt/nwn/start</pre>
If all goes well, you should see the following messages:
<blockquote><pre>Neverwinter Nights Server
Build:8109
Copyright BioWare Corp 1998-2004
Server: Loading...
Server: Running...
</pre></blockquote>
Now we need to load our test module. We'll use Chapter 1 of the OC:
<pre>module Chapter1</pre>
You shold see the following output:
<blockquote><pre>Neverwinter Nights Server
Build:8109
Copyright BioWare Corp 1998-2004
Server: Loading...
Server: Running...
module Chapter1
Server: Loading module "Chapter1"...................................................................................................................
Server: Module loaded
</pre></blockquote>
Now, run NWN on your gaming machine and connect to the server. There are two possibilities here:
# Your server is connected to the same local network as your gaming machine. In this case, just use "Join LAN game" and select your server from the list (it should be the only one there).
# Your server is hosted somewhere else, in which case you need to Direct Connect to it using its IP address.
If you can't connect, make sure that your host has his firewall/router settings set correctly and is forwarding all the correct ports. If you got this far and you're on the same local network as your server, you should have no problems connecting - check your Windows firewall settings, and check the firewall settings on the server box if you've messed with them.
Congratulations! You're hosting your first game. You can play for a few minutes if you want, but I'd recommend shutting down the server and taking a break for a while. To do so, first exit NWN on your gaming machine, then shut down the server by typing the following command at the console:
<pre>exit</pre>
That'll get you back to the command prompt. Now just check one little thing before going on:
<pre>ls -lR /opt/nwn | grep -v nwn\ nwn</pre>
If this returns anything besides blank lines, directory names, and totals, check that you set the suid/sgid bits on nwserver correctly and that nwserver belongs to the nwn user/group. Please re-read all the instructions for installing NWN and NWServer and make sure you followed them correctly.
Note: If you're hosted and couldn't get a special nwn user (and probably had to install to somewhere in your home directory), the above command is meaningless. If this is the case and you were able to get NWServer to run and were able to log in, everything's OK.
===Automatically Starting NWServer On System Boot===
Eh, it's coming.
==NWNX Tutorial==
This will be my attempt at a complete NWNX installation tutorial for Linux (using Ubuntu 14.04). I'm putting it on my user page until it's ready to see the daylight.
This guide assumes you know the basics of the Linux command line interface. It assumes you're using Ubuntu 14.04 (Trusty Tahr) 32-bit. Your mileage may vary if you use other distros. It also assumes you've already installed NWN and have located your install at /opt/nwn.
We'll need a few packages in order to build NWNX:
<pre>sudo apt-get install build-essential cmake gperf zlib1g-dev libmysqlclient18 libmysqlclient-dev</pre>
Now we need to install Git so we can download the necessary files:
<pre>sudo apt-get install git-core</pre>
{{messagebox|image=[[Image:Information icon.png|50px|link=]]|If you followed the Dedicated Server Installation above, you now need to switch to your nwn user:
<pre>sudo -i -u nwn
umask 002</pre>}}
Download the NWNX files to your home directory:
<pre>git clone https://github.com/NWNX/nwnx2-linux.git</pre>
You should now have a folder in your home directory called nwnx2-linux. Navigate to it:
<pre>cd nwnx2-linux</pre>
Now compile!
<pre>./compile.sh</pre>
You may need to install additional libraries for some of the plugins. Check the output of compile.sh and make sure that you have the necessary packages for any of the plugins you need. The library listed may not actually be the package name as it's shipped under Ubuntu, so use some Google-fu if you need.
The installation will take about five minutes, during which you should see lots of compiler messages going by on the screen. When compilation finishes, you should see the following message:
<pre>
NWNX has been compiled successfully.
- Look in the 'compiled' directory for the libraries.
- Copy those that you want to use into your NWN server directory.
IMPORTANT:
- In the case of multiple so files and/or dynamic and static
  variants (for example, the odmbc plugin), choose only one.
  If you're running wserver the same host that you are compiling on,
  the dynamic one is recommended.
  static binaries include the database connector linked in.
- Read & change nwnx2.ini carefully.
- Edit nwnstartup.sh to match your desired server settings.
Have fun!
</pre>
Hooray! Now we need to copy our compiled plugins to our NWN install directory:
<pre>cp compiled/* /opt/nwn</pre>
Now we need to limit ourselves to one of the MySQL plugins. Navigate to the NWN install directory, rename your desired ODBC plugin to <span class="code">nwnx_odbc.so</span> and remove the other one.
<pre>cd /opt/nwn
mv nwnx_odmbc_mysql.so nwnx_odbc.so
rm nwnx_odmbc_*.so</pre>
Now edit your nwnx2.ini file to use the correct login information for your database:
<pre>nano nwnx2.ini</pre>
Note: semicolons are comment characters: make sure to use these to comment out all information about database types you don't wish to use:
<pre>
[ODBC2]
; for sqlite3
;source=SQLITE
;file=./test.sqlite3
; for mysql
source=MYSQL
server=localhost
user=myuser
pass=mypassword
db=mydatabase
; for postgre
;source=PGSQL
;server=localhost
;user=username
;pass=password
;db=database
; Set hookscorco to false if you want to disable hooking of
; StoreCampaignObject and RetrieveCampaignObject entirely
hookscorco=true
</pre>
Now edit your startup script to pass the settings you wish nwserver to use, making sure that any multi-word server or module names are encapsulated in double quotes ("):
<pre>nano nwnstartup.sh</pre>
{{messagebox|image=[[Image:Information icon.png|50px|link=]]|If you followed the Dedicated Server Installation above, insert the following into nwnstartup.sh after the first line:
<pre>umask 002
cd /opt/nwn-test</pre>
You also need to set the UID and GID bits on it:
<pre>chmod ug+s nwnstartup.sh</pre>
Finally, log out of your nwn user:
<pre>exit</pre>}}
When you're done, run the startup script:
<pre>./nwnstartup.sh</pre>
You should see output similar to the following. Check to make sure all plugins initialize correctly:
<pre>NWNX2lib: Init
NWNX2lib: org SetString() at 81f41b4, new SetString() at b77a436d
NWNX2lib: org GetObj() at 81f40bc, new GetObj() at b77a4394
* Parsing configuration...
NWN Extender v2.8-dev
(c) 2004 by the APS/NWNX Linux Conversion Group
(c) 2007-2010 by virusman and Acaos
Based on the Win32 version (c) 2003 by Ingmar Stieger (Papillon)
and Jeroen Broekhuizen
visit us at http://www.avlis.org
* Searching for signatures...
* Loading modules...
SPELLS plugin registered.
STRUCTS plugin registered.
DEFENSES plugin registered.
RESET plugin registered.
PROFILER plugin registered.
DMACTIONS plugin registered.
TWEAKS plugin registered.
FUNCS plugin registered.
RESMAN plugin registered.
VISIBILITY plugin registered.
WEAPONS plugin registered.
FUNCSEXT plugin registered.
TMI plugin registered.
FIXES plugin registered.
SYSTEM plugin registered.
ODBC plugin registered.
CHAT plugin registered.
EVENTS plugin registered.
MNX plugin registered.
EXTEND plugin registered.
AREAS plugin registered.
HASHSET plugin registered.
FUNCTIONS plugin registered.
NAMES plugin registered.
* NWNX2 activated.
Neverwinter Nights Server
Build:8109
Copyright BioWare Corp 1998-2004
Server: Loading...
Server: Running...
Server: Loading module "My Module".....
Server: Module loaded
NWNX!INIT enforcement disabled, using 0x082041ec
INIT(S): reset ignored ret=0x082041ec
INIT(O): valid ret=0x08203e79
</pre>
That's all there is to it, folks!

Latest revision as of 17:44, 28 August 2017

This is a user sandbox of Gorgon. A user sandbox is a subpage of the user's user page. It serves as a testing spot and page development space for the user, and is not an Avlis wiki article.