Ghost And Sword

Ghost And Sword

Enter in dark dungeons where the monsters rule are thirsty to kill you, collect items and artifacts, learn skills and fight with giant bossies, buy on earn gold new equipment and trade with lost souls.

Find the game on Gamejolt.

Menu.js All functions and usage tutorial

Here you will learn how to use menu.js with comfort and will can found all functions that you can use in menu.js.

Posted by on


About

Menu.js is javascript file that game run only once when menu is loaded. For example if you will write in menu.js such code:

Print("Hello world");

You in console will see only one line of "Hello world", code will not be repeated forever as in the case of runtime.js.

Usage

To start use function of menu.js, open your mod folder and create file "menu.js" open it with your text editor. Some of functions require true name of your mod and for comfort we recommend you make variable with true name of your mod. True name of your mod is just name of mod's folder, for example if you create in "mods" folder new folder for your mod with name "MyNewMod" true name of mod will be "MyNewMod", for comfort we recommend you on first line of menu.js add variable with true name of mod, this will looks like a that:

var mod = "MyNewMod";

Next below we can start codding, and if any function will require true name of mod you just will can type "mod" for that function. Example:

var mod = "MyNewMod";

SetMenuMusic(mod, "bg.ogg");
SetMenuBackground(mod, "bg_pic.png"); 

Important note:

If you will need use any images you have to create "Sprites" folder in your mod folder and put all images to there.

This everything that you will need to know to use menu.js with comfort.

Functions

  • SetMenuMusic(modname, sound) - Set new music for menu.
  • SetMenuBackground(modname, image) - Set new background image for menu.
  • ChangeButtonX(modname, buttonname, x) - Set new X for button by name.
  • ChangeButtonY(modname, buttonname, y) - Set new Y for button by name.
  • ChangeButtonString(modname, buttonname, newname) - Set new name for button by name.
  • ChangeButtonHUE(modname, buttonname, hue) - Set hue for button by name.
  • ChangeButtonTextColor(modname, buttonname, r,g,b) - Set color for text of button by name.
  • ChangeCheckBoxHUE(modname, checkboxname, hue) - Set hue for checkbox by name.
  • ChangeCheckBoxTextColor(modname, checkboxname, r,g,b) - Set color for text of checkbox by name.
  • ChangeCheckBoxString(modname, checkboxname, newname) - Set new name for checkbox by name.
  • CreateSprite(modname, x, y, width, height, layer, image, name) - Create image on layer. image example "modpic.png".
  • ChangeSprite(modname, x, y, width, height, layer, image, name) - Set new options for sprite by name.
  • DeleteSprite(modname, name) - Delete sprite by name.
  • SmoothDeleteSprite(mod, time, name) - Sprite going to fade out and delete, speed of fade out in seconds.(time)
  • GetSpriteCount(modname, name) - Get count of images by name.
  • CreateText(modname, text, x, y, fontscale, layer, r, g, b, name) - Create text on layer.
  • ChangeText(modname, text, x, y, fontscale, layer, r, g, b, name) - Set new options for text by name.
  • PlaySound(modname, soundname, looping, volume, tag) - Play in game sound, soundname - name of file WITHOUT extension exmaple "Hit", looping - loop or once.
  • PlayModSound(modname, soundname, looping, volume, tag) - Play sound by file, soundname - name of file WITH extension exmaple "ModSound.ogg", looping - loop or once.
  • StopSound(modname, tag) - Stop sound with tag. No difference in game sound or sound from mod, any sounds with this tag, even from c2 side.

Comments

Join the community or sign in with your gaming account to join the conversation: