Forum

> > CS2D > Scripts > Learning Scripting, asking for assistance/teacher
Forums overviewCS2D overview Scripts overviewLog in to reply

English Learning Scripting, asking for assistance/teacher

17 replies
To the start Previous 1 Next To the start

old Learning Scripting, asking for assistance/teacher

SkullzOrig
User Off Offline

Quote
I was in the middle of starting to learn scripting(I have been starting since(estimated time) 4:45(I know timezones are different, so for those of you it was(remember I said time was estimated) 50 minutes ago, taking a break as of now. When I was doing a exercise, I then got stopped by a question, "How do you compute 2 to the 16th power?". Any idea on how? I need help on learning. I would appreciate the help.
Spoiler >
edited 1×, last 19.05.12 03:09:42 am

old Re: Learning Scripting, asking for assistance/teacher

SkullzOrig
User Off Offline

Quote
I had seen print("2^16")
I just want to make sure I do everything right, I have noticed that debuggers do not really clearify the point in the script where the bug/mistake is at.

cookie for @user Apache uwu: For always helping me with problems. I vote Ketamire for Moderator, I think you have uploaded really awesome scripts. You are also very helpful and positive with others.

old Re: Learning Scripting, asking for assistance/teacher

Apache uwu
User Off Offline

Quote
Generally the lua debugger will give the correct line if it's only a 1 line syntax error.

However if you have many if wrappers and you forget to finish one, it might give you some funky numbers.

Unfinished quotes, brackets, or braces are the easiest to debug simply because lua will show the exact or line-1 or line+1 where the error happened.

old Re: Learning Scripting, asking for assistance/teacher

Devil-Thanh
GAME BANNED Off Offline

Quote
SkullzOrig has written
Oh, the braces seemed to be easier. Especially in the items file of CS2D Tibia. I was working on a script a few minutes ago. But I have encoutered a problem, I am scared to upload images of what was goin on.


Open console and coppy the red lines(ERROR lines) so we can help you.

old Re: Learning Scripting, asking for assistance/teacher

EngiN33R
Moderator Off Offline

Quote
Indeed, the debugger often doesn't show the line the error was caused on, but rather the last line the error directly influenced, sadly. Still, this is an easy task, so if there are errors - we'll be able to pinpoint them with ease, you'd just have to specify the line the error was encountered on.

Also, print("2^16") and print(2^16) are two very different things. The former prints just 2^16 and the latter prints 65536.

old Re: Learning Scripting, asking for assistance/teacher

SkullzOrig
User Off Offline

Quote
So if I type print("2^16") -- That will display 2^16
And typing print(2^16) -- That will perform a funtion

So when a type anything inbetween the quotions, that will be displayed?

For example

space = " "
text = ("Welcome to my server!" .. space .. "Do not hack")
print(text)

Will this work?

old Re: Learning Scripting, asking for assistance/teacher

Alistaire
User Off Offline

Quote
user SkullzOrig has written
So if I type print("2^16") -- That will display 2^16
And typing print(2^16) -- That will perform a funtion

So when a type anything inbetween the quotions, that will be displayed?

For example

space = " "
text = ("Welcome to my server!" .. space .. "Do not hack")
print(text)

Will this work?


That prints

>Welcome to my server! Do not hack

old Re: Learning Scripting, asking for assistance/teacher

Alistaire
User Off Offline

Quote
That addhook is crap, it wouldn't work.

Addhook is a way to add functions to e.g chat.

1
2
3
4
5
6
7
addhook('say', 'sayhook')

function sayhook(id, txt)
	if txt == '!give scout' then
		parse('equip '..id..' 34')
	end
end

Also, print() only returns the value to the CS2D console. It doesn't have any effect on the script, if it's used correctly (no nil values).

print() is used to see if a value returns any errors in the script, to check if anything is wrong (when you think there is).

old Re: Learning Scripting, asking for assistance/teacher

EngiN33R
Moderator Off Offline

Quote
You said you needed to learn what variables, strings, tables and functions were. I've written a quick explanation with examples below. It's quite messy, sorry, but I think you'll be able to understand it and learn something from it.

Tutorial >


Explanation of hooks:
Hooks tutorial >


@user Alistaire: He's learning, insulting him or what he's trying to make doesn't help.

old Re: Learning Scripting, asking for assistance/teacher

omg
User Off Offline

Quote
not sure this applies to anyone, but if u know some more common programming languages like java, c, or python...

code relations >


fun fact: arrays and tables are really just static (usually) joined (in memory) pointers. attempting to "use" an array may end up returning the first memory address of the array like in engineers huge blocks of tutorial (
-- You can't print the table variable itself:
print(tbl) -> table: 0049A640
-- You can, however, print its indices:
print(tbl[1]) -> 1
print(tbl[2]) -> 2
)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview