Forum

> > Off Topic > Lua: Not cs2d lua.
ForenübersichtOff Topic-ÜbersichtEinloggen, um zu antworten

Englisch Lua: Not cs2d lua.

15 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Lua: Not cs2d lua.

Glix
User Off Offline

Zitieren
Guys i want to know did i all ok?
1
2
3
4
5
6
7
8
9
10
11
12
13
function fibo()
  a, b = 0, 1
  while true do
    coroutine.yield(a)
    a, b = b, a + b
  end
end

co = coroutine.create(fibo)

for i = 1, 20 do
  print(coroutine.resume(co))
end

and i got for that this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
1× editiert, zuletzt 25.01.12 17:44:14

alt Re: Lua: Not cs2d lua.

Glix
User Off Offline

Zitieren
@user DannyDeth: thx for info, but what wrong is with this?. ( I'm learning lua)

1
2
3
io.write("Enter your name: ")
name = io.read()
print("Hello, ".. name);

alt Re: Lua: Not cs2d lua.

Glix
User Off Offline

Zitieren
Guys what wrong with this please answer fastly... I nee your help
1
io.write("Enter your age man: "); age = io.read(); print("You are " .. age .. "Old!")
4× editiert, zuletzt 25.01.12 16:54:33

alt Re: Lua: Not cs2d lua.

Banaan
User Off Offline

Zitieren
CS2D doesn't send any data to stdin (which you are trying to receive using io.read()). Where should the data be coming from? From the console? In that case you should use the cs2d lua hook parse hook to retrieve any entered data.

So for this to work, you should run it through the standard Lua interpreter you installed (lua.exe).

alt Re: Lua: Not cs2d lua.

Glix
User Off Offline

Zitieren
Guys this is not from cs2d lua it from normal lua. I am learning it and need your help.

alt Re: Lua: Not cs2d lua.

Kel9290
User Off Offline

Zitieren
1
2
3
4
io.write("Print your name:")
-- you are printing it here
name = io.read()
print("Hello, "..name)

alt Re: Lua: Not cs2d lua.

Glix
User Off Offline

Zitieren
Thanx kel.. can you help me with this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
io.write("Enter a message: ")
userinput = io.read()

if userinput == "hi" then
	print("Well howdy there!")
elseif userinput == "bye" then
	print("Goodbye!")
elseif userinput == "hello" then
	print("Hi")
elseif userinput == "Hu" then
	print("Spelling error much?")
else
	print("I don't understand you. Sorry.")
end

alt Re: Lua: Not cs2d lua.

Kel9290
User Off Offline

Zitieren
just create new .txt file, copy your script in this file, then rename it to <anynamehere>.lua. Select your .lua and drag & drop on lua.exe.

also, put io.read() at end if you don't want window close after writing a text.

alt Re: Lua: Not cs2d lua.

Glix
User Off Offline

Zitieren
[command]io.write("Enter a message: ")
userinput = io.read()

if userinput == "hi" then
print("Well howdy there!")
elseif userinput == "bye" then
print("Goodbye!")
elseif userinput == "hello" then
print("Hi")
elseif userinput == "Hu" then
print("Spelling error much?")
else
print("I don't understand you. Sorry.")
end[/command]

How i can make that like when you say hi. It prints tho print("Well howdy there!") then it returns again says enter msg.

alt Re: Lua: Not cs2d lua.

Alistaire
User Off Offline

Zitieren
Your script reminds me of my tries to make a .vb script.

Good times. Posting it in the startup shit of my school's computer. From my friends account.

Good times.

alt Re: Lua: Not cs2d lua.

Banaan
User Off Offline

Zitieren
Put it in a never-ending while loop:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
while true do
	io.write("Enter a message: ")
	userinput = io.read()

	if userinput == "hi" then
		print("Well howdy there!")
	elseif userinput == "bye" then
		print("Goodbye!")
	elseif userinput == "hello" then
		print("Hi")
	elseif userinput == "Hu" then
		print("Spelling error much?")
	else
		print("I don't understand you. Sorry.")
	end
end

After printing a reply to the user input, this will return to the start where you enter a message.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antwortenOff Topic-ÜbersichtForenübersicht