Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 07:17:11 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Python as a scripting language?
Pages: 1 [2]
Print
Author Topic: Python as a scripting language?  (Read 2773 times)
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #20 on: May 19, 2015, 12:13:36 PM »

So, a typical script right now would be: https://gist.github.com/Lavesson/5979de218cdb4eb7714a
.. And the result would look like this:



An admittedly simplistic implementation - I would probably make completely different architecture decisions if I wanted to something a bit more advanced.
So I appreciate you were aiming for something simple, but I mention for the sake of other readers that you are missing out the (imho) number one best feature of Lua - co-routines.

It's entirely possible to write that script as straight function calls;
Code:
player.hide()
player.lock()
sleep(1)
effect.screenShake()
dialog.say(...)
etc
where the Lua interpreter suspends/resumes the script while waiting for delays and user actions. This isn't possible in any of the other language choices.
Logged
Ky.
Level 0
***


Programmer & Web Slinger


View Profile WWW
« Reply #21 on: May 22, 2015, 12:09:29 PM »

I didn't see anyone mention it here, but throwing Squirrel into fray

Code:
local table = {
a = "10"
subtable = {
array = [1,2,3]
},
[10 + 123] = "expression index"
}
 
local array=[ 1, 2, 3, { a = 10, b = "string" } ];
 
foreach (i,val in array)
{
::print("the type of val is"+typeof val);
}
 
/////////////////////////////////////////////
 
class Entity
{
constructor(etype,entityname)
{
name = entityname;
type = etype;
}

x = 0;
y = 0;
z = 0;
name = null;
type = null;
}
 
function Entity::MoveTo(newx,newy,newz)
{
x = newx;
y = newy;
z = newz;
}
 
class Player extends Entity {
constructor(entityname)
{
base.constructor("Player",entityname)
}
function DoDomething()
{
::print("something");
}

}
 
local newplayer = Player("da playar");
 
newplayer.MoveTo(100,200,300);
Logged

Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic