Forum

> > Off Topic > Lua: Not cs2d lua.
Forums overviewOff Topic overviewLog in to reply

English Lua: Not cs2d lua.

15 replies
To the start Previous 1 Next To the start

old Lua: Not cs2d lua.

Glix
User Off Offline

Quote
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
edited 1×, last 25.01.12 05:44:14 pm

old Re: Lua: Not cs2d lua.

Glix
User Off Offline

Quote
@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);

old Re: Lua: Not cs2d lua.

Glix
User Off Offline

Quote
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!")
edited 4×, last 25.01.12 04:54:33 pm

old Re: Lua: Not cs2d lua.

Banaan
User Off Offline

Quote
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).

old Re: Lua: Not cs2d lua.

Glix
User Off Offline

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

old Re: Lua: Not cs2d lua.

Kel9290
User Off Offline

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

old Re: Lua: Not cs2d lua.

Glix
User Off Offline

Quote
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

old Re: Lua: Not cs2d lua.

Kel9290
User Off Offline

Quote
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.

old Re: Lua: Not cs2d lua.

Glix
User Off Offline

Quote
[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.

old Re: Lua: Not cs2d lua.

Alistaire
User Off Offline

Quote
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.

old Re: Lua: Not cs2d lua.

Banaan
User Off Offline

Quote
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.
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview