|
| 15 Dec 2014 12:59 AM |
Lockout is a port of Knockout.js to Lua. It provides a Model-View-ViewModel framework for data binding and dependency injection. It allows primarily for values to notify 'Subscribers' when they change. Currently, I've started developing a GUI module that allows for developers to bind GUI elements to values quickly and painlessly.
Here's an example place: http://www.roblox.com/Lockout-Port-place?id=13666092
And this is the code behind it: http://pastebin.com/kd43XK8Z |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 01:01 AM |
| In the near future I plan on adding a way for LockoutUI to automatically detect which elements will be bound, like Knockout and Angular do. As you can see we currently have to manually bind each label to each value. |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 15 Dec 2014 06:25 AM |
hmm... while it seems fine and all, I don't see the invention here. As for the knockoutjs-webpage, all it showed me was a dropdown menu with an event attached to OnChange. Nothing fancy there, besides using the HTML5 data-attributes to make the string actually affect what you do.
Could you try clarify on where this may help developing actual stuff? How it enforces good ways to do certain things, and eventual downsides too? Because just toggling a background-color & textlabel doesn't seem to do much. That can be done in just 3-4 lines.
- As, for the sake of lizardkind. |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 08:12 AM |
On my phone so short answer http://en.m.wikipedia.org/wiki/Model_View_ViewModel |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 08:16 AM |
| I'll come up with some in depth examples for you later when I get home |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 09:21 AM |
Sure you can do the same thing in a few lines but that's not the point. The reason MVVM is important is because it decouples the view from the code behind it. From am organizational standpoint this is great because we don't have to worry at all about keeping track of the ui in our code. Eventually the goal is to completely separate the up from the business logic. This allows for a potentially more dynamic application with overall less work.
Notice how we never explicitly set label.text - only the value behind it |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 10:22 AM |
| I don't need this.. i already script and know the basics i know LUA Codes |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 Dec 2014 01:02 PM |
| Sounds good. Will it work on mobile? |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 01:56 PM |
Don't see why it shouldn't work on mobile.
I finished porting lui to Roblox. Wasn't too difficult but you can get the source here: http://www.roblox.com/Lockout-Testing-place?id=13666092
If you look in the LockoutUI module you'll see some example bindingHandlers. I'm too lazy to write documentation for this but you can check out Knockout's docs. Even though they're in Javascript they're pretty similar: http://knockoutjs.com/documentation/custom-bindings.html
If you have any questions just let me know.
|
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 02:34 PM |
| I do have one issue: loadstring() is disabled in localscripts and it's necessary for how I execute bindings. If anyone knows how to bypass this please let me know (Just using setfenv isn't doing it for some reason) |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 15 Dec 2014 02:40 PM |
| You can't without a server bridge |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 02:42 PM |
| Then it's limited to normal Script objects for now until I figure out a way to do it. |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 02:44 PM |
" loadstring() is disabled in localscripts and it's necessary for how I execute bindings"
"it's necessary for how I execute bindings""
Then you're doing something wrong. |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 02:48 PM |
| I really probably am doing something wrong. |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 05:16 PM |
| If anyone's interested in helping out I'd greatly appreciate it! |
|
|
| Report Abuse |
|
|
BowtieMod
|
  |
| Joined: 01 Apr 2013 |
| Total Posts: 804 |
|
|
| 15 Dec 2014 05:25 PM |
| How is the loadstring() binding implemented? Can we see? |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 05:27 PM |
| The place is free and opensource. Check the link above or my places. |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 05:28 PM |
You'll find it in LockoutUI module. Check the 'Run' function at the top.
Idk. Using setfenv wasn't working for some reason with a raw function but using loadstring worked :( |
|
|
| Report Abuse |
|
|
BowtieMod
|
  |
| Joined: 01 Apr 2013 |
| Total Posts: 804 |
|
|
| 15 Dec 2014 05:39 PM |
Seems like a big hassle.
Form what I understand, run() is getting a binding from an another environment? |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 05:41 PM |
| It's sandboxing it to the main viewModel. Running it in viewModel's envirionment |
|
|
| Report Abuse |
|
|
BowtieMod
|
  |
| Joined: 01 Apr 2013 |
| Total Posts: 804 |
|
|
| 15 Dec 2014 06:03 PM |
| Why not pass the entire binding? o3o |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 06:07 PM |
| Not sure what youre getting at |
|
|
| Report Abuse |
|
|
BowtieMod
|
  |
| Joined: 01 Apr 2013 |
| Total Posts: 804 |
|
|
| 15 Dec 2014 06:21 PM |
Oh, wait Nevermind, didn't know what I was talking about - 3- Yeah, don't see any way around it other than revamping the entire library. |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 18 Dec 2014 03:44 PM |
As for the question regarding mobile compability;
Kawaii, if you're not already, just make it so clicking-handlers will both fire on .MouseButton1Click and .TouchTap. I got a ModuleScript for compability, but haven't published it. Basically it allows for cross-platform: Click/Hover/Drag/ScreenClick.
As for the problem regarding binding;
Why would you expose the person using your port of Lockout.lua for security vulnerabilities? Find alternatives to loadstring! For example, you can use STRING PATTERNS!
Resources: http://wiki.roblox.com/index.php?title=String_patterns http://wiki.roblox.com/index.php/Function_dump/String_manipulation
- As, a framework for UI functionality, if I may say so. Or just utility. |
|
|
| Report Abuse |
|
|