JScripts - help

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
WonderlandADmana
UOX3 Newbie
Posts: 19
Joined: Sat Sep 10, 2005 2:05 am
Location: UK
Has thanked: 0
Been thanked: 0

JScripts - help

Post by WonderlandADmana »

hi there all where can i get more, JScripts, or scipts. so on, also how do you add monsters, spawners, in the world. thanks :)
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Moved the thread to Scripting Department, as the Script Vault is intended for posting already finished scripts =)

The only way to get more javascripts for UOX3 is currently to create them yourself, or post a request for a script (telling in detail what you want from the script) and hope someone else will do it for you. Familiarizing yourself with UOX3's javascripting engine (by examining the already existing scripts, as well as the JS Documentation) is highly recommended though, as it will allow you to do an extensive amount of custom stuff for your shard should you want to.

For some help on how to do stuff in UOX3, like adding NPCs, check out my UOX3 Guide, which you will also find a link to on the main UOX3.org page.

Also, for spawning, check out the example of a regional spawner in UOX3\DFNDATA\SPAWN\SPAWN.DFN to make your own, or download the premade spawn-files from the sticky thread in the general discussions forum named Community made spawn.dfn to populate the UOX3 World.
-= Ho Eyo He Hum =-
WonderlandADmana
UOX3 Newbie
Posts: 19
Joined: Sat Sep 10, 2005 2:05 am
Location: UK
Has thanked: 0
Been thanked: 0

Post by WonderlandADmana »

thanks for the help.

where do i go to look at UOX3's javascripting engine, and JS Documentation)

:D
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

To look at example scripts, open any .js file from the subfolders of UOX3/JS/ in notepad. You'll find the javascript documentation in your UOX3/Docs/JavaScripting/ folder, just open the index.html file in a browser. You'll also find an online version in the Docs sub-section of UOX3.org.

A basic explanation of what you'll encounter in both the example files and the docs:

Events are basically triggers, which run when a user has performed a certain action or an object (item/character) reaches a certain state. They contain blocks of code enclosed by brackets, and are setup like this:
function event( argument1, argument2, etc.. )
{
}
An example of an event called onUse, which triggers when the item with the script attached to it is used (double-clicked):

Code: Select all

function onUse( pUser, iUsed )
{
    pUser.SysMessage( "Wooh, just doubleclicked an item!" );
    iUsed.color = 0x0480;
    return false;
}
Functions/Methods are used within an event, like the SysMessage() method in the above example, which sends a system message to the object pUser, which in this example is the character who triggered the onUse event. Note that it also changes the color of the iUsed-object, which is the item that was doubleclicked in the first place, before ending the event with a line saying return false;, which when used in the onUse event tells UOX3 to ignore any hardcoded functions that object might have, and instead only execute the javascript attached to it.

You might also want to check out this thread (UOX3 Javascripting Quick-Reference) on the forums here, which explains how to do a few basic things you'll need to script, and instead of using standard Notepad to view/write javascript-files, try one of the programs listed in this thread (Notepad replacements) instead. They will make it easier for you to both read and write javascripts, since they contain "syntax highlighting", which makes it a lot easier to identify problems and see how everything hangs together.
-= Ho Eyo He Hum =-
Post Reply