Jump to content




Idea Exchange

networking lua command networking pocket wireless networking

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

#381 Galbi3000

  • Members
  • 22 posts

Posted 11 March 2015 - 10:32 PM

I already have a collection of simple command programs of LEFT, RIGHT, FORWARD, BACK, UP, DOWN and DIG that can be used singularly at the TurtleOS command prompt. My program would be an alternative command prompt just for commands that control the turtle in much the same way but adding scripting support.

The overall program name would be called TURTLE. So at the TurtleOS you would type TURTLE to get the TURTLE Prompt. One of those commands is the RUN command that runs the scripts. But I also think that it would be good for the TURTLE program to be able to run a script then exit back to the TurtleOS prompt by adding the script name as a parameter to TURTLE.

So to expand on my previous example of having a script called buildHouse stored on the disk as turtle.buildHouse I would type at the TurtleOS prompt 'turtle buildHouse' (as opposed to typing 'turtle' then 'run buildHouse' followed by 'exit' to return to TurtleOS).

So basically you have 2 modes of using the program, first to give turtle commands directly to the turtle using a specialised command prompt and second to run scripts containing those commands.

Just as in the Logo language, many of the commands will have alternatives or abbreviated versions of the command. For example FORWARD, FORWARDS, FWD, FD or F would move the turtle forward. UP, RISE, U to go up. And I think you get the idea :)

I will keep the first version simple and then see how well it is received before adding more features to make the scripting side a bit more powerful without making it too complex to learn :)

#382 jerimo

  • Members
  • 74 posts

Posted 12 March 2015 - 05:07 AM

View PostGalbi3000, on 11 March 2015 - 10:32 PM, said:

I already have a collection of simple command programs of LEFT, RIGHT, FORWARD, BACK, UP, DOWN and DIG that can be used singularly at the TurtleOS command prompt. My program would be an alternative command prompt just for commands that control the turtle in much the same way but adding scripting support.

The overall program name would be called TURTLE. So at the TurtleOS you would type TURTLE to get the TURTLE Prompt. One of those commands is the RUN command that runs the scripts. But I also think that it would be good for the TURTLE program to be able to run a script then exit back to the TurtleOS prompt by adding the script name as a parameter to TURTLE.

So to expand on my previous example of having a script called buildHouse stored on the disk as turtle.buildHouse I would type at the TurtleOS prompt 'turtle buildHouse' (as opposed to typing 'turtle' then 'run buildHouse' followed by 'exit' to return to TurtleOS).

So basically you have 2 modes of using the program, first to give turtle commands directly to the turtle using a specialised command prompt and second to run scripts containing those commands.

Just as in the Logo language, many of the commands will have alternatives or abbreviated versions of the command. For example FORWARD, FORWARDS, FWD, FD or F would move the turtle forward. UP, RISE, U to go up. And I think you get the idea :)/>

I will keep the first version simple and then see how well it is received before adding more features to make the scripting side a bit more powerful without making it too complex to learn :)/>
Seems interesting, cant wait to see a useable build! If you wanna check out do to reuse some of the code feel free, in case you need an API call without checking a specific one

#383 The Lone Wolfling

  • Members
  • 43 posts

Posted 12 March 2015 - 12:31 PM

Hmm... It should be possible to use a cell phone or tablet as a monitor, using the HTTP API. Has anyone already done this?

#384 jerimo

  • Members
  • 74 posts

Posted 12 March 2015 - 03:12 PM

View PostThe Lone Wolfling, on 12 March 2015 - 12:31 PM, said:

Hmm... It should be possible to use a cell phone or tablet as a monitor, using the HTTP API. Has anyone already done this?
Wouldnt you also need to make an app for the cellphone or tablet in question to display it though?

#385 The Lone Wolfling

  • Members
  • 43 posts

Posted 12 March 2015 - 03:41 PM

View Postjerimo, on 12 March 2015 - 03:12 PM, said:

View PostThe Lone Wolfling, on 12 March 2015 - 12:31 PM, said:

Hmm... It should be possible to use a cell phone or tablet as a monitor, using the HTTP API. Has anyone already done this?
Wouldnt you also need to make an app for the cellphone or tablet in question to display it though?
You could, but I don't think you need to. A fullscreened web page should be enough. I think you'd need a web server running somewhere though, as as far as I know CC doesn't allow HTTP servers. (Although: That would be a neat peripheral.)

See, for example, Mote. And Mote's API could allow this, assuming one could find some way to serve the "glue" page.

Although you could skip the web server by making an app.

#386 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 12 March 2015 - 10:31 PM

View PostGeforce Fan, on 21 February 2015 - 12:27 AM, said:

A trade system using CommandComputers that allows you to list an item on sale for digital currency, and get money when someone decides to buy it. It will store it until someone comes and purchases it, whom will then receive it.

I have started something like this :D

View PostLDDestroier, on 04 March 2015 - 02:47 AM, said:

Would it be possible to allow a player to talk, then have a chatbox take that chat message, put it through an http server, and then output it in another server with another chatbox? It seems like a really frickin cool idea, and something that could be done, given the limitations of chatboxes and the ability of external web servers.

You know what, hey oeed! Try making a web server on your domain, and the lua software for connecting to it and sending player chatting (from certain players) to it to be sent to another server! Chatboxes are in LuaLand, so it could be put there.

EDIT: I forgot this post existed...sorry

I will make this?

#387 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 13 March 2015 - 04:36 PM

So over the past few weeks I have been working on the App Store / CCSystems php script.

I have added new things including comments systems, updateing/editing programs, but now I am stuck on what next to add.
So here is what I ask, would you be able to give me some awesome ideas that should be added to the App Store?
These can be things like rating systems or extra functions to help you use the store.

Another thing is before I do who is up for using the CCSystems User Database? I have had this working and already have over 100 users registered. Currently you can register and login, the idea was to have a centralised database so everyone can use the same database. This is all up to you but I have released a few code snippets for you to use which are below so you can also use the system!

If you have any ideas on what next to add then do tell me!! :D

Code uses sha256 to hash the password, please don't stop this otherwise people won't be able to login/out.

How to use:
Copy the large code below and put it at the top of your program, then use the following functions to use:
users.login(<username>, <password) -- login
users.register(username, email, password)
-- Username and password (and email if registering) will need to be got using a read function etc.

users = {}
users.__index = users
function users.login(username, password)
local req = http.post("https://ccsystems.dannysmc.com/ccsystems.php", "ccsys="..textutils.urlEncode(tostring("user")).."&cccmd="..textutils.urlEncode(tostring("login")).."&username="..textutils.urlEncode(tostring(username)).."&password="..textutils.urlEncode(tostring(users.sha256(password))))
local status = req.readAll()
if status == "true" then
  return true
else
  return false
end
endfunction users.register(username, email, password)
local req = http.post("https://ccsystems.dannysmc.com/ccsystems.php", "ccsys="..textutils.urlEncode(tostring("user")).."&cccmd="..textutils.urlEncode(tostring("register")).."&username="..textutils.urlEncode(tostring(username)).."&password="..textutils.urlEncode(tostring(users.sha256(password))).."&email="..textutils.urlEncode(tostring(email)))
local status = req.readAll()
	if status == "true" then
		return true
	else
		return false
	end
end
local MOD = 2^32
local MODM = MOD-1
local function memoize(f)
	local mt = {}
	local t = setmetatable({}, mt)
	function mt:__index(k)
		local v = f(k)
		t[k] = v
		return v
	end
	return t
end
local function make_bitop_uncached(t, m)
	local function bitop(a, B)/>/>
		local res,p = 0,1
		while a ~= 0 and b ~= 0 do
			local am, bm = a % m, b % m
			res = res + t[am][bm] * p
			a = (a - am) / m
			b = (b - bm) / m
			p = p*m
		end
		res = res + (a + B)/>/> * p
		return res
	end
	return bitop
end
local function make_bitop(t)
	local op1 = make_bitop_uncached(t,2^1)
	local op2 = memoize(function(a) return memoize(function(B)/>/> return op1(a, B)/>/> end) end)
	return make_bitop_uncached(op2, 2 ^ (t.n or 1))
end
local bxor1 = make_bitop({[0] = {[0] = 0,[1] = 1}, [1] = {[0] = 1, [1] = 0}, n = 4})
local function bxor(a, b, c, ...)
	local z = nil
	if b then
		a = a % MOD
		b = b % MOD
		z = bxor1(a, B)/>/>
		if c then z = bxor(z, c, ...) end
		return z
	elseif a then return a % MOD
	else return 0 end
end
local function band(a, b, c, ...)
	local z
	if b then
		a = a % MOD
		b = b % MOD
		z = ((a + B)/>/> - bxor1(a,B)/>/>) / 2
		if c then z = bit32_band(z, c, ...) end
		return z
	elseif a then return a % MOD
	else return MODM end
