projectpath = sky.getDir_Project(); -- Returns the root of the project folder
projectOrGame = sky.getDir_ProjectOrGameFolder() -- Returns the project if in editor or the game assets folder if in end game.
assetLibraryOrGame = sky.getDir_AssetLibraryOrGameFolder() -- Returns the AssetLibrary if in editor or the game assets folder if in end game.
isEditor= sky.isEditor() -- Returns whether this script is running in the editor or in an end game. 1= Editor, 0 = end game.
eg.
sky.include("UI_Camera.lua");
sky.include("UI_Player.lua");
function onInit(objID)
Camera_Init('optional' objID); -- only passing the objID or the ui ID if its needed in the include script.
Player_Init('optional' objID)
end
StarFire wrote: Camera_Init('optional' objID); -- only passing the objID or the ui ID if its needed in the include script.
-- Create a global reference in the script for the ID to be stored into.
obj = -1
-- The onInit() objID argument is the sceneEntity ID that the script is attached to in the scene and is passed from c++ to lua
-- if the script is a microscript or external script.
function onInit( objID )
- Assign the passed id to a global id.
obj = objID;
-- then you can use the id in other functions or this function to set entity properties such as position, rotation or scale
-- or use the id to retrieve the tag of a sceneEntity.
entityTag = entity.getTagFromID( obj ); --or objID in this function
x,y,z = vec3(0,1,0);
entity.setPosition( obj, x, y, z) --or objID in this function
end
-- if using the id outside the onInit, then use the global variable: obj
StarFire wrote:Camera_Init('optional' objID); -- only passing the objID or the ui ID if its needed in the include script.
menu[1]["page"] = gui.load("menu_01.rml",0,0)
menu[2]["page"] = gui.load("menu_02.rml",0,0)
menu[3]["page"] = gui.load("menu_03.rml",0,0)
etc...
SolarPortal wrote:ahh i see, skyline has a lot of interactivity between entities which is how you control what happens in games or as StarFire wrote it, so same scripts can be reused on different entities. Then when extended with dynamic properties in scripts, you can have interchangeable values all from a single script.
function Camera_Init(obj, uiID1, uiID2, uiID3, etc....) -- or whatever names or extras you need.
end
function Camera_Init(objID, uiID1, uiID2, uiID3) -- or whatever names or extras you need.
-- If the ids are not passed, then default to -1
uiID1 = uiID1 or -1
uiID2 = uiID2 or -1
uiID3 = uiID3 or -1
-- print to see the results
lprint("uiID1.."..uiID1)
lprint("uiID2.."..uiID2)
lprint("uiID3.."..uiID3)
end
obj = 0;
function onInit(objID)
obj = objID;
Camera_Init(20, 10, 20, 30);
-- prints 10, 20, 30
Camera_Init(20); -- no other arguments passed
-- prints -1, -1, -1
end
I have to take care of my developers, they are the future.
function onKeyDown( key )
pressed_key = key
sky.lprint("You Pressed the "..pressed_key.." Key");
end
if ( pressed_key == "enter???" ) then
... do something
end
"space"
"up"
"down"
"left"
"right"
"shift" -- or "lshift" and "rshift" in end game. All three return the same in the editor.
"control" -- or "lcontrol" and "rcontrol" in end game. All three return the same in the editor.
"esc"
"tab"
"backtab"
"return" -- Both keypad enter and keyboard return ley
"delete"
"back"
"alt"
"*" -- asterisk
"+-" -- plus/minus key
"+" -- plus key
"-" -- minus key
"~" -- atilde
"&"
"%"
"f1"
"f2"
"f3"
"f4"
"f5"
"f6"
"f7"
"f8"
"f9"
"f10"
"f11"
"f12"
"pgup"
"pgdown"
"end"
"home"
"insert"
"_"
"-"
"="
"["
"]"
"{"
"}"
"("
")"
"<"
">"
"@"
";"
":"
"'" -- Apostrophe
"?"
"!"
","
"."
"/"
"|"
"\"
"volumeup"
"volumedown"
"mute"
function onKeyDown( key )
lprint("key: "..key);
end
SolarPortal wrote:Edit: When you want to know what a key is called,
do this in your script:
- Code: Select all
function onKeyDown( key )
lprint("key: "..key);
end
It will print blank if there is no key assigned
StarFire wrote:lol fully featured key commands
Users browsing this forum: No registered users and 1 guest