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

Computer Craft Mods[Proof of Concept?]

Started by Mailmanq!, 08 March 2013 - 03:32 PM
Mailmanq! #1
Posted 08 March 2013 - 04:32 PM
I think there need to be more programs allowing for mods, or plugins. I have created a simple script; it has a main function and then loops through the mods that are all loaded in a folder and runs them, but of course I am not that good and complex stuff n' things. So, I am opening the idea of something we need more of, customization. The 'OS'es that exist could have plugins and stuff, firewolf adds and more.

Here is my basic script:
Spoilerhttp://pastebin.com/nrdxqFaS



modFolder = "/mods"
mods = {}
function main()
  print("hello")
end

for k, v in pairs(fs.list(modFolder)) do
  local f = fs.open(modFolder.."/"..v, "r")
  if f then
    mods[v] = loadstring(f.readAll())
  end
  f.close()
end

while true do
  main()
  for k, v in pairs(mods) do
    mods[k]()
  end
  
end
Sammich Lord #2
Posted 08 March 2013 - 04:33 PM
So you want more CC scripts to be more modular?
Mailmanq! #3
Posted 08 March 2013 - 04:35 PM
So you want more CC scripts to be more modular?

Exactly good job, me and words hate each other :)/>
billysback #4
Posted 09 March 2013 - 10:43 PM
like this?
Here's a little program that lets you mod any program as long as you sort of install it;

To run it on this just put the line:
function run(mods)
in line 582
and the line:
end
function startup() end
after all of the code, then download this program:
http://pastebin.com/3e0Y0ShV

fiddle with the settings so it works then run that program.

I haven't had time to test it, but it should work, to edit any other game to make it compatible with the mod basically just wrap the loop with a run(mods) function and wrap a part of the code in which important variables are set in startup() function

to make mods just make one function named "run" with one parameter "main" which is the program, so for this you could call
main.registerBlock( 333, "Rainbow", colors.pink, 33)
I made this a while ago, based off of how my "Navy" game's mods work