7 posts
Posted 13 January 2017 - 11:04 PM
Wrote simple dialing program on own pack for private use. Now it's full fledged stargate-management system with some defence features.
–= Features =–
- Dialer - allows dialing stargates without default DHD. When both gate's and computer's chunks are loaded, you can use program even while not there.
- Anti-Dial - stops unknown dials. For example, incoming dials or dials using default DHDs
- Iris Locker - locks iris. It's impossible to open it using GUI or redstone near gate.
- Button Locker - when active, nobody will be able to click buttons in this GUI
- Intruder-Logging - logs all unknown dials into `./intruders` file.
- Address book. Stored in `./book.lua`
- Colored energy meter - first is read when you can't dial any gate, second - when you can't dial selected gate.
- No external screens - only glasses HUD and log in built-in screen.
–= Screenshots =–
–= Download =–
You'll need OpenPeripherals and SGCraft to use this script. Install it on advanced PC.
pastebin get 2YJwXWut main.lua
–= ToDo =–
- Make address-scanner
Edited on 14 January 2017 - 06:23 PM
1220 posts
Location
Earth orbit
Posted 13 January 2017 - 11:36 PM
This looks really nice - great job!
7 posts
Posted 14 January 2017 - 10:37 AM
This looks really nice - great job!
BTW i still have problem - you need to summon any event (click/redstone etc) to rerender data. IDK what to do - on multithreaded systems it's easy to fix, but not here.
7083 posts
Location
Tasmania (AU)
Posted 14 January 2017 - 11:56 AM
Certainly don't do this:
coroutine.yield()
type,_,sender,_,id,_,x,y = os.pullEvent("glasses_component_mouse_down")
os.pullEvent() gets data by calling coroutine.yield() for you.
https://github.com/alekso56/ComputercraftLua/blob/master/bios.lua#L173
1220 posts
Location
Earth orbit
Posted 14 January 2017 - 04:59 PM
On line 49, you are writing nil to .startup since you never define 'startup' as a variable. I believe that instead of 'startup' you want 'd_stup'. Also, just out of curiosity, why is there a coroutine.yield() on line 314?
7 posts
Posted 14 January 2017 - 07:22 PM
On line 49, you are writing nil to .startup since you never define 'startup' as a variable. I believe that instead of 'startup' you want 'd_stup'. Also, just out of curiosity, why is there a coroutine.yield() on line 314?
Thanks, but i already noticed. Also i noticed that lanteacraft's owner removed part of API. So i cannot use some features there.
1220 posts
Location
Earth orbit
Posted 14 January 2017 - 08:32 PM
Yeah, LanteaCraft is really in flux right now - it'll probably be awhile before it's out of development. Based on the bug reports I believe Lochie is aware of the issue and will probably fix it with the next release (just a guess).
Why is that coroutine.yield() on line 314? I'm really curious. The reason I ask is because you aren't using your own coroutine manager so I don't understand what it's there for.
7 posts
Posted 15 January 2017 - 10:24 AM
Why is that coroutine.yield() on line 314? I'm really curious. The reason I ask is because you aren't using your own coroutine manager so I don't understand what it's there for.
Well - it left after my attemps to make both renderer and eventer run simultaneously. But there's no multithreading here :(/>
1220 posts
Location
Earth orbit
Posted 15 January 2017 - 04:14 PM
No multi-threading, true, but you should be able to achieve essentially what you want with the parallel api (and you shouldn't need the coroutine.yield() calls either) - if you rig it properly, it will appear as if they are running at the same time. In fact, it looks like your code should work that way once you remove the coroutine.yield() calls.
EDIT: I looked through your code some more and noticed something you're doing that probably won't work the way you expect. In several places you do this:
if not (someVariable == someValue) and (more stuff here) then
I believe that won't evaluate the way you expect…what you want is this…
if someVariable ~= someValue and (more stuff here) then
Edited on 15 January 2017 - 04:14 PM
7083 posts
Location
Tasmania (AU)
Posted 16 January 2017 - 01:04 AM
The two expressions will resolve the same way (thanks to the brackets), but it's still better to just use the not-equals evaluator.
Also bear in mind that single values resolve as false if they're false / nil, and otherwise resolve as true.
For eg, this sort of thing:
if (not (state == "Offline")) and (not (state == "Idle")) and (dial == false) and (not printed) then
… is more neatly written as:
if state ~= "Offline" and state ~= "Idle" and not dial and not printed then
… or we could invert everything in one go:
if not (state == "Offline" or state == "Idle" or dial or printed) then
Edited on 16 January 2017 - 12:05 AM
7 posts
Posted 17 January 2017 - 01:44 PM
The two expressions will resolve the same way (thanks to the brackets), but it's still better to just use the not-equals evaluator.
Also bear in mind that single values resolve as false if they're false / nil, and otherwise resolve as true.
For eg, this sort of thing:
if (not (state == "Offline")) and (not (state == "Idle")) and (dial == false) and (not printed) then
… is more neatly written as:
if state ~= "Offline" and state ~= "Idle" and not dial and not printed then
… or we could invert everything in one go:
if not (state == "Offline" or state == "Idle" or dial or printed) then
Thanks. I'll use that.