Forum

> > CS2D > Scripts > create file
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch create file

12 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Re: create file

TimeQuesT
User Off Offline

Zitieren
please describe better your problem. there are many ways to create one. Or do you mean in "lua" ?

alt Re: create file

Banaan
User Off Offline

Zitieren
1
2
3
local file = io.open("my.file", "w")
file:write("This is my file")
file:close()

This would create a file and write This is my file to it. You should make sure you have write rights in the folder though.

alt Re: create file

J4x
User Off Offline

Zitieren
Yeah it's about lua.

Well, there are several forms, but this is the one i use.
>Go to the folder where u like to create your lua, then press rigght click -> new -> text document.

> then change all the name to THE_NAME THAT YOU WANT.lua, it will ask you if you are shure to change the extention, just press yes. YAY! we have our lua file

EDIT: LOL, i was thinking you want to cretae a .lua file

alt Re: create file

EnderCrypt
User Off Offline

Zitieren
What you are saying makes no sense... Im confiused
just, how do i make it create a file io.open gives nil when file doesent exist

alt Re: create file

DannyDeth
User Off Offline

Zitieren
@Banaan & pheangsri:
The reason this code is not working is because you are not opening it with the right rights or the file does not exist.

Well that is what I remember. But yeah, give more details about the error message.

alt Re: create file

Banaan
User Off Offline

Zitieren
That's what I said: rights. If a file does not exist, it will automatically be created (as long as you use a write mode).

The exact code below creates a file called my.file with This is my file as contents on my Ubuntu 10.10. So the problem must lie within your system configuration.

You should try using the assert function for an error report:
1
local file = assert(io.open("my.file", "w"))
Tell us which error it raises.

alt Re: create file

DannyDeth
User Off Offline

Zitieren
@Banaan:
Hmmm, it must be PHP then. I started learning them right about the same time, so I might of confused some stuff around But yeah, I thought it was w+ that made a file if it was non-existent

alt Re: create file

EnderCrypt
User Off Offline

Zitieren
LUA ERROR: sys/lua/fy_knife_arena_lua.lua:715: sys/lua/exp_data_backup/backup 1299318034.txt: No such file or directory

maybe its cause im missing a folder, i was tinking it would create it?

alt Re: create file

DannyDeth
User Off Offline

Zitieren
You cannot create directories ( folders in Windows User Language )! Only files!

alt Re: create file

EnderCrypt
User Off Offline

Zitieren
thx then i just create folder and done

edit: yeah working now, thx
1× editiert, zuletzt 05.03.11 12:03:20
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht