Jump to content


Cross_Sans's Content

There have been 63 items by Cross_Sans (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#274078 How can I set the "..." used as arguments ?

Posted by Cross_Sans on 03 January 2018 - 12:56 PM in Ask a Pro

Thank you for both users that helped me, and especially for the helpful links. :)
Have a nice afternoon (well, that depends on where you both live);
Anyways, bye :)
Alex.



#274075 How can I set the "..." used as arguments ?

Posted by Cross_Sans on 03 January 2018 - 11:41 AM in Ask a Pro

EDIT:I just saw that I post this at the wrong section, if you are a moderator, please move it to Ask a pro. Thanks.

Hi, I am currently making a shell for ComputerCraft, and I am currently facing a problem: How do I set the ... to what the shell receives ?

For example:
... = arguments; -- This is not possible, but then how CraftOS did set this ?
local env = { ... };
setmetatable(env, { __index = getfenv() });
local initFn, err = assert(loadfile(path, env));
-- check and run

Thank you and have a nice day, Alex.



#273565 Shark - A site browser for CC

Posted by Cross_Sans on 21 December 2017 - 04:27 PM in Programs

Yeah, another web browser; but seriously, hardly creating a custom URL syntax with a custom language is very impertinent and not useful at all to be honest. If it was supporting requests (and this is possible even if ComputerCraft hasn't many functions for networking) and HTML (even a bit), it would be much more popular and would get more feedback. I mean, you did have made a parser that is XML language like, so why using a custom language ?

Have a nice day,

Alex.



#273553 256 shades of gray

Posted by Cross_Sans on 20 December 2017 - 05:11 PM in Programs

Hi, long time ago I didn't post something. With the first pre-release of ComputerCraft 1.80, I decided to show how term.setPaletteColor(...) was useful in many cases. Here is an example of what you can do with this precious function:
Posted Image
Pretty cool isn't it ?

And here is the program to reproduce the following:
for i = 1, 14 do
 term.setBackgroundColor(colors.black);
 write(" ");
 term.setPaletteColor(2 ^ i, colors.rgb8(i * 6 / 100, i * 6 / 100, i * 6 / 100));
 term.setBackgroundColor(2 ^ i);
 for i = 1, 14 do
  term.setTextColor(2 ^ i);
  write(string.char(127));
 end
 print();
end

It's such a great improvement for ComputerCraft. By the way, this function is available only in ComputerCraft 1.80pr0.

Anyways, this was a very simple demonstration of what you can do with this; have a nice day,
Alex.



#267011 Graduation - The portable operating system

Posted by Cross_Sans on 13 May 2017 - 06:53 PM in Operating Systems

Graduation is now discountinued, a new and bigger project is in creation.
Please do not download and use this operating system.



#267000 coroutine.resume(...) without pause to main code

Posted by Cross_Sans on 13 May 2017 - 10:26 AM in Ask a Pro

(Sorry for the double post)

I managed to fix problems, and the thread manager is working now :D !
Many thanks for SquidDev, Lyqyd, and KingofGamesYami for helping me.

Moderators, you can close this topic.

Posted Image



#266978 coroutine.resume(...) without pause to main code

Posted by Cross_Sans on 12 May 2017 - 06:45 PM in Ask a Pro

View PostSquidDev, on 12 May 2017 - 06:14 PM, said:

...

I changed my for loop to use ipairs function. I try to fix errors by reading the parralel API, I managed to run threads but the only problem is that the screen is black for 10 seconds, and then the output of the threads displays for 1 second, and shuts down. It says an error like "windows: 95: too long without yielding" but I use coroutine.yield() in my two functions for the threads. Here is the modified function:
function Nature.Thread.Switch()
	if ThreadMode then
		error("Nature.Thread.Switch: Cannot switch because Thread Mode is already activated");
	end

	Nature.Logger.LogLine("THRD", "Switching to ThreadMode...");
	ThreadMode = true;

	while #Nature.Thread.List > 0 do
		local Event = Nature.Thread.GetEvent() or {};

		for Index, ThreadItem in ipairs(Nature.Thread.List) do
			if Nature.Thread.List[Index] ~= nil then
				repeat
				local CanResume, Parameter = coroutine.resume(ThreadItem.Thread, unpack(Event));

				write("Thread #" .. Index .. " is running... ");
				write(tostring(coroutine.status(ThreadItem.Thread)));
				print(" - " .. tostring(Parameter));

				if CanResume == false then
					Nature.Logger.LogLine("THRD", "Error while running thread ID " .. Index .. ": " .. Parameter);
					table.remove(Nature.Thread.List, Index);
					break;
				elseif coroutine.status(Nature.Thread.List[Index].Thread) == "dead" then
					table.remove(Nature.Thread.List, Index);
					break;
				end
				until true
			end
		end
	end
end



#266975 coroutine.resume(...) without pause to main code

Posted by Cross_Sans on 12 May 2017 - 06:07 PM in Ask a Pro

Thanks for helping me, I managed to fix it without having to do a reversed for loop.

View PostSquidDev, on 12 May 2017 - 05:54 PM, said:

--# Note the arguments are flipped and the -1. This says "start at the length and continue to 1".
for Index = #Nature.Thread.List, 1, -1 do
	--# Whatever you had before.
	if CanResume == false then
		--# Removing is actually the same here too.
		table.remove(Nature.Thread.List, Index)
	end
end

View PostSquidDev, on 12 May 2017 - 05:54 PM, said:

I'm not entirely sure what you're expecting next to do here. This normally accepts a table and a key and returns the next key in the table. Here you're passing no arguments.
I didn't understand what are you talking about; give me an example; and sorry if i'm dumb by the way.



#266972 coroutine.resume(...) without pause to main code

Posted by Cross_Sans on 12 May 2017 - 05:02 PM in Ask a Pro

(Sorry for the double post)

Okay, I have figured out how to fix it, but when I run it, the thread is turning to "dead" mode when coroutine.yield() is called:
Posted Image

Code for threading: https://pastebin.com/HZiRT8d5
Code for kernel (part of): https://pastebin.com/GKubbDRq



#266969 coroutine.resume(...) without pause to main code

Posted by Cross_Sans on 12 May 2017 - 04:07 PM in Ask a Pro

Thanks for the links.
I have already checked how does the LyqydOS's process API, but I didn't understand how does actually works.
But, with the flow chart of KingofGamesYami, I figured out how does it works. I will tell if I still couldn't do it.



#266953 coroutine.resume(...) without pause to main code

Posted by Cross_Sans on 11 May 2017 - 06:25 PM in Ask a Pro

View PostSquidDev, on 11 May 2017 - 06:18 PM, said:

No. Only one thing can be run at once with Lua. Even individual computers cannot be run at the same time.

I mean by that, I could implement by running one at a time a thread, by helping me with the parallel and coroutine* sources ?
coroutine*: Not sure if the source is available.



#266950 coroutine.resume(...) without pause to main code

Posted by Cross_Sans on 11 May 2017 - 06:14 PM in Ask a Pro

Thanks for your help. So, there is still a way to implement it ?



#266948 coroutine.resume(...) without pause to main code

Posted by Cross_Sans on 11 May 2017 - 03:59 PM in Ask a Pro

Hi,
I am currently writing my own thread manager, the only problem is I want to coroutine.resume without pausing the next piece of code. Example:
coroutine.resume(thread); -- This will run in background
print("Thread started successfully"); -- This will print when the coroutine has started successfuly


Is there any way to do that ?

Thanks for reading,
Redall.



#266904 M-Shell - A simple shell.

Posted by Cross_Sans on 09 May 2017 - 04:09 PM in Operating Systems

Please REMOVE all sleeps calls, it's useless.
Otherwise, it's good for a beginning.



#266889 How do I make threads that uses events with the coroutine API ?

Posted by Cross_Sans on 08 May 2017 - 06:32 PM in Ask a Pro

Thanks for the links.



#266878 How do I make threads that uses events with the coroutine API ?

Posted by Cross_Sans on 08 May 2017 - 01:00 PM in Ask a Pro

Hi, my question is "How do I make threads that uses events with the coroutine API ?". I have tried few times, but failed at each one. I was unable to get os.pullEvent() to work on any attempt I have made. Please make an example program.

Thanks for reading, Redall.



#266877 cLinux [now with OPTIONAL Desktop Enviroment] [Bye CraftOS, kappa]

Posted by Cross_Sans on 08 May 2017 - 12:36 PM in Operating Systems

View PostPiorjade, on 08 May 2017 - 11:03 AM, said:

...
No problem Piorjade :)
By the way:
Posted Image



