Veltamax
|
  |
| Joined: 06 May 2012 |
| Total Posts: 368 |
|
|
| 18 Aug 2014 02:32 PM |
Could someone help me with this? I can't get this stupid module script to do what I want. So basically I want to store a table somewhere, that when you open a program, it will add that program to the table. I've come up with that the only way to do this is with a Module Script. If there is another way, PLEASE TELL ME. Anyway, so, this is the little section of the script to require the module script.
local OpenProgramsModule = require(veltumpc.OpenPrograms) openprograms.insert(script.Parent.Name) --Apparently openprograms is nil?
ENTIRE MODULE SCRIPT:
local openprograms = {} openprograms.insert = function(program) table.insert(openprograms, program) print("insert") print(#openprograms .. " programs are open") end openprograms.recant = function(pprogram) table.remove(openprograms, pprogram) print("recant") print(#openprograms .. " programs are open") end return OpenProgramsModule
The issue is in the section in the script section, it says that the openprograms is nil.
If anyone knows any other way to do this or any way to make this work, PLEASE help me! I don't really know how to use module scripts much at all. :\ |
|
|
| Report Abuse |
|
|
|
| 18 Aug 2014 02:39 PM |
Looks like you've gotten some of your variables mixed up. Try this:
local openprograms = require(veltumpc.OpenPrograms) openprograms.insert(script.Parent.Name)
ENTIRE MODULE SCRIPT:
local openprograms = {} local OpenProgramsModule = {}
OpenProgramsModule.insert = function(program) table.insert(openprograms, program) print("insert") print(#openprograms .. " programs are open") end
OpenProgramsModule.recant = function(pprogram) table.remove(openprograms, pprogram) print("recant") print(#openprograms .. " programs are open") end
return OpenProgramsModule
Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson |
|
|
| Report Abuse |
|
|
Veltamax
|
  |
| Joined: 06 May 2012 |
| Total Posts: 368 |
|
|
| 19 Aug 2014 05:17 PM |
| You see, I only want one table. :\ |
|
|
| Report Abuse |
|
|
|
| 19 Aug 2014 11:32 PM |
If you don't mind me asking, why? Is there a problem with using two?
Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 20 Aug 2014 02:30 AM |
local openprograms = require(veltumpc.OpenPrograms) -- OpenProgramsModule == veltumpc.OpenPrograms, require(veltumpc.OpenPrograms) returns openprograms table openprograms.insert(script.Parent.Name) --Apparently openprograms is nil?
ENTIRE MODULE SCRIPT:
local openprograms = {}
openprograms.insert = function(program) table.insert(openprograms, program) print("insert") print(#openprograms .. " programs are open") end
openprograms.recant = function(pprogram) table.remove(openprograms, pprogram) print("recant") print(#openprograms .. " programs are open") end
return OpenProgramsModule |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 20 Aug 2014 02:33 AM |
I derped
local openprograms = require(veltumpc.OpenPrograms) -- OpenProgramsModule == veltumpc.OpenPrograms, require(veltumpc.OpenPrograms) returns openprograms table openprograms.insert(script.Parent.Name) --Apparently openprograms is nil?
ENTIRE MODULE SCRIPT:
local openprograms = {}
openprograms.insert = function(program) table.insert(openprograms, program) print("insert") print(#openprograms .. " programs are open") end
openprograms.recant = function(pprogram) table.remove(openprograms, pprogram) print("recant") print(#openprograms .. " programs are open") end
return openprograms |
|
|
| Report Abuse |
|
|