OBLIVION
OBSE Plugin Network Pipe by Demolishun
Oblivion » Modders Resources & Tutorials
Added: 15/04/2013 - 02:12AM
Updated: 19/04/2013 - 07:58AM

6 Endorsements

1.0.2 Latest version

167 Unique D/Ls

208 Total D/Ls

5,779 Total Views

Uploaded by demolishun

Description

Last updated at 7:58, 19 Apr 2013 Uploaded at 2:12, 15 Apr 2013

Notice:
Found major crash bug when editing mods with this. I had some log spam that would occur and cause a crash of the editor. This log spam (_MESSAGE) spam has since been fixed. The newest version fixes this issue.

Network Pipe OBSE
This is a network plugin for the OBSE add on app for the game Oblivion. The plugin provides basic networking support exposed to the Oblivion scripting language. The networking uses UDP and transmits data using JSON. A mod using this plugin has complete control over the data passed in and out of the game and can use any external apps they choose. This basically opens the door for external modding tools and programs designed to extend the capabilities of the game.

Requirements:
  • OBSE 0020
  • Latest Oblivion with patches.


Some potential uses for the plugin:
  • Web enabling the game for blogging/journaling, website connectivity, IRC, etc.
  • External apps adding access to databases and other data repositories. This removes the limit of needing to use save files for some persistent data.
  • Control the game for things like: machinimas, dungeon mastering, messing with friends, etc.
  • Potential of controlling the game externally via a phone or other remote devices.
  • The sky is the limit.


Commands the mod supports:
  • NetworkPipe_StartService: starts the service on a specific port.
  • NetworkPipe_StopService: stops the service.
  • NetworkPipe_Receive: returns an array of pre-converted JSON data to native OBSE types. The "host" and "port" of the connected application is part of the data returned in the array map.
  • NetworkPipe_Send: sends an array data that is converted to a JSON string and sent. Requires: "host" and "port" entries in the map passed to the function. The host is a IPV4 address "ex: 192.168.0.5" and the port is the port number of the connected application. (If the host and port are not present in the array map provided to the _Send command then it will not send. When you specify host 0.0.0.0 with any port number the _Send command will attempt to send to all known clients that have communicated to the program. This will effectively broadcast to all clients that communicated at least once. The port is ignored, but is still required.)
  • NetworkPipe_IsNewGame: this returns if the game is new. Was used for testing internally mostly. I left this in as it might be useful. The problem is if a bunch of mods get created and I take this out, then it will break those mods. So I decided to keep this and just maintain it.
  • NetworkPipe_CreateClient: launches an external app. The first parameter is a string for calling the app: "notepad.exe". The second is a number describing the visibility of the app: 0=hidden, 1=normal, 2=show minimized. The second parameter is optional and defaults to 0 or hidden. It returns the process ID of the app. On close of the game all apps are shutdown as nicely as possible.
  • NetworkPipe_KillClient: shuts down an app that was started using NetworkPipe_CreateClient. The parameter is the PID that was returned when starting the app.
  • NetworkPipe_SetData: will set data (array map) to an internal map. This is basically the functionality of SetModLocalData except in bulk. This data is not persistent after the program ends and it is not saved in save files.
  • NetworkPipe_GetData: will get data in bulk from the internal map. No parameters for this command.


Note:
Forms can be sent in the JSON string by adding "ref:" before the form string (ex: "ref:0018B118"). The form will be checked for validity upon conversion from string to integer. If it fails to convert to a valid form then it is maintained as a string in its entirety. However, if a new game is started or the game is at the Main Menu screen, then forms will NOT be converted. For some reason if you attempt to create a new form during a new game (a game that has not been saved and loaded from file) or while in the Main Menu then Oblivion will crash. So I had to detect these two conditions and prevent forms from being created during these times. Once you load a saved game then forms will be converted just fine.

Extra:
For those inclined to compile the plugin themselves:
Source Code