Difference between revisions of "Sliding Interface MKII (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m
m
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{| class="ts" style="width:100%"
 
{| class="ts" style="width:100%"
 
|-
 
|-
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By
+
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By {{lee_PP}}
 
|-
 
|-
 
| Sliding Interface MKII || Definition || AFRLme
 
| Sliding Interface MKII || Definition || AFRLme
 
|}
 
|}
  
This script allows you to slide interfaces in/out, on mouse over/out, or via mouse wheel. ''Visionaire Studio 4.0+ is required to run this script''.
+
This script allows you to slide interfaces in/out on mouse over/out, via mouse wheel or key input. ''Visionaire Studio 4.1+ is required to run this script''.
  
 
== Instructions ==
 
== Instructions ==
 
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
 
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
2. Replace ''inventory'' with whatever name you gave your interface; names are case sensitive.
+
2a. Now you need to create some tables containing various information that will be used to slide the interface(s) in & out; ''the table '''must''' contain the same name as the target interface''.
 
<syntaxhighlight>
 
<syntaxhighlight>
local int = "inventory"
+
local t = {} -- creates an empty table
 +
t["inventory_1"] = {x_in = -350, x_out = -20, y_in = 60, y_out = 60, xo = -50, yo = 0, dir =1, state = false} -- from left
 
</syntaxhighlight>
 
</syntaxhighlight>
3a. Now you need to create a table containing various information that will be used to slide the interface in & out; ''the table '''must''' contain the same name as the interface''.
+
2b. '''x_in''' is the closed coordinate that your interface is positioned on the x-axis & should be the same as the value set in the interface properties tab of the interface you want to slide.<br/>
 +
 
 +
2c. '''x_out''' is the coordinate position the interface will slide to (open) on the x-axis.<br/>
 +
 
 +
2d. '''y_in''' is the closed coordinate that your interface is positioned on the y-axis & should be the same as the value set in the interface properties tab of the interface you want to slide.<br/>
 +
 
 +
2e. '''y_out''' is the coordinate position the interface will slide to (open) on the x-axis.<br/>
 +
 
 +
2f. '''xo''' is the amount of pixels to offset the x-axis by (closed position) while mouse wheel mode is active (hide the interface). Set '''0''' to deactivate offset for x-axis. ''The offset should contain a positive or negative value depending on direction value, else it should contain 0.''<br/>
 +
 
 +
2g. '''yo''' is the amount of pixels to offset the y-axis by (closed position) while mouse wheel mode is active (hide the interface). Set '''0''' to deactivate offset for y-axis. ''The offset should contain a positive or negative value depending on direction value, else it should contain 0.''<br/>
 +
 
 +
2h. '''dir''' is the direction in which the interface should slide from. 1 = from left, 2 = from right, 3 = from top, 4 = from bottom.<br/>
 +
 
 +
2i. '''state''' controls whether interface is sliding out, in, or is open or closed; default value should be <span class="red">false</span>.<br/>
 +
 
 +
3. You need to create a condition somewhere & name it '''mouse_wheel_mode'''. The default value should be set to <span 1class="red">false</span>.<br/>
 +
 
 +
4a. Create a button for your interface, move to bottom of list, set button as '''action area''', set object area around the part that will trigger interface slide out on hover.<br/>
 +
 
 +
4b. Add a mouse enter action (or left click action) to the button mentioned in '''4a'''. Inside of this action you should add an if query...
 +
 
 +
if condition 'mouse_wheel_mode' is false
 +
  execute a script > (see code block below this)
 
<syntaxhighlight>
 
<syntaxhighlight>
local t = {} -- creates an empty table (required once)
+
openInterface("interface_name", 3000, easeQuintInOut) -- open interface_name over 3 seconds with smooth easing (change easing to whatever you prefer)
t["inventory"] = {x = 440, y_in = 670, y_out = 140, offset = 50, state = false} -- table containing x & y positions of the interface, amongst other values...
 
 
</syntaxhighlight>
 
</syntaxhighlight>
3b. '''x''' is the coordinate that your interface is positioned on the x-axis. It should be the same as the value set in the interface properties tab of the interface you want to slide.
+
end if
 +
 
 +
 
 +
4c. Inside of the ''properties'' tab for the interface, add this action part to the '''action on leaving''' action...
 +
 
 +
if condition 'mouse_wheel_mode' is false
 +
  execute a script > (see code block below this)
 
<syntaxhighlight>
 
<syntaxhighlight>
x = 450
+
closeInterface("interface_name", 2000, easeBounceOut) -- close interface_name over 2 seconds with bounce out easing (change easing to whatever you prefer)
 
</syntaxhighlight>
 
</syntaxhighlight>
3c. '''y_in''' is the default y coordinate of your interface (closed) & should be the same value set in the interface properties tab of the interface you want to slide.
+
end if
 +
 
 +
 
 +
5a. Inside of '''game''' > '''mouse properties''': '''mouse wheel up''' you should add these action parts...
 +
 
 +
if condition 'mouse_wheel_mode' is true
 +
  execute a script > (see code block below this)
 
<syntaxhighlight>
 
<syntaxhighlight>
y_in = 670
+
openInterface("interface_name", 3000, easeQuintInOut)
 
</syntaxhighlight>
 
</syntaxhighlight>
3d. '''y_out''' is the target coordinate of your interface (open position).
+
end if
 +
 
 +
 
 +
5b. Inside of '''game''' > '''mouse properties''': '''mouse wheel down''' you should add these action parts...
 +
 
 +
if condition 'mouse_wheel_mode' is true
 +
  execute a script > (see code block below this)
 
<syntaxhighlight>
 
<syntaxhighlight>
y_out = 140
+
closeInterface("interface_name", 2000, easeBounceOut)
 
</syntaxhighlight>
 
</syntaxhighlight>
3e. '''offset''' is the amount of pixels to offset the y value (closed position) while mouse wheel mode is active (hide the interface). Set '''0''' to deactivate offset.
+
end if
<syntaxhighlight>
+
 
offset = 50 -- adds 50 pixels to current y_in value
+
 
</syntaxhighlight>
+
6. To toggle mouse wheel mode, you need to create an object in your options menu or a key input command containing...
3f. '''state''' controls whether interface is sliding out, in, or is open or closed; default value should be <span class="red">false</span>.
+
 
 +
toggle condition 'mouse_wheel_mode'
 +
 
 +
 
 +
7. Inside of your scenes, you should probably add inside of an at begin of scene action, an execute a script action containing...
 
<syntaxhighlight>
 
<syntaxhighlight>
state = false
+
closeInterface("interface_name", 0, easeNoneInOut) -- instantly resets interface_name back to closed position; just in case the interface was open when you changed scenes.
</syntaxhighlight>
 
4. You need to create a condition somewhere & name it '''mouse_wheel_mode'''. The default value should be set to <span class="red">false</span>.<br/>
 
5a. Create a button for your interface, move to bottom of list, set button as '''action area''', set object area around the part that will trigger interface slide out on hover.<br/>
 
6b. Add a mouse enter action (or left click action) to the button mentioned in '''5a'''. Inside of this action you should add an if query...
 
<syntaxhighlight>
 
if condition 'mouse_wheel_mode' is false
 
execute a script > (see code block below this)
 
end if
 
</syntaxhighlight><br/>
 
<syntaxhighlight>
 
openInterface(3000, easeQuintInOut) -- open interface over 3 seconds with smooth easing (change easing to whatever you prefer)
 
</syntaxhighlight>
 
6c. Inside of the ''properties'' tab for the interface, add this action part to the '''action on leaving''' action...
 
<syntaxhighlight>
 
if condition 'mouse_wheel_mode' is false
 
execute a script > (see code block below this)
 
end if
 
</syntaxhighlight><br/>
 
<syntaxhighlight>
 
closeInterface(3000, easeBounceInOut) -- close interface over 3 seconds. Interface bounces at end (change easing to whatever you prefer)
 
</syntaxhighlight>
 
7. To toggle mouse wheel mode, you need to create an object in your options menu or a key input command containing...
 
