Below you’ll find a consolidate and structured guide that will help you start building up your own game.
Have fun and be creative!
Have fun and be creative!
local resx = getProperty("display_resolution").width local resy = getProperty("display_resolution").height
return game.CurrentScene == Scenes["101_river"]
if string.match(game.CurrentScene:getName(), "minigame") then ... end
game.CurrentScene.SceneIsMenu
game.CurrentObject:getName() -- For object under cursor game.SavedObject:getName() -- For saved object game.UsedItem:getName() -- For the item at handGet the object name as it appears in game:
game.CurrentObject:getTextStr(VObjectName)) game.SavedObject:getTextStr(VObjectName))Change the name of the object as it appears in game.
game.CurrentScene.Objects["obj"]:setTextStr(VObjectName, "string")Note: if you want to change it in all languages you need to do a for loop through all languages. Check if a string value is not empty (zero length)
string.len(game.CurrentObject:getTextStr(VObjectName)) ~= 0How to clear/unlink an object value? Using the ‘emptyObject’, e.g.:
Characters["Tom"].FollowCharacter = emptyObjectItem at hand The currently used item, either with the ‘Set item’ action part or dragged item:
game.UsedItemHide an Object
Objects["bottle"].Visibility = 0Note: it hides only the image, not the interaction polygon. Get the Sprite position of an object
Objects["name"].Sprite.Sprite -- holds a table with information about the sprite path, position , etcGet the position of the sprite
Objects["name"].Sprite.Sprite:getPosition().y -- for the y-axis positionMove or Check if an object has moved to another position (x,y)
game.CurrentScene.Objects[“key”].ObjectOffset
local obj = game.CurrentScene.Objects.["table"]:duplicate("duplTable") -- duplicate object is created and then stored into a variableYou can delete this new object with:
obj:remove()
game.CurrentScene:to(500, {SceneBrightness = 0}, easeQuintOut) -- easing is optional
function onActionArea(movement, actionArea, character) if movement == "ENTER" then -- do something elseif movement == "LEAVE" then -- do something else end end registerEventHandler("actionArea", "onActionArea")Tip: actionArea == ActionAreas[“example”] (ActionAreas is a table)
game:setValue(VGameScrollSpeed, 300) -- scroll by 300 pixels a second
game.ScrollPosition = {x = 0, y = 0} -- replace the 0's with whatever coordinates you want to snap the camera to.
game:setValue(VGameCursorHorizontalScrollDistance, 50) -- scroll on X axis when cursor is 50 pixels or less from scene edge
game.CursorHorizontalScrollDistance = 50
game:setValue(VGameCursorVerticalScrollDistance, 50) -- scroll on Y axis when cursor is 50 pixels or less from scene edge
game.CursorVerticalScrollDistance = 50
game:setValue(VGameHorizontalScrollDistance, 50) -- scroll on X axis when character is 50 pixels or less from scene edge
game.HorizontalScrollDistance = 50 game:setValue(VGameVerticalScrollDistance, 50) -- scroll on Y axis when character is 50 pixels or less from scene edge
game.HorizontalScrollDistance = 50
startCallBackTween(duration, function(position) --code-- end, easing, loop, pendulum) duration: the time needed to complete 1 loop loop: true = infinite loops, false = 1 loop only pendulum: if loop = true, it will reverse direction each next loop startCallbackTween(30000, function(x) -- starts loop function that lasts for x time local pos = game.CurrentScene.Curves[3]:curveAt(x) -- gets current position of linked curve local direction = game.CurrentScene.Curves[3]:curveDirection(x) - 1.57 -- gets the current direction based on position of curve in the curve local p = graphics.getParticles(game.CurrentScene.Objects.moving) -- gets the particle belonging to the scene object ["moving"] p.emissionDirection = {0.0, direction, 0.0, direction} -- updates the angle of the particle p.center = {pos.x,pos.y} -- updates the position of the particle end, easeLinearIn, true, false)
startCallbackTween(30000, function(x) local pos = game.CurrentScene.Curves[3]:curveAt(x) local direction = game.CurrentScene.Curves[3]:curveDirection(x) - 1.57 ActiveAnimations["animation_name"].AnimationCurrentPosition = {x = pos.x, y = pos.y} end, easeLinearIn, true, false)
startCallbackTween(duration, function(x) if game.CurrentScene == Scenes["Scene that the curves/anims live"] then -- do your stuff else return false end -- it will kill the loop in any other scene (returns false) end, easeLinearIn, true, false)
Characters["Dragon"].Tint = 0xFF0000 -- format used by Visionaire is 0xBGR (BBGGRR) so this will tint the character blueAlternatively you could use shaders to directly apply lighting to your scenes which would affect things in a more dynamic way.
local cisco = game:getLink(VGameCurrentCharacter)Get any character object
local kosmos = getObject("Characters[kosmos]")Now, you can do anything with your character:
local pos = cisco:getPoint(VCharacterPosition)Set the position (x,y) of a character
kosmos:setValue(VCharacterPosition, {x = pos.x, y = pos.y})Get the Direction of a character
local direction = cisco:getInt(VCharacterDirection)Set the Direction of a character
cisco:setValue(VCharacterDirection, 0) Characters["Cisco"].Direction = 0 --shorthand game.CurrentCharacter.Direction = 0 -- for current characterNote: 0 = right, 90 = top, 180 = left, 270 = bottom
Characters["cisco"].CharacterActive = false / trueSet the size of a character
Characters["unicorn"].Size = 50 -- in %Disable character scaling
Characters["franco"].Size = 100 -- First set him to 100% Characters["franco"].CharacterScale = falseDisable Interaction during animation state of the current Character
game.DisableInteractionDuringAnim = eDisableInteractionAlwaysPossible options:
game.CurrentCharacter.AnimStateWhere AnimState can be:
if Characters["grocery-elf"].AnimState == 2 -- (or == eTalkAnim) then -- do something endSo for example, you want to check when a character is talking, possible options:
local SHOW_TEXT = 23 system.registerActionPartHook(SHOW_TEXT, "charTalk") function charTalk(actionPart) if actionPart.Link:getName() == "Tom" then -- do something end endPrevent Character from Moving
game.LeftClickBehaviour = eMouseActionBehaviourDoNotSendCharacter -- Disable left click from updating/setting destination game.LeftClickBehaviour = eMouseActionBehaviourSendCharacterToCursor -- Enable left click update/set destinationCharacter talking and walking
graphics.getCurrentAnimation(char)Empty the inventory of a character
function txtStart(text) -- this function handles actions when the char text starts local owner = text:getLink(VTextOwner) if owner:getId().tableId == eCharacters and owner:getName() == 'cisco' then -- start any actions here end end function txtEnd(text) -- this function handles actions when the char text finishes local owner = text:getLink(VTextOwner) if owner:getId().tableId == eCharacters and owner:getName() == 'cisco' then -- start any actions here end end -- * initialize text event handlers * -- registerEventHandler("textStarted", "txtStart") registerEventHandler("textStopped", "txtEnd")
Characters["townhall-elf-right"].Dialogs.townhall.DialogParts[4].DialogPartAvailable = false -- this will remove the dialog part with ID 4Access Dialog Parts
Characters.Daniel.Dialogs.feueralarm.DialogParts["1.Test"]Generally, if you have unique texts/naming you can search them directly:
DialogParts["1.Test"]
Characters[1].Dialogs[1].DialogParts[1]
Characters[1].Dialogs[1].DialogParts[1].Available == true
if game.CurrentCharacter.CurrentOutfit == Outfits["sad"] then ... end if Characters["potion-man"].CurrentOutfit == Outfits["tied"] then ... endPlay a Character Animation
startAnimation(game.CurrentCharacter.CurrentOutfit.OutfitCharacterAnimations["cisco_kosmos_appear_right"]) startAnimation(Characters["cisco"].Outfits["normal"].OutfitCharacterAnimations["cisco_kosmos_appear_right"])Set Character Speed
game.CurrentCharacter.CurrentOutfit.OutfitCharacterSpeed = 400Random Animations
Characters["cisco"].CurrentOutfit.RandomMinTime = 1500 Characters["cisco"].Outfits["Surprised"].RandomMinTime = 1500 -- choose a specific outfit -- Changing the random times for all character's outfits for i = 1, #Characters["cisco"].Outfits do Characters["cisco"].Outfits[i].RandomMinTime = 1500 Characters["cisco"].Outfits[i].RandomMaxTime = 5000 end