Welcome, Guest |
You have to register before you can post on our site.
|
Forum Statistics |
» Members: 8,079
» Latest member: seanac11
» Forum threads: 10,350
» Forum posts: 91,276
Full Statistics
|
Online Users |
There are currently 232 online users. » 0 Member(s) | 230 Guest(s) Bing, Google
|
Latest Threads |
I'm leaving the site too....
Forum: 2DWorlds Discussion
Last Post: Jacob_
07-03-2023, 04:59 AM
» Replies: 12
» Views: 6,012
|
hi there.
Forum: 2DWorlds Discussion
Last Post: Jacob_
01-03-2020, 04:30 AM
» Replies: 1
» Views: 694
|
obroke
Forum: Current Games
Last Post: FrancisSah
09-06-2017, 10:11 AM
» Replies: 0
» Views: 20,500
|
fcouldn't
Forum: Current Games
Last Post: FrancisSah
09-06-2017, 09:02 AM
» Replies: 0
» Views: 8,206
|
qhow
Forum: Current Games
Last Post: PhilipShums
09-06-2017, 07:25 AM
» Replies: 0
» Views: 2,075
|
zstone
Forum: Current Games
Last Post: TimothyTox
09-06-2017, 07:03 AM
» Replies: 0
» Views: 954
|
vbit
Forum: Current Games
Last Post: FrancisSah
09-06-2017, 03:00 AM
» Replies: 0
» Views: 931
|
sildenafil 100 mg sandoz
Forum: Current Games
Last Post: RichardLen
09-06-2017, 12:28 AM
» Replies: 0
» Views: 1,139
|
mhis
Forum: Current Games
Last Post: TimothyTox
09-05-2017, 04:09 PM
» Replies: 0
» Views: 952
|
sildenafil citrate 100mg ...
Forum: Current Games
Last Post: Waltertog
09-05-2017, 12:27 PM
» Replies: 0
» Views: 910
|
|
|
[TUT] Beginning 2DWorlds Lua Scripting |
Posted by: DysLabs - 03-19-2013, 12:43 AM - Forum: Help
- Replies (6)
|
 |
Hello. This is an introduction to 2DWorlds Lua Scripting. In no way is this complete, and suggestions, questions, and feedback is welcome.
Part 1: Beginner
Chapter 1: Identifiers and Properties
Lua is like a tree. At the top is the root object (called 'game' in your scripts) ans then the services, ad then the objects inside the services. In Lua, you navigate this tree with .'s (dots).
For example, this code will kill you.
[lua]
game.World.[YOURNAMEHERE].Health=0
[/lua]
If you replace '[YOURNAMEHERE]' with your in-game name.
For example, I would put
[lua]
game.World.DysLabs.Health=0
[/lua]
In order to run this, you can either put it in a script and run it, or you can type it in the Lua console. Be sure to add your character first or it won't work.
As you can see 'game.World.DysLabs.Health' is the identifier, '=' is the operator, and '0' is the value. It's kind of like a math problem. You can set any property in any object, see the wiki for properties that an object has.
You can also create your own identifiers. In this case, they will be called variables. You assign them the same way. However, they can only contain 0-9, a-Z, and underscores. The scope is also important, but we will get to the later.
Functions
(now you will actually need to write a script, the Lua console won't work here)
Sometimes, you will reuse the same code over and over, and you might want to compress it into single statements. Now you can. Introducing functions.
Here's how you would create a function:
[lua]
function example()
--do stuff
end
[/lua]
(btw, a line that begins with '--' is a comment in Lua and is ignored)
So lets say we wanted to make multiple countdowns.
You could do:
[lua]
start=10
repeat
print(start)
sleep(1)
start-1
until
start==0
-- Next countdown --
[/lua]
(note: this code is untested. I'm not sure if there is a repeat... until loop in 2DWorlds)
But with functions, this could be simplified to:
[lua]
function countdown(start)
repeat
print start
start=start-1
sleep(1)
until start==0
end
countdown(10)
countdown(9)
countdown(8)
-- etc--
[/lua]
Now notice the word 'start' in the parenthesis in the function definition and the call. This can be any number of values, as long as they are valid identifiers. They are called 'parameters.' You define them like so:
[lua]
function newprint(msg)
print("HI U OK: "..msg)
end
[/lua]
(hint: '..' is the string concentration symbol in Lua. It is used to combine strings with other data types.)
and that concludes our section on functions.
Not Really A Chapter (Creating Scripts)
To insert a script, go to Edit > Insert
Click on 'Script' and click Ok.
Now, in the explorer to the left, expand World (if it isn't already) and find 'Script'
Double click it.
You can now edit it.
Due to a bug, you will need to right-click and hut run to test the script after its initial run (right after its created)
Variables
-- End of written tutorial --
|
|
|
Oak's Enormously Stupid Blog of Poo |
Posted by: Oak - 03-18-2013, 10:39 PM - Forum: Blog
- Replies (6)
|
 |
3-18-13
Woke up in the morning, had a normal and boring day at school. Came home, had Mexican food which was delicious for dinner. Finished dinner, did my homework, took a shower. Came on the computer. And now I'm here.
|
|
|
2DWorlds Interviews with OAK #1 |
Posted by: Oak - 03-18-2013, 10:32 PM - Forum: 2DWorlds Discussion
- Replies (6)
|
 |
Today I will be interviewing Myem. A legendary player who has contributed to our famous meme collection. His most prominent meme is "Fuck you" and "Jews did 9/11". All of you please stand up and give him a round of applause. I now present you, Myem. Be warned, 80% of what he says is not true.
And the interview begins.
Enjoy.
1.) What led you to join 2DWorlds/Buildism?
Myem: Several ROBLOX raid threads.
2.) What do you like the most about the site?
Myem: The forums and the community.
3.) What people have you met on the site whom you are friends with from this day?
Myem: No one. Everyone who was once a friend of mine was sent into a FEMA concentration camp for browsing the site unprotected. I suspect that their corpses might've been decaying in their burial ground for many months by now.
4.) Have you learnt anything from your experience on here?
Myem: Yes, I have. What I've learned is that Ghosty is nearly everything I despise about people.
5.) Do you regret spending a handful amount of time on the site with us?
Myem: I don't regret anything about being on here at all.
6.) What is the funniest moment you've been through with us?
Myem: When Jacob_ called the Illuminati to kill all of us but I was smart enough to use 7 proxies.
7.) How old are you?
Myem: 14
8.) What is your mothers maiden name?
Myem: ygobfyebgfayobgeyhbghyebgfaefgaiybgfiybgfsabisaeofbsabff
9.) Are you married?
Myem: Married to the forums and Jacob_, yes. Jacob_'s still tsundere with me tough.
10.) Are you related to Ghosty somehow?
Myem: Aren't we all related?
11.) This is the dumbest question because it isn't a question.
Myem: Fuck you.
Thanks for participating in Oak's FIRST 2DWorlds interview!
UP NEXT..
OAK MEETS THE FOUNDER AND CREATOR OF THIS MASTERPIECE SITE
|
|
|
|