<syntaxhighlight>
 
toggle condition 'mouse_wheel_mode'
 
</syntaxhighlight>
 
8. Inside of your scenes, you should probably add inside of an at begin of scene action, an execute a script action containing...
 
<syntaxhighlight>
 
closeInterface(0, easeNoneInOut) -- instantly resets interface back to closed position; just in case the interface was open when you changed scenes.
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 71: Line 88:
 
<syntaxhighlight>
 
<syntaxhighlight>
 
--[[
 
--[[
Sliding Interface [v1] (26/09/2014)
+
Sliding Interface MKII [v3] (27/11/2014)
 
Written by AFRLme [Lee Clarke]
 
Written by AFRLme [Lee Clarke]
 
-- + --
 
-- + --
Line 81: Line 98:
 
--]]
 
--]]
  
-- * variables * --
+
-- * local variables * --
local int = "inventory" -- name of interface you want to slide in/out
+
local p, ox, oy -- empty variables
  
-- * tables * --
+
-- * local tables * --
 
local t = {} -- empty table
 
local t = {} -- empty table
t["inventory"] = {x = 440, y_in = 670, y_out = 140, offset = 50, state = false} -- table containing x & y positions of the interface, amongst other values...
+
t["inventory_1"] = {x_in = -350, x_out = -20, y_in = 60, y_out = 60, xo = -50, yo = 0, dir =1, state = false} -- from left
 
+
t["inventory_2"] = {x_in = 1230, x_out =  930, y_in = 60, y_out = 60, xo = 50, yo = 0, dir = 2, state = false} -- from right
 +
t["inventory_3"] = {x_in = 440, x_out = 440, y_in = -550, y_out = -20, xo = 0, yo = -50, dir = 3, state = false} -- from top
 +
t["inventory_4"] = {x_in = 440, x_out = 440, y_in = 670, y_out = 140, xo = 0, yo = 50, dir = 4, state = false} -- from bottom
 +
 
-- * function that slides the interface out * --
 
-- * function that slides the interface out * --
function openInterface(delay, easing, p)
+
function openInterface(int, delay, easing, dir)
 
  if t[int]["state"] ~= true then t[int]["state"] = true -- if not already sliding out then begin sliding out (safety measure to make sure it keeps sliding)
 
  if t[int]["state"] ~= true then t[int]["state"] = true -- if not already sliding out then begin sliding out (safety measure to make sure it keeps sliding)
   p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).y - t[int].y_out) / (t[int].y_in - t[int].y_out) * 100); delay = math.floor((delay / 100) * p)
+
   if t[int].dir == 1 or t[int].dir == 2 then p = math.floor(( Interfaces[int].InterfaceOffset.x - t[int].x_out) / (t[int].x_in - t[int].x_out) * 100); delay = math.floor((delay / 100) * p ) end
   startObjectTween(getObject("Interfaces[" .. int .. "]"), VInterfaceOffset, getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset), {x = t[int].x, y = t[int].y_out}, delay, easing)
+
  if t[int].dir == 3 or t[int].dir == 4 then p = math.floor(( Interfaces[int].InterfaceOffset.y - t[int].y_out) / (t[int].y_in - t[int].y_out) * 100); delay = math.floor((delay / 100) * p ) end
 +
   startObjectTween( Interfaces[int], VInterfaceOffset, Interfaces[int].InterfaceOffset, {x = t[int].x_out, y = t[int].y_out}, delay, easing)
 
  end
 
  end
 
end
 
end
 
+
 
-- * function that slides the interface in * --
 
-- * function that slides the interface in * --
function closeInterface(delay, easing, p, o)
+
function closeInterface(int, delay, easing, dir)
 
   t[int]["state"] = false
 
   t[int]["state"] = false
   if getObject("Conditions[mouse_wheel_mode]"):getBool(VConditionValue) then o = t[int].offset else o = 0 end
+
   if Conditions["mouse_wheel_mode"].ConditionValue then ox = t[int].xo; oy = t[int].yo else ox = 0; oy = 0 end
   p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).y - t[int].y_in) / (t[int].y_out - t[int].y_in) * 100); delay = math.floor((delay / 100) * p)
