Jump to content




Save values on restart


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

#1 Stroooomdahl

  • New Members
  • 1 posts

Posted 25 February 2014 - 01:06 PM

Hello!

I couldn't find a thread about this...

I got an idea for a program that will count the number of items my mob spawner drops but the problem is that it will not save the value when i shut down minecraft..
Is there a way to make the computer to remember the value after a restart has been done?

Ps Im sorry if their is some miss spelling or false grammar. i'm from sweden so my english is not that good.

#2 wieselkatze

  • Members
  • 221 posts
  • LocationGermany

Posted 25 February 2014 - 01:36 PM

You could just store them in actual files and load them after restart; that should be the easiest way.

For example your count is "count" and equals 10.
Then you could store this in a file:

count = 10
f = fs.open("mobspawn", "w")
f.writeLine(count)
f.close()

at the top op the program you just have to put

f = fs.open("mobspawn", "r")
count = tonumber(f.readLine())
f.close()

That should be it. (Not tested)

#3 Dahknee

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

Posted 25 February 2014 - 11:26 PM

You could use an config file.... I have an API that you're welcome to use, the syntax is:
os.loadAPI("uapi")
-- intCount being the number of drops
uapi.saveConfig({['count']=intCount}, ".config") -- will save it
-- on boot use:
local config = uapi.loadConfig(".Config")
count = config.count

then use count as the number, you can make it write the new number every time (using loops, or add it as part of a function/corountine)

To get it use the retriever (use the following command in terminal):

pastebin get rTDR0tjx uretrieve

then run it by typing 'uretrieve' (without quotes)

Post:
http://www.computerc...__fromsearch__1

Hope this helps!
Danny!

Edited by DannySMc, 25 February 2014 - 11:28 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users