====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
script_snake [2014/10/04 09:28] lm13 [About the script] |
script_snake [2016/06/28 12:31] (current) f43nd1r |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== About the script ====== | ====== About the script ====== | ||
* Purpose : This script is will give you the possibility to play Snake in your launcher | * Purpose : This script is will give you the possibility to play Snake in your launcher | ||
- | * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] | + | * Author : F43nd1r |
* Current Version : 1.0 | * Current Version : 1.0 | ||
* Link : https://plus.google.com/115366157037831519359/posts/66u6CJgMnGC | * Link : https://plus.google.com/115366157037831519359/posts/66u6CJgMnGC | ||
- | * Download avialable! (Check repository) | + | * Download available! (Check repository) |
====== Changelog ====== | ====== Changelog ====== | ||
Line 13: | Line 13: | ||
* Resize it to the wished game size | * Resize it to the wished game size | ||
* set this script to the Touchevent | * set this script to the Touchevent | ||
+ | * Note: For this manual way you won't need the setup script | ||
====== Issues and hints ====== | ====== Issues and hints ====== | ||
- | * None yet | + | * The Setup script won't work outside of the APK |
//please report all bugs in the g+ community// | //please report all bugs in the g+ community// | ||
- | ====== Script ====== | + | ====== Setup Script ====== |
+ | <sxh javascript;>var MY_PKG="net.pierrox.lightning_launcher.llscript.snake"; | ||
+ | // install (or update) a script given its id in the package, and its clear name in the launcher data | ||
+ | function installScript(id,name){ | ||
+ | // load the script (if any) among the existing ones | ||
+ | var script=LL.getScriptByName(name); | ||
+ | |||
+ | var script_text=LL.loadRawResource(MY_PKG,id); | ||
+ | |||
+ | if(script==null){ | ||
+ | // script not found: install it | ||
+ | script=LL.createScript(name,script_text,0); | ||
+ | }else{ | ||
+ | // the script already exists: update its text | ||
+ | script.setText(script_text); | ||
+ | } | ||
+ | |||
+ | return script; | ||
+ | } | ||
+ | |||
+ | if(!confirm("Do you want to load Snake in this Container? It should be empty to avoid problems."))return; | ||
+ | var c=LL.getEvent().getContainer(); | ||
+ | var i=c.getItemByName("SnakeField")||c.addShortcut("SnakeField",new Intent(),0,0); | ||
+ | i.setName("SnakeField"); | ||
+ | var script=installScript("snake","Snake"); | ||
+ | var editor=i.getProperties().edit(); | ||
+ | editor.setEventHandler("i.touch",EventHandler.RUN_SCRIPT,script.getId()); | ||
+ | editor.setBoolean("s.labelVisibility",false); | ||
+ | editor.setBoolean("s.iconVisibility",false); | ||
+ | editor.setBoolean("i.onGrid",false); | ||
+ | editor.commit(); | ||
+ | i.setSize(c.getWidth(),c.getHeight()); | ||
+ | i.setBoxBackground(LL.createImage(MY_PKG,"start_screen"),"nsf"); | ||
+ | </sxh> | ||
+ | |||
+ | ====== Snake Script ====== | ||
<sxh javascript;>//config | <sxh javascript;>//config | ||
var bgColor=0xffffffff;//has to be a solid color; | var bgColor=0xffffffff;//has to be a solid color; |