end
local function bnot(x) return (-1 - x) % MOD end
local function rshift1(a, disp)
	if disp < 0 then return lshift(a,-disp) end
	return math.floor(a % 2 ^ 32 / 2 ^ disp)
end
local function rshift(x, disp)
	if disp > 31 or disp < -31 then return 0 end
	return rshift1(x % MOD, disp)
end
local function lshift(a, disp)
	if disp < 0 then return rshift(a,-disp) end
	return (a * 2 ^ disp) % 2 ^ 32
end
local function rrotate(x, disp)
	x = x % MOD
	disp = disp % 32
	local low = band(x, 2 ^ disp - 1)
	return rshift(x, disp) + lshift(low, 32 - disp)
end
local k = {
	0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
	0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
	0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
	0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
	0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
	0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
	0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
	0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
	0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
	0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
	0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
	0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
	0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
	0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
	0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
	0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
}
local function str2hexa(s)
	return (string.gsub(s, ".", function(c) return string.format("%02x", string.byte(c)) end))
end
local function num2s(l, n)
	local s = ""
	for i = 1, n do
		local rem = l % 256
		s = string.char(rem) .. s
		l = (l - rem) / 256
	end
	return s
end
local function s232num(s, i)
	local n = 0
	for i = i, i + 3 do n = n*256 + string.byte(s, i) end
	return n
end
local function preproc(msg, len)
	local extra = 64 - ((len + 9) % 64)
	len = num2s(8 * len, 8)
	msg = msg .. "\128" .. string.rep("\0", extra) .. len
	assert(#msg % 64 == 0)
	return msg
end
local function initH256(H)
	H[1] = 0x6a09e667
	H[2] = 0xbb67ae85
	H[3] = 0x3c6ef372
	H[4] = 0xa54ff53a
	H[5] = 0x510e527f
	H[6] = 0x9b05688c
	H[7] = 0x1f83d9ab
	H[8] = 0x5be0cd19
	return H
end
local function digestblock(msg, i, H)
	local w = {}
	for j = 1, 16 do w[j] = s232num(msg, i + (j - 1)*4) end
	for j = 17, 64 do
		local v = w[j - 15]
		local s0 = bxor(rrotate(v, 7), rrotate(v, 18), rshift(v, 3))
		v = w[j - 2]
		w[j] = w[j - 16] + s0 + w[j - 7] + bxor(rrotate(v, 17), rrotate(v, 19), rshift(v, 10))
	end
	local a, b, c, d, e, f, g, h = H[1], H[2], H[3], H[4], H[5], H[6], H[7], H[8]
	for i = 1, 64 do
		local s0 = bxor(rrotate(a, 2), rrotate(a, 13), rrotate(a, 22))
		local maj = bxor(band(a, B)/>/>, band(a, c), band(b, c))
		local t2 = s0 + maj
		local s1 = bxor(rrotate(e, 6), rrotate(e, 11), rrotate(e, 25))
		local ch = bxor (band(e, f), band(bnot(e), g))
		local t1 = h + s1 + ch + k[i] + w[i]
		h, g, f, e, d, c, b, a = g, f, e, d + t1, c, b, a, t1 + t2
	end
	H[1] = band(H[1] + a)
	H[2] = band(H[2] + B)/>/>
	H[3] = band(H[3] + c)
	H[4] = band(H[4] + d)
	H[5] = band(H[5] + e)
	H[6] = band(H[6] + f)
	H[7] = band(H[7] + g)
	H[8] = band(H[8] + h)
end
function users.sha256(msg)
	msg = preproc(msg, #msg)
	local H = initH256({})
	for i = 1, #msg, 64 do digestblock(msg, i, H) end
	return str2hexa(num2s(H[1], 4) .. num2s(H[2], 4) .. num2s(H[3], 4) .. num2s(H[4], 4) ..
		num2s(H[5], 4) .. num2s(H[6], 4) .. num2s(H[7], 4) .. num2s(H[8], 4))
end

Edited by DannySMc, 13 March 2015 - 04:38 PM.


#388 CastleMan2000

  • Members
  • 195 posts
  • LocationThe trashcan where all Undertale trash is

Posted 14 March 2015 - 09:48 AM

It's relatively easy to set up a GPS program on a pocket computer. I did it myself with ActiveGPS, a simple program to tell you your XYZ coordinates. However, if you have limited wifi range, or the chunk simply unloads, your GPS will disconnect and stop working. So here's an idea: Use turtles. Having one to three turtles (I don't know how many would actually be necessary) you could use the distance parameter in rednet to automatically keep up with you while you carry a pocket computer running a special program, and then they would automatically update the coordinates they are broadcasting, allowing you to virtually always know where you are. I think the best way to do this would be to put the turtles up at the sky limit, and then follow your every step from above. I think that something similar could be done for things like chat or file servers, allowing constant access to whatever data you need.

What do you think of this idea?

#389 oli414

  • Members
  • 29 posts
  • LocationThe Netherlands

Posted 14 March 2015 - 10:08 AM

It's a nice idea, however when you log out and back in you'll have to start all the turtles again, which will be a pain if they're really heigh to prevent them from getting stuck in mountains

#390 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 14 March 2015 - 11:08 AM

After server restart, chunk reload, etc.. all computers that were running before it are automatically turned on. You can then just have a startup script on them to re-run the GPS.

#391 Bomb Bloke

    Hobbyist Coder

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

Posted 14 March 2015 - 11:24 AM

But then how would the turtles know where they are, in order to function as GPS hosts? They'd either need to spam HDD writes to track their locations (in preparation for the next server reboot, which could happen at any time), or remain in range of a static GPS cluster.

Really though, the main issue is that there's no way for turtles to keep up with a roaming player. Better to have the turtles simply wander around placing static GPS clusters down in preparation for a player to come wandering through. If you've got MoarPeripherals installed, maybe use its long-range towers instead. Scratch that, pocket computers don't support any peripheral that isn't a regular wireless modem...

Edited by Bomb Bloke, 14 March 2015 - 11:30 AM.


#392 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 14 March 2015 - 11:37 AM

Almost ninjad

What I was going to say but is mostly repeating BombBloke:
The bigger problem is what if the chunk uploads (SMP: log out, SSP: close world) and one (or more) of the turtles was in mid move and hadn't saved its new position yet. Its saved position on load would be one block off from where it actually is.

New information:
There are some ways to get around this problem, Lama is/was one (no idea if it still works) and the other would be having 5 turtles where only one moves at a time and on chunk load they compare positions to find out who may have got lost during the unload. There is a problem with the latter though, your turtles will be moving even slower then they do now, and turtles have a hard time keeping up with the player already.

Edited by Lupus590, 15 March 2015 - 11:52 AM.


#393 Galbi3000

  • Members
  • 22 posts

Posted 15 March 2015 - 02:24 AM

View Postjerimo, on 12 March 2015 - 05:07 AM, said:

View PostGalbi3000, on 11 March 2015 - 10:32 PM, said:

I already have a collection of simple command programs of LEFT, RIGHT, FORWARD, BACK, UP, DOWN and DIG that can be used singularly at the TurtleOS command prompt. My program would be an alternative command prompt just for commands that control the turtle in much the same way but adding scripting support.

The overall program name would be called TURTLE. So at the TurtleOS you would type TURTLE to get the TURTLE Prompt. One of those commands is the RUN command that runs the scripts. But I also think that it would be good for the TURTLE program to be able to run a script then exit back to the TurtleOS prompt by adding the script name as a parameter to TURTLE.

So to expand on my previous example of having a script called buildHouse stored on the disk as turtle.buildHouse I would type at the TurtleOS prompt 'turtle buildHouse' (as opposed to typing 'turtle' then 'run buildHouse' followed by 'exit' to return to TurtleOS).

So basically you have 2 modes of using the program, first to give turtle commands directly to the turtle using a specialised command prompt and second to run scripts containing those commands.

Just as in the Logo language, many of the commands will have alternatives or abbreviated versions of the command. For example FORWARD, FORWARDS, FWD, FD or F would move the turtle forward. UP, RISE, U to go up. And I think you get the idea :)/>

I will keep the first version simple and then see how well it is received before adding more features to make the scripting side a bit more powerful without making it too complex to learn :)/>
Seems interesting, cant wait to see a useable build! If you wanna check out do to reuse some of the code feel free, in case you need an API call without checking a specific one

I have a first beta version posted in the Turtle Programs section of the forum :)

http://www.computerc...romptscripting/

#394 jerimo

  • Members
  • 74 posts

Posted 15 March 2015 - 02:32 PM