+
   if t[int].dir == 1 or t[int].dir == 2 then p = math.floor(( Interfaces[int].InterfaceOffset.x - t[int].x_in) / (t[int].x_out - t[int].x_in) * 100); delay = math.floor((delay / 100) * p ) end
   startObjectTween(getObject("Interfaces[" .. int .. "]"), VInterfaceOffset, getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset), {x = t[int].x, y = t[int].y_in + o}, delay, easing)
+
  if t[int].dir == 3 or t[int].dir == 4 then p = math.floor(( Interfaces[int].InterfaceOffset.y - t[int].y_in) / (t[int].y_out - t[int].y_in) * 100); delay = math.floor((delay / 100) * p ) end
 +
   startObjectTween( Interfaces[int], VInterfaceOffset, Interfaces[int].InterfaceOffset, {x = t[int].x_in + ox, y = t[int].y_in + oy}, delay, easing)
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
== Alternative Script ==
 
== Alternative Script ==
This script is more global & allows you to slide out multiple interfaces. Hover/button mode only.
+
This script is the same as the above script but uses the old getObject scripting method. ''At least Visionaire Studio 4.0 is required to run this script because of the startObjectTween function.''
 
 
=== Instructions ===
 
1. To slide out an interface...
 
<syntaxhighlight>
 
openInterface("interface_name", 3000, easeQuintOut)
 
</syntaxhighlight>
 
2. To slide interface back in...
 
<syntaxhighlight>
 
closeInterface("interface_name", 3000, easeQuintOut)
 
</syntaxhighlight>
 
  
=== The Script ===
 
 
<syntaxhighlight>
 
<syntaxhighlight>
 
--[[
 
--[[
Sliding Interface [v2] (02/11/2014)
+
Sliding Interface MKII [v3] (27/11/2014)
 
Written by AFRLme [Lee Clarke]
 
Written by AFRLme [Lee Clarke]
 
-- + --
 
-- + --
Line 131: Line 143:
 
--]]
 
--]]
  
-- * tables * --
+
-- * local variables * --
 +
local p, ox, oy -- empty variables
 +
 
 +
-- * local tables * --
 
local t = {} -- empty table
 
local t = {} -- empty table
t["inventory"] = {x = 440, y_in = 670, y_out = 140, state = false} -- table containing x & y positions of the interface, amongst other values...
+
t["inventory_1"] = {x_in = -350, x_out = -20, y_in = 60, y_out = 60, xo = -50, yo = 0, dir =1, state = false} -- from left
t["another_interface"] = {x = 300, y_in = 500, y_out = 80, state = false}
+
t["inventory_2"] = {x_in = 1230, x_out =  930, y_in = 60, y_out = 60, xo = 50, yo = 0, dir = 2, state = false} -- from right
 
+
t["inventory_3"] = {x_in = 440, x_out = 440, y_in = -550, y_out = -20, xo = 0, yo = -50, dir = 3, state = false} -- from top
 +
t["inventory_4"] = {x_in = 440, x_out = 440, y_in = 670, y_out = 140, xo = 0, yo = 50, dir = 4, state = false} -- from bottom
 +
 
-- * function that slides the interface out * --
 
-- * function that slides the interface out * --
function openInterface(int, delay, easing, p)
+
function openInterface(int, delay, easing, dir)
 
  if t[int]["state"] ~= true then t[int]["state"] = true -- if not already sliding out then begin sliding out (safety measure to make sure it keeps sliding)
 
  if t[int]["state"] ~= true then t[int]["state"] = true -- if not already sliding out then begin sliding out (safety measure to make sure it keeps sliding)
   p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).y - t[int].y_out) / (t[int].y_in - t[int].y_out) * 100); delay = math.floor((delay / 100) * p)
+
   if t[int].dir == 1 or t[int].dir == 2 then p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).x - t[int].x_out) / (t[int].x_in - t[int].x_out) * 100); delay = math.floor((delay / 100) * p) end
   startObjectTween(getObject("Interfaces[" .. int .. "]"), VInterfaceOffset, getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset), {x = t[int].x, y = t[int].y_out}, delay, easing)
+
  if t[int].dir == 3 or t[int].dir == 4 then p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).y - t[int].y_out) / (t[int].y_in - t[int].y_out) * 100); delay = math.floor((delay / 100) * p) end
 +
   startObjectTween(getObject("Interfaces[" .. int .. "]"), VInterfaceOffset, getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset), {x = t[int].x_out, y = t[int].y_out}, delay, easing)
 
  end
 
  end
 
end
 
end
 
+
 
-- * function that slides the interface in * --
 
-- * function that slides the interface in * --
function closeInterface(int, delay, easing, p, o)
+
function closeInterface(int, delay, easing, dir)
 
   t[int]["state"] = false
 
   t[int]["state"] = false
   p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).y - t[int].y_in) / (t[int].y_out - t[int].y_in) * 100); delay = math.floor((delay / 100) * p)
+
   if getObject("Conditions[mouse_wheel_mode]"):getBool(VConditionValue) then ox = t[int].xo; oy = t[int].yo else ox = 0; oy = 0 end
   startObjectTween(getObject("Interfaces[" .. int .. "]"), VInterfaceOffset, getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset), {x = t[int].x, y = t[int].y_in}, delay, easing)
+
  if t[int].dir == 1 or t[int].dir == 2 then p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).x - t[int].x_in) / (t[int].x_out - t[int].x_in) * 100); delay = math.floor((delay / 100) * p) end
 +
  if t[int].dir == 3 or t[int].dir == 4 then p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).y - t[int].y_in) / (t[int].y_out - t[int].y_in) * 100); delay = math.floor((delay / 100) * p) end
 +
   startObjectTween(getObject("Interfaces[" .. int .. "]"), VInterfaceOffset, getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset), {x = t[int].x_in + ox, y = t[int].y_in + oy}, delay, easing)
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
== Resources ==
 
== Resources ==
Line 157: Line 178:
 
! style="text-align:left" | Name !! style="text-align:left" | Description
 
! style="text-align:left" | Name !! style="text-align:left" | Description
 
|-
 
|-
| [http://wiki.visionaire-tracker.net/archive/sliding_interface_vs4.zip sliding_interface_vs4.zip] || A working example of the script in action. ''Visionaire Studio 4.0.1+'' required to run the included .ved file.
+
| [[media:sliding_interface_vs4.zip|sliding_interface_vs4.zip]] || A working example of the script in action. ''Visionaire Studio 4.0.1+'' required to run the included .ved file.
|}
+
|}{{toc}}
{{i18n|Sliding_Interface_MKII_(CMS)}}{{toc}}
 

Latest revision as of 19:17, 6 January 2015

Name Type By

Sliding Interface MKII Definition AFRLme

This script allows you to slide interfaces in/out on mouse over/out, via mouse wheel or key input. Visionaire Studio 4.1+ is required to run this script.

Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. Now you need to create some tables containing various information that will be used to slide the interface(s) in & out; the table must contain the same name as the target interface.

local t = {} -- creates an empty table
t["inventory_1"] = {x_in = -350, x_out = -20, y_in = 60, y_out = 60, xo = -50, yo = 0, dir =1, state = false} -- from left

2b. x_in is the closed coordinate that your interface is positioned on the x-axis & should be the same as the value set in the interface properties tab of the interface you want to slide.

2c. x_out is the coordinate position the interface will slide to (open) on the x-axis.

2d. y_in is the closed coordinate that your interface is positioned on the y-axis & should be the same as the value set in the interface properties tab of the interface you want to slide.

2e. y_out is the coordinate position the interface will slide to (open) on the x-axis.

2f. xo is the amount of pixels to offset the x-axis by (closed position) while mouse wheel mode is active (hide the interface). Set 0 to deactivate offset for x-axis. The offset should contain a positive or negative value depending on direction value, else it should contain 0.

2g. yo is the amount of pixels to offset the y-axis by (closed position) while mouse wheel mode is active (hide the interface). Set 0 to deactivate offset for y-axis. The offset should contain a positive or negative value depending on direction value, else it should contain 0.

2h. dir is the direction in which the interface should slide from. 1 = from left, 2 = from right, 3 = from top, 4 = from bottom.

2i. state controls whether interface is sliding out, in, or is open or closed; default value should be false.

3. You need to create a condition somewhere & name it mouse_wheel_mode. The default value should be set to false.

4a. Create a button for your interface, move to bottom of list, set button as action area, set object area around the part that will trigger interface slide out on hover.

4b. Add a mouse enter action (or left click action) to the button mentioned in 4a. Inside of this action you should add an if query...

if condition 'mouse_wheel_mode' is false
 execute a script > (see code block below this)
openInterface("interface_name", 3000, easeQuintInOut) -- open interface_name over 3 seconds with smooth easing (change easing to whatever you prefer)
end if


4c. Inside of the properties tab for the interface, add this action part to the action on leaving action...

if condition 'mouse_wheel_mode' is false
 execute a script > (see code block below this)
closeInterface("interface_name", 2000, easeBounceOut) -- close interface_name over 2 seconds with bounce out easing (change easing to whatever you prefer)
end if


5a. Inside of game > mouse properties: mouse wheel up you should add these action parts...

if condition 'mouse_wheel_mode' is true
 execute a script > (see code block below this)
openInterface("interface_name", 3000, easeQuintInOut)
end if


5b. Inside of game > mouse properties: mouse wheel down you should add these action parts...

if condition 'mouse_wheel_mode' is true
 execute a script > (see code block below this)
closeInterface("interface_name", 2000, easeBounceOut)
end if


6. To toggle mouse wheel mode, you need to create an object in your options menu or a key input command containing...

toggle condition 'mouse_wheel_mode'


7. Inside of your scenes, you should probably add inside of an at begin of scene action, an execute a script action containing...

closeInterface("interface_name", 0, easeNoneInOut) -- instantly resets interface_name back to closed position; just in case the interface was open when you changed scenes.

Main Script

