MegaKerma / Silent Walk FPS Creator / Silent Walk: RENAISSANCE

Tools for creating 3D games
It is currently Mon Sep 28, 2020 10:26 am

All times are UTC + 2 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Using scripts
PostPosted: Mon Jan 30, 2012 11:29 pm 
Offline
Site Owner
Site Owner
User avatar

Joined: Thu Aug 17, 2006 7:27 pm
Posts: 966
Location: Budapest, Hungary
USING SCRIPTS

Silent Walk Renaissance is able to handle game scripts when different game events occured. With game scripts you can add your own logic to the game, you can modify or create new game objects in realtime. Every game object has its own name. When you create your game with SWR you can name all of your items. It is very important, that every single item has to have its own and unique name, as the system is recognizing the object by the name. If you give the same name for different objects, the system can't decide which object you want to control.

You don't have name all of the game object, only the ones you want to modify or control. By default the system gives a unique name to each object, but these are autogenerated names, so sometimes you might want to name id differently by adding a human readable name.

Once you named the objects you can start adding you scripts to the different events. If you popup the object menu (right click in the editor) you find different menu options handling scripts.
Not every object handle script, so walls, floors, ceilings don't have their own scripting features, but enemies, monsters, general objects have.

If you find scripting options in the menu, you can also notice there are different events and different types of script.

SCRIPT TYPES
There are two types of script: STRING and FILE

STRING scripts
They are short commands, they are useful when you want to execute only a small command, like playing a sound.
If you edit a string script, you simply enter the command in the input box (see later).

FILE scripts
They are longer, and they can contain a complex command set with lots of commands, programming conditions, loops etc.
If you edit the file script, first you enter a filename which holds the full complex script (see later) then edit the script in the built-in script editor.

LEVEL script
Level START script: Edit this script if you want to execute a complex command set when the level starts
Level END script: Edit this script if you want to execute a complex command set when the level ends

ENEMY script
There are two events that you can extend with scripts: creation and destroy.

When the enemy is created in the level, the system can execute the creation script.
1. Select the "File script to execute when created" option if you want to edit a complex script. First enter the filename in the input box, then you can edit the complex script in the built-in script editor.
2. Select the "String script to execute when created" option if you want to edit a simple script. Enter the command in the input box.

When the enemy is dead, the system can execute the destroy script.
1. Select the "File script to execute when destroyed" option if you want to edit a complex script. First enter the filename in the input box, then you can edit the complex script in the built-in script editor.
2. Select the "String script to execute when destroyed" option if you want to edit a simple script. Enter the command in the input box.

GENERAL OBJECT script
There are four events that you can extend with scripts: creation, destroy, collect, and use.

When the object is created in the level, the system can execute the creation script.
1. Select the "File script to execute when created" option if you want to edit a complex script. First enter the filename in the input box, then you can edit the complex script in the built-in script editor.
2. Select the "String script to execute when created" option if you want to edit a simple script. Enter the command in the input box.

When the object is destroyed, the system can execute the destroy script.
1. Select the "File script to execute when destroyed" option if you want to edit a complex script. First enter the filename in the input box, then you can edit the complex script in the built-in script editor.
2. Select the "String script to execute when destroyed" option if you want to edit a simple script. Enter the command in the input box.

When the object is collected by the player (set as COLLECTABLE), the system can execute the collect script.
1. Select the "File script to execute when collected" option if you want to edit a complex script. First enter the filename in the input box, then you can edit the complex script in the built-in script editor.
2. Select the "String script to execute when collected" option if you want to edit a simple script. Enter the command in the input box.

When the player is stading close to the object and press the USE key, the system can execute the use script.
1. Select the "File script to execute when pressed the USE key" option if you want to edit a complex script. First enter the filename in the input box, then you can edit the complex script in the built-in script editor.
2. Select the "String script to execute when pressed the USE key" option if you want to edit a simple script. Enter the command in the input box.

...to be continued...

SCRIPT FUNCTIONS


- A -

add_enemy_creator("enemyname", "destinationname", delay, maxnum);
Creates a new enemy in every X seconds. Maxnum is the maximum number
of enemies at a time.
example: http://www.silentworks.hu/download/enem ... xample.zip

add_hud_image("imagename", x, y);
Adds an image to the player HUD.
example: http://www.silentworks.hu/download/hudimage_example.zip

add_hud_text("textname", "text", x, y, "font", fontsize, bold, italic, [delay to remove]);
Adds text to the player HUD. The delay parameter optional.

add_keyboard_script(keycode, "scriptname");
Assigns a keyboard check to a registered script, so every time this
key is pressed the system executes the script.