Yeah saw that yesterday, if you need help with anything dont hesitate wr will probably run into the same problems anyways eh!

#395 Galbi3000

  • Members
  • 22 posts

Posted 15 March 2015 - 05:55 PM

View Postjerimo, on 15 March 2015 - 02:32 PM, said:

Yeah saw that yesterday, if you need help with anything dont hesitate wr will probably run into the same problems anyways eh!

The only problems I have had so far is learning differences between C/C++ and Lua. This project is the first time I have used tables which do not exist in C/C++ :)

I used to write software for Windows professionally back in the days of Windows 3.1 then on to Windows 95+, mostly GUI stuff (oops, showing my age a bit there!!). So conceptually this stuff is easy, I just need to learn Lua as I go along :)

Edited by Galbi3000, 15 March 2015 - 06:04 PM.


#396 jerimo

  • Members
  • 74 posts

Posted 17 March 2015 - 04:18 AM

View PostGalbi3000, on 15 March 2015 - 05:55 PM, said:

View Postjerimo, on 15 March 2015 - 02:32 PM, said:

Yeah saw that yesterday, if you need help with anything dont hesitate wr will probably run into the same problems anyways eh!

The only problems I have had so far is learning differences between C/C++ and Lua. This project is the first time I have used tables which do not exist in C/C++ :)/>

I used to write software for Windows professionally back in the days of Windows 3.1 then on to Windows 95+, mostly GUI stuff (oops, showing my age a bit there!!). So conceptually this stuff is easy, I just need to learn Lua as I go along :)/>
Actually coming from the same background, albeit being much younger, and yup some ways that you learnt to program won't hold up but have much simpler ways here, do is actually my first real push into lua as well, strangely enough

#397 SpencerBeige

  • Members
  • 263 posts

Posted 19 March 2015 - 01:16 PM

[IDEA]
LISC is a game which will allow you to mine, and craft in your own world. basically a ripoff of mc. however: a few things have been planned: a ranking system, for example, when you spawn you are asked: evil, or good? after you chose, you are 'humanic' meaning, that you are on the basic level. at this point, you are in the neutral world. leveling up is based on killing animals, or doing good things. killing animals will earn red points, and good things will earn green points. if you are evil, and earn 100 green points, you have the choice to become good, and visa - versa. after you gain enough points, you will be able to move onto different worlds. the evil side has: underworld, darklands, then hell. good has: overworld, peacelands, and heaven.

another idea is alchemy. mixing that herb, with this chemical, to get...a healing potion. blah blah blah,

this is the basic steps of production, so, this forum is very basic. i will post more ideas soon

extra note: the game will DEFINITELY not release until mouse_up event is made by dan200. a mouse_up function will make sure that i can integrate a time to mine function, that will make it take time to mine blocks, like in minecraft

Edited by slow-coder, 19 March 2015 - 01:22 PM.


#398 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 19 March 2015 - 03:35 PM

View Postslow-coder, on 19 March 2015 - 01:16 PM, said:

[IDEA]
LISC is a game which will allow you to mine, and craft in your own world. basically a ripoff of mc. however: a few things have been planned: a ranking system, for example, when you spawn you are asked: evil, or good? after you chose, you are 'humanic' meaning, that you are on the basic level. at this point, you are in the neutral world. leveling up is based on killing animals, or doing good things. killing animals will earn red points, and good things will earn green points. if you are evil, and earn 100 green points, you have the choice to become good, and visa - versa. after you gain enough points, you will be able to move onto different worlds. the evil side has: underworld, darklands, then hell. good has: overworld, peacelands, and heaven.

another idea is alchemy. mixing that herb, with this chemical, to get...a healing potion. blah blah blah,

this is the basic steps of production, so, this forum is very basic. i will post more ideas soon

extra note: the game will DEFINITELY not release until mouse_up event is made by dan200. a mouse_up function will make sure that i can integrate a time to mine function, that will make it take time to mine blocks, like in minecraft

This is an awesome idea, should definitely make it multiplayer!

#399 AssossaGPB

  • Members
  • 126 posts
  • LocationFlorida, USA

Posted 20 March 2015 - 03:43 PM

IDEA

A raytracer in cc! Probably would be very slow, but it would be good practice and very interesting.

#400 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 20 March 2015 - 05:40 PM

Some people have done that already
http://www.computerc...d-graphics-api/
(not the one i remembered google, but i guess this works)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users