Jump to content




Top level multishell/bios override


  • You cannot reply to this topic
6 replies to this topic

#1 Hiran

  • Members
  • 44 posts

Posted 03 October 2014 - 12:13 PM

When I started playing with PDA I've got irritated by one thing - 1 pda per one active program. If i want to have Door lock, turtle control and my base control thats already 3 devices in my inventory, and for me its way too much. Why 3 devices? Events are (almost) shell specific
Spoiler
So if you try run 2 programs with parallel, and both are using mouse events things will get messy. But if u run them with multishell everything should work almost ok, but if they use some custom events you will still have mess.
After digging through the code ive found in bios.lua (lines 555-570) piece of code that's responsible for my suffering.
-- Run the shell
local ok, err = pcall( function()
    parallel.waitForAny(
	    function()
		    if term.isColour() then
			    os.run( {}, "rom/programs/advanced/multishell" )
		    else
			    os.run( {}, "rom/programs/shell" )
		    end
		    os.run( {}, "rom/programs/shutdown" )
	    end,
	    function()
		    rednet.run()
	    end )
end )
And the main question: how to override it? I dont want to call 'multishell' from "rom/programs/advanced/" but my own version. Is it possible to shut everything down, and then start my own environment?

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 03 October 2014 - 01:46 PM

Indeed it is very possible to do it

Link 1
Link 2
Link 3

I cannot confirm that last link, but the first two work nicely, I have used them before. There is an extensive discussion in the first link as to why (or why not) you should use this approach.

Edited by theoriginalbit, 03 October 2014 - 04:09 PM.


#3 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 03 October 2014 - 01:50 PM

I don't understand one thing: what's wrong with multishell exactly and at what circumstances it fails to you?

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 03 October 2014 - 02:39 PM

When running multiple scripts via multishell, you've got one script visible in the foreground, and all the others invisible in the background. All of these scripts run at the same time.

Because you would only "expect" the foreground script to respond to user input, some events are not passed to background scripts. Examples include key, char, mouse_click etc events.

It sounds like Hiran wants to set up something similar, but with a different selection of events being filtered. Personally, I'd aim to code the scripts such that they can't interfere with each other, but I realise this isn't always viable/worthwhile.

#5 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 03 October 2014 - 04:05 PM

From my understanding, Hiran has 2 or more programs firing the same custom event, thus interfering with each other. If that is the case, I would change those events in a way that programs would not interfere with each other.

I would really like to know the reason why you, Hiran, want to run your own multitasking shell.

Edited by MKlegoman357, 03 October 2014 - 04:06 PM.


#6 Hiran

  • Members
  • 44 posts

Posted 03 October 2014 - 04:14 PM

Bomb Bloke is right. If u're the only one writing all the code that would be run on one device you can easily set it in a way that wont interfere with others, but if you want to use multishell to run few apps from different people you can expect miracles if they use events that are considered "global" by current multishell xD
And multishell has this "tab selection row" on the top of the screen. If i were to run some app that has button/etc on the bottom, it is outside of the screen, so essentially invisible.

I dont know if its possible, but i want to create multishell without that tab row, as it interferes with other soft, and that forces me to play with events a little, so i can add a way to change active tab without running parallel on each shell. Maybe ill add customizable event handling, im not really sure yet.

I know that its a lot of work for a little effect, but i want to learn Lua, and coding stuff in CC is a good way to learn it, and other people may find it useful :)

Edit:

View PostMKlegoman357, on 03 October 2014 - 04:05 PM, said:

I would really like to know the reason why you, Hiran, want to run your own multitasking shell.
I want to learn Lua the hard way, and besides are you always the owner of the code ure using, and are the apps always simple? PDA are new, and im sure that people will create more and more complex apps on them. What would you do if you have 2 really complex apps and they fire events that interfere with each other?
Lua isnt really that complex language, so i want to create something complex, maybe it will evolve in something OS like, i dont know :)

Edited by Hiran, 03 October 2014 - 04:21 PM.


#7 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 03 October 2014 - 04:31 PM

Ah, I see now.

I don't know if you have seen it or not, but because of the top row multishell has in CC 1.6+ there was added a new event called "term_resize" which is fired when the screen size changes (when the mutlishell top row appears). Also, there is a multishell API which lets you to open new tabs and change their title.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users