add_lmb_script("scriptname");
Adds a left mouse button press listener to the system.
example: http://www.silentworks.hu/download/titl ... xample.zip

add_rmb_script("scriptname");
Adds a right mouse button press listener to the system.

add_screen_image("imagename", x, y);
Adds a new image on the actual 2D screen (e.g. title, gameover, completed).
example: http://www.silentworks.hu/download/titl ... xample.zip

ammo("weaponame", bullets_num);
Adds ammo to the indicated weapon.

- B -

- C -

id = create_particle_system("thisname", "texturename", x, y, z);
Creates a new 3D particle system as X,Y,Z coordinates and returns the
created system ID.
example: http://www.silentworks.hu/download/particle_example.zip

- D -

destroy("objectname");
Destroys the specified object.

destroy_all_enemy();
Destroys all enemies

destroy_enemy("enemyname");
Destroys the specified enemy.

disable_completed_buttons();
Disables the default keyboard and mouse button press in the completed screen.

disable_gameover_buttons();
Disables the default keyboard and mouse button press in the gameover screen.

disable_title_buttons();
Disables the default keyboard and mouse button press in the title screen.
example: http://www.silentworks.hu/download/titl ... xample.zip

- E -

enable_completed_buttons();
Enables the default keyboard and mouse button press in the completed screen.

enable_gameover_buttons();
Enables the default keyboard and mouse button press in the gameover screen.

enable_title_buttons();
Enables the default keyboard and mouse button press in the title screen.

- F -

id = find("objectname");
Returns the ID of the specified object.

id = find_sound("soundname");
Finds the specified sound.

- G -

get_cb_dimension("objectname");
Sets three global variables width_last, length_last, height_last with the dimension of the collision box of the specified object.

get_cb_height("objectname");
Returns the height of the collision box of the specified object.

get_cb_length("objectname");
Returns the length of the collision box of the specified object.

get_cb_width("objectname");
Returns the width of the collision box of the specified object.

get_top("objectname");
Returns the absolute top value of the specified object (z + height).

get_x("objectname");
Returns the X position of the specified object.

get_y("objectname");
Returns the Y position of the specified object.

get_z("objectname");
Returns the Z position of the specified object.

get_xyz("objectname");
Sets three global variables x_last, y_last, z_last with the position of the specified object.

grab_light("lightname");
Player grabs the indicated light as a torch light.

grab_weapon("weaponname");
Player collects this weapon immediately.

- H -

health(amount);
Adds medkit amount (health) to the player (Relative to the actual amount).

hide_mouse();
Hides the system mouse pointer.
example: http://www.silentworks.hu/download/titl ... xample.zip

- I -

- J -

- K -

- L -

load_game();
Loads and starts the saved level
example: http://www.silentworks.hu/download/loadsave_example.zip

lock_all_door();
Locks all doors.

lock_door("doorname");
Locks the specified door.

loop_sound("soundname");
Loops the specified sound.

- M -

mouse_in(x1, y1, x2, y2);
Returns true if the mouse is in the specified x1,y1 - x2, y2 rectangle
region on the screen.
example: http://www.silentworks.hu/download/titl ... xample.zip

move_elevator("cubename", destinationheight, speed);
Moves the specified cube to the destination height with the specified speed.
example: http://www.silentworks.hu/download/elevator_example.zip

move_object_by("objectname", x_amount, y_amount, z_amount, steps);
Moves the specified object by adding X,Y,Z amounts to the actual
position in steps steps

move_object_to("objectname", new_x, new_y, new_z, steps);
Moves the specified object to the new XYZ position in steps steps.
example: http://www.silentworks.hu/download/door_example.zip

- N -

- O -

- P -

play_sound("soundname");
Plays the specified sound.
example: http://www.silentworks.hu/download/door_example.zip

- R -

register_script("filename", "scriptname");
Loads the "filename" script and stores it in the system. The name of
the registered script is the second parameter.
example: http://www.silentworks.hu/download/titl ... xample.zip

release_light("lightname");
Players drops the indicated light.

remove_all_screen_image();
Removes all images from the actual 2D screen (e.g. title, gameover, completed).

remove_hud_image("imagename");
Removes a previously added image from the player HUD.

remove_hud_text("textname");
Removes a previously added text from the player HUD.

remove_keyboard_script(keycode);
Removes the keyboard check.

remove_lmb_script();
Removes the left mouse button press listener from the system.
example: http://www.silentworks.hu/download/titl ... xample.zip

remove_rmb_script();
Removes the right mouse button press listener from the system.

remove_screen_image("imagename");
Removes the image from the actual 2D screen (e.g. title, gameover, completed).
example: http://www.silentworks.hu/download/titl ... xample.zip

restart_game();
Restarts the game.

rotate_object_by("objectname", xrot_amount, yrot_amount, zrot_amount, steps);
Rotates the specified object by adding X,Y,Z amounts to the actual
rotation values in steps steps.

rotate_object_to("objectname", new_xrot, new_yrot, new_zrot, steps);
Rotates the specified object to the new XYZ rotation in steps steps.
example: http://www.silentworks.hu/download/door_example.zip

run_levels();
Start the actual gameplay.
example: http://www.silentworks.hu/download/titl ... xample.zip

- S -

save_game();
Saves the current level.
example: http://www.silentworks.hu/download/loadsave_example.zip

set_ambient_light(R,G,B);
Sets the color of the ambient light.

set_gravity(gravity);
Sets the global game gravity.

set_light("lightname", status);
Sets the status (0/1) of the specified light.

set_light_color("lightname", R, G, B);
Sets the color of the specified light.
example: http://www.silentworks.hu/download/light_example.zip

set_light_range("lightname", range);
Sets the range of the specified light.
example: http://www.silentworks.hu/download/light_example.zip

set_player_height(height);
Sets the height of the player.

set_player_invisible();
Player becomes invisible, so enemies and monsters can't see and attack
him / her.

set_player_jump(value);
Sets the jump power of the player.

set_player_run_multiplyer(value);
Sets the sprint speed multiplyer of the player.

set_player_speed(speed);
Sets the walking speed of the player.

set_player_step_shake(value);
Value of camera/player shake effect (0: none).

set_player_visible();
Player becomes visible, so enemies and monsters can see and attack him.

set_security_camera(x,y,z,"target",seconds,"texture");
Displays a camera projection from XYZ to the target object for N seconds. The texture parameter is used for the camera hud effect (interlace, colorize, etc).
example: http://www.silentworks.hu/download/secu ... xample.zip

set_cb_height("objectname", height);
Sets the height of the collision box of the specified object.

set_cb_length("objectname", length);
Sets the length of the collision box of the specified object.

set_cb_width("objectname", width);
Sets the width of the collision box of the specified object.

set_cb_dimensions("objectname", width, length, height);
Sets the dimensions of the collision box of the specified object.

set_texture("objectname", "texturename");
Sets the texture of the specified object.

set_x("objectname", x);
Sets the X position of the specified object.

set_y("objectname", y);
Sets the Y position of the specified object.

set_z("objectname", z);
Sets the Z position of the specified object.

set_xyz("objectname", x, y, z);
Sets the XYZ coordinates of the specified object.

show_mouse();
Displays the system mouse pointer.
example: http://www.silentworks.hu/download/titl ... xample.zip

stop_sound("soundname");
Stops the specified sound.

- T -

- U -

unlock_all_door();
Unlocks all doors.

unlock_door("doorname");
Unlocks the specified door

- V -

- W -

- X -

- Y -

- Z -


Top
 Profile  
 
 Post subject: Re: Using scripts
PostPosted: Mon Sep 02, 2013 7:04 am 
Offline
Registered member
Registered member

Joined: Tue Nov 20, 2012 2:21 am
Posts: 4
Hi Zoltan

load_game();
Loads and starts the saved level
example: http://www.silentworks.hu/download/loadsave_example.zip

I can't play this example. Just showing black loading screen. I need this script. Can you help me? thank you.


Top
 Profile  
 
 Post subject: Re: Using scripts
PostPosted: Sun Nov 24, 2013 12:01 pm 
Offline
Registered member
Registered member
User avatar

Joined: Wed Dec 14, 2011 1:40 am
Posts: 28
Location: Australia WA
aksinergi wrote:
Hi Zoltan

load_game();
Loads and starts the saved level
example: http://www.silentworks.hu/download/loadsave_example.zip

I can't play this example. Just showing black loading screen. I need this script. Can you help me? thank you.


Hello aksinergi.

I haven't tried the example, but using that script should be easy.

Just copy load_game();

And add it into the script area of the game you want.

For example.

In the starting room of your game, you could have a box or lever. That when used loads the game that was saved.

Just make an object. Edit the properties. Goto the bit where it says [File Script On Use]
Then in that area paste in load_game();.

It should work... if im not mistaken.

Tell me how it went and i might be able to help you further.


Top
 Profile  
 
 Post subject: Re: Using scripts
PostPosted: Tue Oct 23, 2018 3:51 pm 
Offline
Registered member
Registered member

Joined: Mon Oct 01, 2018 8:53 pm
Posts: 1
thanks this was very helpful :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group