This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
billysback's profile picture

[WIP] Navy [MMORPG] - very much work in progress

Started by billysback, 24 November 2012 - 10:02 PM
billysback #1
Posted 24 November 2012 - 11:02 PM
Navy is (I believe) the first MMORPG for CC (I may be wrong)

Not that much progress has been made yet but here is what you CAN do:
SpoilerJoin a server with a username (logging in with an already existant username will override the current player, bug, fixing)
Move around the world in real time and see other ships move around as well
Collision detection is implemented with the generated islands
Currently the map is 20 (width) by 18 (height), you can change this easily on lines 14 and 15 of the navy server
Move in to new maps by entering the island tiles
Chat in-game to other users!

Usage:
for the server you just start it up then enter the server name
for the client you start it up, enter the server you are joining and enter your username, to move your ship use left/right/up/down arrows

ToDo:
Spoileradd enemy mobs on islands – probably coming in update after next.
add loot, then <- working on this, you can find chests
add mods <- done, coming in next update
add password protected vaults to store your precious loot :D/>
add trading

Download:
SpoilerServer:
http://pastebin.com/jqQnEXC8
Client:
http://pastebin.com/9R0tyTiz

Requires Multinet API, found here:
http://www.computerc...ust-got-easier/

It also requires the modem to be on the right, you can edit this in code if you wish (the first line of code on both programs)

Screenies:
Spoiler
billysback #2
Posted 24 November 2012 - 11:08 PM
I can't edit the post properly, so until then here is a picture:
Spoiler
Map is random, the little brown "^" are the players, the top screen is the server, ignore the logs :D/>/>;
jag #3
Posted 24 November 2012 - 11:15 PM
Can't you make a auto installer for your API?
Sammich Lord #4
Posted 24 November 2012 - 11:34 PM
Cool man!
billysback #5
Posted 24 November 2012 - 11:38 PM
Can't you make a auto installer for your API?
How can I check if the API is already installed though, and doesn't it download the program in to the computer's program folder, not in to the apis folder…

Cool man!
thanks :D/>/>
TheVarmari #6
Posted 25 November 2012 - 12:24 AM
Can't you make a auto installer for your API?
How can I check if the API is already installed though, and doesn't it download the program in to the computer's program folder, not in to the apis folder…
1) fs.exists
2) Then use os.loadAPI to load it from *folder*
billysback #7
Posted 25 November 2012 - 12:27 AM
fs only checks in the run path, which is the computers folder… apis are not there.
ArchAngel075 #8
Posted 25 November 2012 - 12:30 AM
At the above

It is not going to check in apis folder, but that is ok since os.loadAPI will load it as if its an API, no need for a user to manually insert into a api folder
billysback #9
Posted 25 November 2012 - 12:41 AM
Hmmm?
The suggestion was for me to make an auto-installed, I don't know how to check if an API exists as there doesn't seem to be an obvious way, I don't want to be downloading it from paste bin every time it's run. I also don't understand how to get it to download something in to the apis folder, which is in rom, instead of making it download as if it was a program.
billysback #10
Posted 25 November 2012 - 01:33 AM
Update:
Added chat, type to enter character, enter to send message, backspace to remove last character. Messages appear on the left.
Added username checking, cannot log in with an existing username now.
ArchAngel075 #11
Posted 25 November 2012 - 01:47 AM
Hmmm? The suggestion was for me to make an auto-installed, I don't know how to check if an API exists as there doesn't seem to be an obvious way, I don't want to be downloading it from paste bin every time it's run. I also don't understand how to get it to download something in to the apis folder, which is in rom, instead of making it download as if it was a program.

using fs.exists("THE API") == true
to check if it is there else hav it dl from pastebin

you dont HAVE to have it in the api folder, using os.loadAPI will treat it as an api even though its in the programs folder.
ElectricOverride #12
Posted 25 November 2012 - 03:19 AM
When I try to boot up the server I get this:



Please reply.
billysback #13
Posted 25 November 2012 - 03:22 AM
You haven't installed my multinet API, you must download that… also:
Update:
improved updating of users, less flashy
multi-world servers now, enter a island tile to travel to it, press tab to return the the spawn point of the normal world.
added auto-installed of multinet API
ElectricOverride #14
Posted 25 November 2012 - 03:28 AM
You haven't installed my multinet API, you must download that… also: Update: improved updating of users, less flashy multi-world servers now, enter a island tile to travel to it, press tab to return the the spawn point of the normal world. added auto-installed of multinet API
Ahh sorry, got so exited to play I didnt read the whole post ^.^
ElectricOverride #15
Posted 25 November 2012 - 03:43 AM
Wow, now that I've got it working, this is pretty nice, there's even chat!