#266852 ReboOSt - Beta 1

Posted by Cross_Sans on 07 May 2017 - 03:00 PM in Operating Systems

View PostChickenbreadlp, on 30 April 2017 - 08:18 AM, said:

...

Look at the top of the first message.



#266851 cLinux [now with OPTIONAL Desktop Enviroment] [Bye CraftOS, kappa]

Posted by Cross_Sans on 07 May 2017 - 02:58 PM in Operating Systems

View PostPiorjade, on 26 April 2017 - 05:45 PM, said:

  • rmusr <name>
It's deluser not rmuser.
Anyway, it's your OS :).



#265461 Sliders - Easy Slider Creation

Posted by Cross_Sans on 09 March 2017 - 05:37 PM in APIs and Utilities

Interresting, but why did you called it Sliders and not Scrollbars ?



#265460 VedroidOS - Pocket (or maybe more) Computer OS | ● ^ ● |

Posted by Cross_Sans on 09 March 2017 - 05:31 PM in Operating Systems

You can block CTRL-T by using this piece of code:
function os.pullEvent(event, ...)
  local event = os.pullEventRaw(event);
  if event ~= "terminate" then
   return event, ...;
  end
end



#265459 Claire (screenshot) - A hexadecimal programming language

Posted by Cross_Sans on 09 March 2017 - 05:23 PM in Media

The same program, but the programming language was complety clean and rewritten:
Posted Image



#265457 cLinux [now with OPTIONAL Desktop Enviroment] [Bye CraftOS, kappa]

Posted by Cross_Sans on 09 March 2017 - 11:04 AM in Operating Systems

If you are (re)making Android, you should implement /vendor.rc or a file called like this that contains informations about the OS and the "Vendor".



#264435 Graduation - The portable operating system

Posted by Cross_Sans on 04 February 2017 - 11:16 AM in Operating Systems

View PostExerro, on 04 February 2017 - 11:08 AM, said:

View PostRedall, on 04 February 2017 - 10:30 AM, said:

- The rwx is to short this, because it takes only 3 characters :
  • Can I read ?
  • Can I write ?
  • Can I execute ?

Sure but does it actually affect anything? Like, would I be able to give a file `r-x` permissions and then not be able to write to it (make it read-only)?

View PostRedall, on 04 February 2017 - 10:30 AM, said:


- I prefer writing on a document than on a Wiki. I do not really like the way Wikis works.

That may be true, but I'd suggest most people prefer wikis. It's probably as simple as copying the pdf text into a `.md` file and doing a bit of formatting, ~10 mins tops.


- I plan to add a permission system, for the moment, it is just for showing properties quickly.
- I still do not want to make a Wiki for this. I don't like it.



#264432 Graduation - The portable operating system

Posted by Cross_Sans on 04 February 2017 - 10:30 AM in Operating Systems

View PostExerro, on 04 February 2017 - 10:20 AM, said:

Looks kinda cool. The pdf manual is a neat idea although a markdown file in the wiki probably would've done just as well and been much easier to write. It's also not that hard to show folder file sizes in the 'ls' program, and that'd be pretty helpful. Also, what's with the 'rwx'? I'm guessing that's for file permissions (read/write/execute), but I couldn't find anything in the code that handles that. Is it just for show?

I looked through the code; you have a big function for finding if a string is empty, which I think should probably return true if it only contains "\t" and " ". You could simplify this to:
return not s:find "[^\t ]" or #s == 0
That being said, your current function will also return true if only the start is whitespace (probably unintentional?), which'd be this:
return s:find "^[\t ]" or #s == 0

You give quite a few restrictions in the README on creating OSs from this, but you've given it the MIT license. Have a read through your restrictions and the license: the license says "do whatever you want", pretty much. You might want to change that.

If you can manage it, I'd add in things like piping: redirecting the output of one program to the input of another. Right now, this only really gives a graphical tweak to the inbuilt shell commands, so claiming it's "more powerful than a graphical operating system" is a bit risky when compared to something that does things like multitasking and users as well as fancy graphics.

Anyways, the effort you put into this really shows, just keep adding more to make it worth the annoyingly awkward installation process.

- The rwx is to short this, because it takes only 3 characters :
  • Can I read ?
  • Can I write ?
  • Can I execute ?
- Actually, you are right for the license and my restrictions. I changed it
- This was intentional to only return true if the string contains only spaces or tabulation characters. I changed the function, thanks for your code.
- This operating system just have 7/8 days of live, I should remove the line "more powerful than a graphical operating system", and re-add it when I will do the multitasking and piping.
- I prefer writing on a document than on a Wiki. I do not really like the way Wikis works.
- Actually, I am really bad at coroutines, so I need time to learn more about it.

Thanks for your post, this was really constructive and helpful.