--[[
Sliding Interface MKII [v3] (27/11/2014)
Written by AFRLme [Lee Clarke]
-- + --
alternatingfrequencies@hotmail.com | skype @ AFRLme
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]

-- * local variables * --
local p, ox, oy -- empty variables

-- * local tables * --
local t = {} -- empty table
t["inventory_1"] = {x_in = -350, x_out = -20, y_in = 60, y_out = 60, xo = -50, yo = 0, dir =1, state = false} -- from left
t["inventory_2"] = {x_in = 1230, x_out =  930, y_in = 60, y_out = 60, xo = 50, yo = 0, dir = 2, state = false} -- from right
t["inventory_3"] = {x_in = 440, x_out = 440, y_in = -550, y_out = -20, xo = 0, yo = -50, dir = 3, state = false} -- from top
t["inventory_4"] = {x_in = 440, x_out = 440, y_in = 670, y_out = 140, xo = 0, yo = 50, dir = 4, state = false} -- from bottom
 
-- * function that slides the interface out * --
function openInterface(int, delay, easing, dir)
 if t[int]["state"] ~= true then t[int]["state"] = true -- if not already sliding out then begin sliding out (safety measure to make sure it keeps sliding)
  if t[int].dir == 1 or t[int].dir == 2 then p = math.floor(( Interfaces[int].InterfaceOffset.x - t[int].x_out) / (t[int].x_in - t[int].x_out) * 100); delay = math.floor((delay / 100) * p ) end
  if t[int].dir == 3 or t[int].dir == 4 then p = math.floor(( Interfaces[int].InterfaceOffset.y - t[int].y_out) / (t[int].y_in - t[int].y_out) * 100); delay = math.floor((delay / 100) * p ) end
  startObjectTween( Interfaces[int], VInterfaceOffset, Interfaces[int].InterfaceOffset, {x = t[int].x_out, y = t[int].y_out}, delay, easing)
 end
end
 
-- * function that slides the interface in * --
function closeInterface(int, delay, easing, dir)
  t[int]["state"] = false
  if Conditions["mouse_wheel_mode"].ConditionValue then ox = t[int].xo; oy = t[int].yo else ox = 0; oy = 0 end
  if t[int].dir == 1 or t[int].dir == 2 then p = math.floor(( Interfaces[int].InterfaceOffset.x - t[int].x_in) / (t[int].x_out - t[int].x_in) * 100); delay = math.floor((delay / 100) * p ) end
  if t[int].dir == 3 or t[int].dir == 4 then p = math.floor(( Interfaces[int].InterfaceOffset.y - t[int].y_in) / (t[int].y_out - t[int].y_in) * 100); delay = math.floor((delay / 100) * p ) end
  startObjectTween( Interfaces[int], VInterfaceOffset, Interfaces[int].InterfaceOffset, {x = t[int].x_in + ox, y = t[int].y_in + oy}, delay, easing)
end


Alternative Script

This script is the same as the above script but uses the old getObject scripting method. At least Visionaire Studio 4.0 is required to run this script because of the startObjectTween function.

--[[
Sliding Interface MKII [v3] (27/11/2014)
Written by AFRLme [Lee Clarke]
-- + --
alternatingfrequencies@hotmail.com | skype @ AFRLme
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]

-- * local variables * --
local p, ox, oy -- empty variables

-- * local tables * --
local t = {} -- empty table
t["inventory_1"] = {x_in = -350, x_out = -20, y_in = 60, y_out = 60, xo = -50, yo = 0, dir =1, state = false} -- from left
t["inventory_2"] = {x_in = 1230, x_out =  930, y_in = 60, y_out = 60, xo = 50, yo = 0, dir = 2, state = false} -- from right
t["inventory_3"] = {x_in = 440, x_out = 440, y_in = -550, y_out = -20, xo = 0, yo = -50, dir = 3, state = false} -- from top
t["inventory_4"] = {x_in = 440, x_out = 440, y_in = 670, y_out = 140, xo = 0, yo = 50, dir = 4, state = false} -- from bottom
 
-- * function that slides the interface out * --
function openInterface(int, delay, easing, dir)
 if t[int]["state"] ~= true then t[int]["state"] = true -- if not already sliding out then begin sliding out (safety measure to make sure it keeps sliding)
  if t[int].dir == 1 or t[int].dir == 2 then p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).x - t[int].x_out) / (t[int].x_in - t[int].x_out) * 100); delay = math.floor((delay / 100) * p) end
  if t[int].dir == 3 or t[int].dir == 4 then p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).y - t[int].y_out) / (t[int].y_in - t[int].y_out) * 100); delay = math.floor((delay / 100) * p) end
  startObjectTween(getObject("Interfaces[" .. int .. "]"), VInterfaceOffset, getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset), {x = t[int].x_out, y = t[int].y_out}, delay, easing)
 end
end
 
-- * function that slides the interface in * --
function closeInterface(int, delay, easing, dir)
  t[int]["state"] = false
  if getObject("Conditions[mouse_wheel_mode]"):getBool(VConditionValue) then ox = t[int].xo; oy = t[int].yo else ox = 0; oy = 0 end
  if t[int].dir == 1 or t[int].dir == 2 then p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).x - t[int].x_in) / (t[int].x_out - t[int].x_in) * 100); delay = math.floor((delay / 100) * p) end
  if t[int].dir == 3 or t[int].dir == 4 then p = math.floor((getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset).y - t[int].y_in) / (t[int].y_out - t[int].y_in) * 100); delay = math.floor((delay / 100) * p) end
  startObjectTween(getObject("Interfaces[" .. int .. "]"), VInterfaceOffset, getObject("Interfaces[" .. int .. "]"):getPoint(VInterfaceOffset), {x = t[int].x_in + ox, y = t[int].y_in + oy}, delay, easing)
end


Resources

Name Description
sliding_interface_vs4.zip A working example of the script in action. Visionaire Studio 4.0.1+ required to run the included .ved file.