Great job on this! :D/>/>
anonimo182 #16
Posted 25 November 2012 - 09:05 AM
Nice game! I can't wait for it to have some other neat things!
Cranium #17
Posted 25 November 2012 - 12:37 PM

--check version
function update(code,filename)
local updateSite = http.get("http://pastebin.com/raw.php?i="..code)
if updateSite then
local newVersion = updateSite.readAll()
local currentFile = fs.open(filename,"r")
local readFile = currentFile.readAll()
currentFile.close()
if newVersion ~= readFile then
  local updateSite = http.get("http://pastebin.com/raw.php?i="..code)
  local siteFile = updateSite.readAll()
  local writeFile = fs.open(filename,"w")
  writeFile.write(siteFile)
  writeFile.close()
  return true
else
  return false
end
else
return "Error"
end
end
Here's a little update function for you. You can define the Pastebin code, and the file path. You can call it like this:

if fs.exists("API_FILE_PATH") then
  os.loadAPI("API_FILE_PATH")
else
  local file = fs.open("API_FILE_PATH", "w")
  file.writeLine("Loading")
  file.close()
  update("PASTEBIN_CODE", "API_FILE_PATH")
end
billysback #18
Posted 25 November 2012 - 12:55 PM
presuming you have the correct version is the way to go.
(that's what I'm doing right now)
when I use my own API's I treat them as if they are someone Else's anyway, I never edit the code just to make something easier, I work with what I already have unless it's fundamentally impossible.
ElectricOverride #19
Posted 25 November 2012 - 02:17 PM
presuming you have the correct version is the way to go. (that's what I'm doing right now) when I use my own API's I treat them as if they are someone Else's anyway, I never edit the code just to make something easier, I work with what I already have unless it's fundamentally impossible.
Same here. :D/>/>
GeniusName3 #20
Posted 25 November 2012 - 05:04 PM
Whenever I start up the client and type in the server name then enter my name,it terminates the program (doesn't say terminated) but it closes the program.
GeniusName3 #21
Posted 25 November 2012 - 05:48 PM
im offended cuz im in the navy
How is this going to offend you?It's just a game about the Navy.You don't see the military complaining about CoD.
GeniusName3 #22
Posted 25 November 2012 - 06:19 PM
im offended cuz im in the navy
How is this going to offend you?It's just a game about the Navy.You don't see the military complaining about CoD.
my dad is in the milatary and he is ofended
Why,what offends him?
billysback #23
Posted 25 November 2012 - 09:45 PM
Whenever I start up the client and type in the server name then enter my name,it terminates the program (doesn't say terminated) but it closes the program.
This happens if the server you entered is not a real server, you must start up your server on another computer first, leave it running, then go on another computer which is in range and start up the client.
ElectricOverride #24
Posted 26 November 2012 - 02:39 AM
Whenever I start up the client and type in the server name then enter my name,it terminates the program (doesn't say terminated) but it closes the program.
That means the server doesent exist.
Sammich Lord #25
Posted 26 November 2012 - 03:32 AM
You should really add a error handling for when the server does not exist.
D3matt #26
Posted 26 November 2012 - 04:47 AM
fs only checks in the run path, which is the computers folder… apis are not there.
I'm pretty sure fs accepts path names, IE fs.exists("path/to/api") in addition to just file names. Correct me if I'm wrong.
billysback #27
Posted 26 November 2012 - 04:57 AM
No it doesn't unfortunately, otherwise red-net would be absolutely pointless (you could create files not localized on computers so that all computers could read them, a computer could check to see if a file exists on loop, if it does then read the contents of the file and delete it, do something with the contents then continue to wait for a new file to be created :D/>/>

On the "server not found" error to be added, just replace the very last line on the navy client (line 245) with this super complex code:

else
	print("Server does not exist!")
end
Cranium #28
Posted 26 November 2012 - 05:09 AM
Actualy, os.loadAPI("path/to/API") will work. I run it all the time with my programs. It returns the filename as the api name. So in the example, you would be using API.function(). APIs do not need to be in the API folder to work.
billysback #29
Posted 26 November 2012 - 05:21 AM
Actualy, os.loadAPI("path/to/API") will work. I run it all the time with my programs. It returns the filename as the api name. So in the example, you would be using API.function(). APIs do not need to be in the API folder to work.
Wait, neither me or you responded with the correct thing.
He took what I said wrong and thought I was saying that fs does not accept "/" (directories)
I then took what he said wrong and said that fs cannot go out of the run path, i.e. it can't look through C:/ etc.
You then took what I said wrong and said the os.loadApi() can use directories, when that's not at all what I said,

what I said in the first place was that I thought apis were only checked in the apis folder (rom/apis), I know now that they don't have to be. I never said anything about anything not being able to use directories in the path…
Cranium #30
Posted 26 November 2012 - 06:57 AM
Well, glad we cleared that confusion up….
tommyroyall #31
Posted 26 November 2012 - 07:04 AM
man, this is awesome already xD. I can't wait :D/>/>. Also, mod support? Perhaps breaking it up into numerous modules for the sake of modding?

Or better yet, once it's finished I'll dig around and make it into modules that load mods from a directory :P/>/>.
GeniusName3 #32
Posted 26 November 2012 - 08:08 AM
Whenever I start up the client and type in the server name then enter my name,it terminates the program (doesn't say terminated) but it closes the program.
That means the server doesent exist.
I checked,it matches the server name case-sensitive
GeniusName3 #33
Posted 26 November 2012 - 08:33 AM

billysback #34
Posted 26 November 2012 - 09:03 AM
Is the computer in range of the server?
Have you got the latest version of navy for both the server and client?
Is your modem on the right for both the server and the client?

For the mods bit, I might add mods for both the client and server; maybe they would work like this:
To install a mod you download a file to the computer then edit the client or server and add the director in to a table at the top of the program (so it's easy to find and edit), the server/client then loads all of these mods as if they were APIs, the mods must have 3 functions:

function getName()
function startUp(user|server, other params)
function update(event, event_params, user|server, other params)
then it would tell you that it has loaded each mod on start up (and pause a bit), it would call the startUp() of each one when they load and it would update it every time an event is called.
GeniusName3 #35
Posted 26 November 2012 - 09:08 AM
Is the computer in range of the server? Have you got the latest version of navy for both the server and client? Is your modem on the right for both the server and the client? For the mods bit, I might add mods for both the client and server; maybe they would work like this: To install a mod you download a file to the computer then edit the client or server and add the director in to a table at the top of the program (so it's easy to find and edit), the server/client then loads all of these mods as if they were APIs, the mods must have 3 functions:
 function getName() function startUp(user|server, other params) function update(event, event_params, user|server, other params) 
then it would tell you that it has loaded each mod on start up (and pause a bit), it would call the startUp() of each one when they load and it would update it every time an event is called.
its like 5 blocks away from the server computer O.o.Latest version aswell.I have modems attached to all sides(except front)
billysback #36
Posted 26 November 2012 - 09:15 AM
Ummm…
I have no idea, try re-installed multinet?
The only time this would ever happen is if it cannot connect to the server, otherwise it would at least clear the screen or give you an error log.


EDIT:
I ADDED MODS :P/>/>/&amp;gt;
It hasn't been updated yet because I started adding loot before adding mods, so I'm going to have to finish adding the loot mechanics in before I can release the code :/
But you can start writing mods now if you want, heres how the work:
SpoilerStart by creating a new file, calling it whatever, then in this file creating four functions:


function getName()
	return "name"
end

--return 1 to 5, this is priority (1 is highest 5 is lowest), just decides what mods get called first. Don't always do top priority -.-
function getLevel()
	return 5
end

function startUp(user)
	--code on startup
end

--[[
user_dat is a table containing:
	user, location, current_input
event_dat is a table containing:
	event, p1, p2, p3
map_dat is a table containing:
	map, width, height, current_map_name
inv is a table contianing the players inventory (not yet implemented)

returns:
	true/false - whether or not to run the normal events or not, usually do true.
	commands in a table - commands you can run, i'll explain in thread
	data - a table containing all of the data given to you in the same format but in a table
]]
function update(user_dat, event_dat, map_dat, inv)
	local commands = {}
        local data = {user_dat, event_dat, map_dat, inv}
	return true, commands, data
end


neither data or commands has to be returns, you can just do return true

data is a table like so, just in case you didn't understand:

{
   {user, location, current_input}, 
   {event, p1, p2, p3}, 
   {map, width, height, name}, 
   inventory
}
any of these values can be nil, if they are then that value is ignored and not set,
it loops through all of them regardless of whether others were nil or not and sets the values to what you set.

commands are a bit more complicated, they let you run functions inside of the navy client, each command is a string split by a ":", the commands are:
Spoiler

send:message
   -sends a message to the server to put in the chat log
add:message
   -adds a message in to only the clients chat log
move:x:y
   -moves the player by x,y and checks collision
join:map_name
   -makes that player join that world, if the world does not exist creates the world
draw:type
   type can be:
      input
         -draws the current input (what your writing)
      messages
         -draws all of the messages again
      map
         -draws all of the map
      inv
         -draws your inventory
loot
   -adds a random amount of loot to your inventory

As I said earlier installing mods is super easy to do, you just add a line to a table in the navy_c file and download the mod :D/>/>
GeniusName3 #37
Posted 26 November 2012 - 09:47 AM
I got it working now,restarted minecraft and it worked,but on a tekkit server it isn't working :D/>/>
billysback #38
Posted 26 November 2012 - 10:06 AM
I ADDED MODS :P/>/>/&amp;gt;
It hasn't been updated yet because I started adding loot before adding mods, so I'm going to have to finish adding the loot mechanics in before I can release the code :/
But you can start writing mods now if you want, heres how the work:
SpoilerStart by creating a new file, calling it whatever, then in this file creating four functions:


function getName()
    return "name"
end

--return 1 to 5, this is priority (1 is highest 5 is lowest), just decides what mods get called first. Don't always do top priority -.-
function getLevel()
    return 5
end

function startUp(user)
    --code on startup
end

--[[
user_dat is a table containing:
    user, location, current_input
event_dat is a table containing:
    event, p1, p2, p3
map_dat is a table containing:
    map, width, height, current_map_name
inv is a table contianing the players inventory (not yet implemented)

returns:
    true/false - whether or not to run the normal events or not, usually do true.
    commands in a table - commands you can run, i'll explain in thread
    data - a table containing all of the data given to you in the same format but in a table
]]
function update(user_dat, event_dat, map_dat, inv)
    local commands = {}
	    local data = {user_dat, event_dat, map_dat, inv}
    return true, commands, data
end


neither data or commands has to be returns, you can just do return true

data is a table like so, just in case you didn't understand:

{
   {user, location, current_input},
   {event, p1, p2, p3},
   {map, width, height, name},
   inventory
}
any of these values can be nil, if they are then that value is ignored and not set,
it loops through all of them regardless of whether others were nil or not and sets the values to what you set.

commands are a bit more complicated, they let you run functions inside of the navy client, each command is a string split by a ":", the commands are:
Spoiler

send:message
   -sends a message to the server to put in the chat log
add:message
   -adds a message in to only the clients chat log
move:x:y
   -moves the player by x,y and checks collision
join:map_name
   -makes that player join that world, if the world does not exist creates the world
draw:type
   type can be:
	  input
		 -draws the current input (what your writing)
	  messages
		 -draws all of the messages again
	  map
		 -draws all of the map
	  inv
		 -draws your inventory
loot
   -adds a random amount of loot to your inventory

As I said earlier installing mods is super easy to do, you just add a line to a table in the navy_c file and download the mod :D/>/>

Also, good I'm happy it worked, I dunno about tekkit though…
GeniusName3 #39
Posted 26 November 2012 - 12:36 PM
yea,tekkit runs CC 1.3 they don't even have printers :l
Xemiru #40
Posted 26 November 2012 - 05:22 PM
Instead of making the modem required to be on the right, you could use rs.getSides().

for k,v in ipairs(rs.getSides()) do
rednet.open(v)
end
billysback #41
Posted 27 November 2012 - 05:02 AM
Instead of making the modem required to be on the right, you could use rs.getSides().
 for k,v in ipairs(rs.getSides()) do rednet.open(v) end 
I know how to do it, I just never did; CCEmu only has them on the right so yeah :P/>
billysback #42
Posted 27 November 2012 - 05:03 AM
I'm confused! D: I move my guy, and then he gets stuck and the server spams out: "8" "mk352:MATCHED" "updated" and the game freezes.
I have no idea, could you give me more details?
That all sounds like it should be working perfectly.
GeniusName3 #43
Posted 23 December 2012 - 06:35 AM
You should add some kind of friend list.
ElectricOverride #44
Posted 08 March 2013 - 12:20 AM
Whenever I start up the client and type in the server name then enter my name,it terminates the program (doesn't say terminated) but it closes the program.
I think that you dont have the multinet API installed.
akeldama280 #45
Posted 08 March 2013 - 05:36 AM
Sooooo cool.! It makes a computer something i want now! :D/>
ssandiss #46
Posted 10 March 2013 - 12:43 AM
How do i install the API? :S
Dlcruz129 #47
Posted 10 March 2013 - 11:51 AM
How do i install the API? :S

APIs are loaded via os.loadAPI(path)
LuaEclipser #48
Posted 11 March 2013 - 01:03 PM
not the first. mine (used to be mine) is a massive MMORPG
Left #49
Posted 11 March 2013 - 01:08 PM
Nice! Its fun to play too.