SlideShare uma empresa Scribd logo
1 de 19
Lua in Games



               Mr. Nguyễn Ngọc Vân
      Ass Software Manager – VNG Corporation
Agenda

1.   Lua & Benefits
2.   Core engine & Lua model
3.   Lua integrations model
4.   Secure Lua code
5.   Disadvantages
1. Lua & Benefits
What’s Lua?
•   Scripting language
•   Works through LVM (Lua Virtual Machine)
•   Stack model design
•   “Ultimate game scripting language” (GDC 2010)
•   Popular uses in games
•   Runs on most machines and devices
•   Written in ANSI C and distributed by small library
Lua Benefits
•   Free and open source 
•   Support OOP
•   Runs on almost platforms
•   Easy to interface with C/C++
•   Very clean C API
•   Auto memory management (GC)
•   Powerful, fast and lightweight
•   Flexible data structure (TABLE)
Lua Benefits

•   Contents can be changed in real-time
•   Auto generate contents
•   Users can customize/change contents
•   Fast and easy distributed contents
•   Secure code
•   Easy to use, embed and learn
•   Good references
2. Core Engine & Lua Model
Configs        Control Flow
  Settings
(XML, INI, T   Game Logic Process
   XT, …)       (Behaviors, AI, …)

                  Core Engine
Configs
  Settings
 (…, LUA)
              Control Flow
              Lua Engine
 LUA Logic
  Process
(Behaviors,    Core Engine
  AI, …)
3. Lua Integrations Model
Lua APIs
 Lua     Core Logic                     Lua Engine
codes   (Logic Flow)                      (LVM)
                        Lua interface


                       Core Engine
• Lua APIs
  – Call to LVM through events/triggers base
  – C APIs to work with LVM
  – Auxiliary library provides basic functions to
    check, register, debug, … LVM
  – Use C APIs to build core functions
• Lua Interface
  – Call to core logic through exports APIs
  – Provides APIs (game APIs) to work with core logic
  – Use C APIs to build, register, and exports APIs
Quick Sample
function OnPlayerUseItem(nItem)
        core.InstanceObj(OBJ_KIND_ITEM, nItem)
        if item.GetKind() == ITM_KIND_HP then
                local nItemHP = item.GetAttribute(ITM_ATTR_HP)
                local nPlayerHP = player.GetCurrentHP()
                local nAddHP = 0.2 * nPlayerHP
                if nAddHP > 0 and nAddHP < player.GetMaxHP() then
                        player.SetCurrentHP(nAddHP)
                        player.Message('Player:
'..player.GetName()..' use item '..item.GetName())
                end
        end
end
4. Secure Lua Code
• Compile to byte-code
  – Popular use
  – Use luaC module included in library
  – Modify luaC with keys for more secure
• Encrypted
  – Little use
  – Use keys-pair to encrypted
  – Use signed file, CRC
• Simple code
  function Add(a, b)
     return a + b
  end
  print(Add(100, 200))

• Byte-code
5. Disadvantages
• C APIs are too low-level
• Error messages are very confusing 
• No try-catch, no exceptions
• Hard to debug
• Hard to interfaces with unlike C/C++
• Once LVM is crashed, it’s not likely to recover and the
  service is crashed too 
• Hard to implement reload feature at run-time
• For extreme speed, LuaJIT is a good choice 
Benefits/tutorial of Lua in games

Mais conteúdo relacionado

Mais procurados

Setting up a local WordPress development environment
Setting up a local WordPress development environmentSetting up a local WordPress development environment
Setting up a local WordPress development environmentZero Point Development
 
Intro to Massively Multiplayer Online Game (MMOG) Design
Intro to Massively Multiplayer Online Game (MMOG) DesignIntro to Massively Multiplayer Online Game (MMOG) Design
Intro to Massively Multiplayer Online Game (MMOG) DesignChristopher Mohritz
 
Highly available Drupal on a Raspberry Pi cluster
Highly available Drupal on a Raspberry Pi clusterHighly available Drupal on a Raspberry Pi cluster
Highly available Drupal on a Raspberry Pi clusterJeff Geerling
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Simplilearn
 
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016Dylan Butler
 
Open Cloud BBQ - Nano Server
Open Cloud BBQ - Nano ServerOpen Cloud BBQ - Nano Server
Open Cloud BBQ - Nano ServerTomica Kaniski
 
MMO Design Architecture by Andrew
MMO Design Architecture by AndrewMMO Design Architecture by Andrew
MMO Design Architecture by AndrewAgate Studio
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance DrupalJeff Geerling
 
Empowering developers to deploy their own data stores
Empowering developers to deploy their own data storesEmpowering developers to deploy their own data stores
Empowering developers to deploy their own data storesTomas Doran
 
OGDC2012 A Practical Architecture Design For MMO Casual Game_Mr. An, Ngo Thai
OGDC2012 A Practical Architecture Design For MMO Casual Game_Mr. An, Ngo ThaiOGDC2012 A Practical Architecture Design For MMO Casual Game_Mr. An, Ngo Thai
OGDC2012 A Practical Architecture Design For MMO Casual Game_Mr. An, Ngo ThaiBuff Nguyen
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...Sencha
 
Aos canadian tour (YOW) @energizedtech - Manage AzureRM with powershell
Aos canadian tour (YOW)  @energizedtech - Manage AzureRM with powershellAos canadian tour (YOW)  @energizedtech - Manage AzureRM with powershell
Aos canadian tour (YOW) @energizedtech - Manage AzureRM with powershellSean Kearney
 
Building a World in the Clouds: MMO Architecture on AWS (MBL304) | AWS re:Inv...
Building a World in the Clouds: MMO Architecture on AWS (MBL304) | AWS re:Inv...Building a World in the Clouds: MMO Architecture on AWS (MBL304) | AWS re:Inv...
Building a World in the Clouds: MMO Architecture on AWS (MBL304) | AWS re:Inv...Amazon Web Services
 

Mais procurados (18)

Setting up a local WordPress development environment
Setting up a local WordPress development environmentSetting up a local WordPress development environment
Setting up a local WordPress development environment
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
 
Intro to Massively Multiplayer Online Game (MMOG) Design
Intro to Massively Multiplayer Online Game (MMOG) DesignIntro to Massively Multiplayer Online Game (MMOG) Design
Intro to Massively Multiplayer Online Game (MMOG) Design
 
CUDA vs OpenCL
CUDA vs OpenCLCUDA vs OpenCL
CUDA vs OpenCL
 
Highly available Drupal on a Raspberry Pi cluster
Highly available Drupal on a Raspberry Pi clusterHighly available Drupal on a Raspberry Pi cluster
Highly available Drupal on a Raspberry Pi cluster
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
 
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
 
Open Cloud BBQ - Nano Server
Open Cloud BBQ - Nano ServerOpen Cloud BBQ - Nano Server
Open Cloud BBQ - Nano Server
 
MMO Design Architecture by Andrew
MMO Design Architecture by AndrewMMO Design Architecture by Andrew
MMO Design Architecture by Andrew
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance Drupal
 
Empowering developers to deploy their own data stores
Empowering developers to deploy their own data storesEmpowering developers to deploy their own data stores
Empowering developers to deploy their own data stores
 
OGDC2012 A Practical Architecture Design For MMO Casual Game_Mr. An, Ngo Thai
OGDC2012 A Practical Architecture Design For MMO Casual Game_Mr. An, Ngo ThaiOGDC2012 A Practical Architecture Design For MMO Casual Game_Mr. An, Ngo Thai
OGDC2012 A Practical Architecture Design For MMO Casual Game_Mr. An, Ngo Thai
 
Nano Server (ATD 11)
Nano Server (ATD 11)Nano Server (ATD 11)
Nano Server (ATD 11)
 
Extending ansible
Extending ansibleExtending ansible
Extending ansible
 
Introduction to AJAX
Introduction to AJAXIntroduction to AJAX
Introduction to AJAX
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
 
Aos canadian tour (YOW) @energizedtech - Manage AzureRM with powershell
Aos canadian tour (YOW)  @energizedtech - Manage AzureRM with powershellAos canadian tour (YOW)  @energizedtech - Manage AzureRM with powershell
Aos canadian tour (YOW) @energizedtech - Manage AzureRM with powershell
 
Building a World in the Clouds: MMO Architecture on AWS (MBL304) | AWS re:Inv...
Building a World in the Clouds: MMO Architecture on AWS (MBL304) | AWS re:Inv...Building a World in the Clouds: MMO Architecture on AWS (MBL304) | AWS re:Inv...
Building a World in the Clouds: MMO Architecture on AWS (MBL304) | AWS re:Inv...
 

Semelhante a Benefits/tutorial of Lua in games

Lua in games
Lua in gamesLua in games
Lua in gamesSon Aris
 
Lua in Games
Lua in GamesLua in Games
Lua in Gameswe20
 
Apache Traffic Server & Lua
Apache Traffic Server & LuaApache Traffic Server & Lua
Apache Traffic Server & LuaKit Chan
 
High-Performance Computing with C++
High-Performance Computing with C++High-Performance Computing with C++
High-Performance Computing with C++JetBrains
 
Hkube
HkubeHkube
Hkubehkube
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileAmazon Web Services Japan
 
Exploiting NoSQL Like Never Before
Exploiting NoSQL Like Never BeforeExploiting NoSQL Like Never Before
Exploiting NoSQL Like Never BeforeFrancis Alexander
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeDmitri Nesteruk
 
Hot to build continuously processing for 24/7 real-time data streaming platform?
Hot to build continuously processing for 24/7 real-time data streaming platform?Hot to build continuously processing for 24/7 real-time data streaming platform?
Hot to build continuously processing for 24/7 real-time data streaming platform?GetInData
 
.Net overviewrajnish
.Net overviewrajnish.Net overviewrajnish
.Net overviewrajnishRajnish Kalla
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayLuka Zakrajšek
 
ApacheCon NA 2010 - High Performance Cloud-enabled SCA Runtimes
ApacheCon NA 2010 - High Performance Cloud-enabled SCA RuntimesApacheCon NA 2010 - High Performance Cloud-enabled SCA Runtimes
ApacheCon NA 2010 - High Performance Cloud-enabled SCA RuntimesJean-Sebastien Delfino
 
Using LuaJIT in mid-load web-projects
Using LuaJIT in mid-load web-projectsUsing LuaJIT in mid-load web-projects
Using LuaJIT in mid-load web-projectsAlexander Gladysh
 
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...gree_tech
 
Near real-time anomaly detection at Lyft
Near real-time anomaly detection at LyftNear real-time anomaly detection at Lyft
Near real-time anomaly detection at Lyftmarkgrover
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Yuta Iwama
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangLyon Yang
 
[Intuit] Control Everything
[Intuit] Control Everything[Intuit] Control Everything
[Intuit] Control EverythingPerforce
 

Semelhante a Benefits/tutorial of Lua in games (20)

Lua in games
Lua in gamesLua in games
Lua in games
 
Lua in Games
Lua in GamesLua in Games
Lua in Games
 
Apache Traffic Server & Lua
Apache Traffic Server & LuaApache Traffic Server & Lua
Apache Traffic Server & Lua
 
High-Performance Computing with C++
High-Performance Computing with C++High-Performance Computing with C++
High-Performance Computing with C++
 
Hkube
HkubeHkube
Hkube
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
Exploiting NoSQL Like Never Before
Exploiting NoSQL Like Never BeforeExploiting NoSQL Like Never Before
Exploiting NoSQL Like Never Before
 
01 java intro
01 java intro01 java intro
01 java intro
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
 
Hot to build continuously processing for 24/7 real-time data streaming platform?
Hot to build continuously processing for 24/7 real-time data streaming platform?Hot to build continuously processing for 24/7 real-time data streaming platform?
Hot to build continuously processing for 24/7 real-time data streaming platform?
 
.Net overviewrajnish
.Net overviewrajnish.Net overviewrajnish
.Net overviewrajnish
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and Play
 
ApacheCon NA 2010 - High Performance Cloud-enabled SCA Runtimes
ApacheCon NA 2010 - High Performance Cloud-enabled SCA RuntimesApacheCon NA 2010 - High Performance Cloud-enabled SCA Runtimes
ApacheCon NA 2010 - High Performance Cloud-enabled SCA Runtimes
 
Using LuaJIT in mid-load web-projects
Using LuaJIT in mid-load web-projectsUsing LuaJIT in mid-load web-projects
Using LuaJIT in mid-load web-projects
 
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
 
Near real-time anomaly detection at Lyft
Near real-time anomaly detection at LyftNear real-time anomaly detection at Lyft
Near real-time anomaly detection at Lyft
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
 
PyData Boston 2013
PyData Boston 2013PyData Boston 2013
PyData Boston 2013
 
[Intuit] Control Everything
[Intuit] Control Everything[Intuit] Control Everything
[Intuit] Control Everything
 

Mais de action.vn

Bao cao tai nguyen Internet VN 2013
Bao cao tai nguyen Internet VN 2013Bao cao tai nguyen Internet VN 2013
Bao cao tai nguyen Internet VN 2013action.vn
 
ComScore - Southeast Asia Digital Future in Focus 2013
ComScore - Southeast Asia Digital Future in Focus 2013ComScore - Southeast Asia Digital Future in Focus 2013
ComScore - Southeast Asia Digital Future in Focus 2013action.vn
 
comScore's Presentation Google's Think Digital Vietnam 11-Dec-2012
comScore's Presentation Google's Think Digital Vietnam 11-Dec-2012comScore's Presentation Google's Think Digital Vietnam 11-Dec-2012
comScore's Presentation Google's Think Digital Vietnam 11-Dec-2012action.vn
 
Toan canh thuong mai dien tu 2012
Toan canh thuong mai dien tu 2012Toan canh thuong mai dien tu 2012
Toan canh thuong mai dien tu 2012action.vn
 
White book 2012 - Các vấn đề thương mại/đầu tư và kiến nghị
White book 2012 - Các vấn đề thương mại/đầu tư và kiến nghịWhite book 2012 - Các vấn đề thương mại/đầu tư và kiến nghị
White book 2012 - Các vấn đề thương mại/đầu tư và kiến nghịaction.vn
 
Amazon Annual Report
Amazon Annual ReportAmazon Annual Report
Amazon Annual Reportaction.vn
 
HIGH IMPACT ENTREPRENEURS
HIGH IMPACT ENTREPRENEURSHIGH IMPACT ENTREPRENEURS
HIGH IMPACT ENTREPRENEURSaction.vn
 
Bao cao EBI TMDT 2012
Bao cao EBI TMDT 2012Bao cao EBI TMDT 2012
Bao cao EBI TMDT 2012action.vn
 
VC-Corp Intro
VC-Corp IntroVC-Corp Intro
VC-Corp Introaction.vn
 
Mobile Trends: Cơ hội còn bỏ ngỏ
Mobile Trends: Cơ hội còn bỏ ngỏMobile Trends: Cơ hội còn bỏ ngỏ
Mobile Trends: Cơ hội còn bỏ ngỏaction.vn
 
Mobile VAS market in Vietnam
Mobile VAS market in VietnamMobile VAS market in Vietnam
Mobile VAS market in Vietnamaction.vn
 
Vietnam’s Web in 2012
Vietnam’s Web in 2012Vietnam’s Web in 2012
Vietnam’s Web in 2012action.vn
 
Mạng quảng cáo gia tăng hiệu quả cho quảng cáo hiển thị
Mạng quảng cáo gia tăng hiệu quả cho quảng cáo hiển thịMạng quảng cáo gia tăng hiệu quả cho quảng cáo hiển thị
Mạng quảng cáo gia tăng hiệu quả cho quảng cáo hiển thịaction.vn
 
IDC Q3 2012 Mobile Developer Report
IDC Q3 2012 Mobile Developer ReportIDC Q3 2012 Mobile Developer Report
IDC Q3 2012 Mobile Developer Reportaction.vn
 
Why not to do a startup?
Why not to do a startup?Why not to do a startup?
Why not to do a startup?action.vn
 
Mobiles share of the mix marketing evolution
Mobiles share of the mix marketing evolutionMobiles share of the mix marketing evolution
Mobiles share of the mix marketing evolutionaction.vn
 
Khảo sát lứa tuổi Teen Việt Nam 2012
Khảo sát lứa tuổi Teen Việt Nam 2012Khảo sát lứa tuổi Teen Việt Nam 2012
Khảo sát lứa tuổi Teen Việt Nam 2012action.vn
 
Creative design for mobile social game
Creative design for mobile social gameCreative design for mobile social game
Creative design for mobile social gameaction.vn
 
Balance in SNS by Energy
Balance in SNS by EnergyBalance in SNS by Energy
Balance in SNS by Energyaction.vn
 
Training and developing human resources in a game studio
Training and developing human resources in a game studioTraining and developing human resources in a game studio
Training and developing human resources in a game studioaction.vn
 

Mais de action.vn (20)

Bao cao tai nguyen Internet VN 2013
Bao cao tai nguyen Internet VN 2013Bao cao tai nguyen Internet VN 2013
Bao cao tai nguyen Internet VN 2013
 
ComScore - Southeast Asia Digital Future in Focus 2013
ComScore - Southeast Asia Digital Future in Focus 2013ComScore - Southeast Asia Digital Future in Focus 2013
ComScore - Southeast Asia Digital Future in Focus 2013
 
comScore's Presentation Google's Think Digital Vietnam 11-Dec-2012
comScore's Presentation Google's Think Digital Vietnam 11-Dec-2012comScore's Presentation Google's Think Digital Vietnam 11-Dec-2012
comScore's Presentation Google's Think Digital Vietnam 11-Dec-2012
 
Toan canh thuong mai dien tu 2012
Toan canh thuong mai dien tu 2012Toan canh thuong mai dien tu 2012
Toan canh thuong mai dien tu 2012
 
White book 2012 - Các vấn đề thương mại/đầu tư và kiến nghị
White book 2012 - Các vấn đề thương mại/đầu tư và kiến nghịWhite book 2012 - Các vấn đề thương mại/đầu tư và kiến nghị
White book 2012 - Các vấn đề thương mại/đầu tư và kiến nghị
 
Amazon Annual Report
Amazon Annual ReportAmazon Annual Report
Amazon Annual Report
 
HIGH IMPACT ENTREPRENEURS
HIGH IMPACT ENTREPRENEURSHIGH IMPACT ENTREPRENEURS
HIGH IMPACT ENTREPRENEURS
 
Bao cao EBI TMDT 2012
Bao cao EBI TMDT 2012Bao cao EBI TMDT 2012
Bao cao EBI TMDT 2012
 
VC-Corp Intro
VC-Corp IntroVC-Corp Intro
VC-Corp Intro
 
Mobile Trends: Cơ hội còn bỏ ngỏ
Mobile Trends: Cơ hội còn bỏ ngỏMobile Trends: Cơ hội còn bỏ ngỏ
Mobile Trends: Cơ hội còn bỏ ngỏ
 
Mobile VAS market in Vietnam
Mobile VAS market in VietnamMobile VAS market in Vietnam
Mobile VAS market in Vietnam
 
Vietnam’s Web in 2012
Vietnam’s Web in 2012Vietnam’s Web in 2012
Vietnam’s Web in 2012
 
Mạng quảng cáo gia tăng hiệu quả cho quảng cáo hiển thị
Mạng quảng cáo gia tăng hiệu quả cho quảng cáo hiển thịMạng quảng cáo gia tăng hiệu quả cho quảng cáo hiển thị
Mạng quảng cáo gia tăng hiệu quả cho quảng cáo hiển thị
 
IDC Q3 2012 Mobile Developer Report
IDC Q3 2012 Mobile Developer ReportIDC Q3 2012 Mobile Developer Report
IDC Q3 2012 Mobile Developer Report
 
Why not to do a startup?
Why not to do a startup?Why not to do a startup?
Why not to do a startup?
 
Mobiles share of the mix marketing evolution
Mobiles share of the mix marketing evolutionMobiles share of the mix marketing evolution
Mobiles share of the mix marketing evolution
 
Khảo sát lứa tuổi Teen Việt Nam 2012
Khảo sát lứa tuổi Teen Việt Nam 2012Khảo sát lứa tuổi Teen Việt Nam 2012
Khảo sát lứa tuổi Teen Việt Nam 2012
 
Creative design for mobile social game
Creative design for mobile social gameCreative design for mobile social game
Creative design for mobile social game
 
Balance in SNS by Energy
Balance in SNS by EnergyBalance in SNS by Energy
Balance in SNS by Energy
 
Training and developing human resources in a game studio
Training and developing human resources in a game studioTraining and developing human resources in a game studio
Training and developing human resources in a game studio
 

Último

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Benefits/tutorial of Lua in games

  • 1. Lua in Games Mr. Nguyễn Ngọc Vân Ass Software Manager – VNG Corporation
  • 2. Agenda 1. Lua & Benefits 2. Core engine & Lua model 3. Lua integrations model 4. Secure Lua code 5. Disadvantages
  • 3. 1. Lua & Benefits
  • 4. What’s Lua? • Scripting language • Works through LVM (Lua Virtual Machine) • Stack model design • “Ultimate game scripting language” (GDC 2010) • Popular uses in games • Runs on most machines and devices • Written in ANSI C and distributed by small library
  • 5. Lua Benefits • Free and open source  • Support OOP • Runs on almost platforms • Easy to interface with C/C++ • Very clean C API • Auto memory management (GC) • Powerful, fast and lightweight • Flexible data structure (TABLE)
  • 6. Lua Benefits • Contents can be changed in real-time • Auto generate contents • Users can customize/change contents • Fast and easy distributed contents • Secure code • Easy to use, embed and learn • Good references
  • 7. 2. Core Engine & Lua Model
  • 8. Configs Control Flow Settings (XML, INI, T Game Logic Process XT, …) (Behaviors, AI, …) Core Engine
  • 9. Configs Settings (…, LUA) Control Flow Lua Engine LUA Logic Process (Behaviors, Core Engine AI, …)
  • 11. Lua APIs Lua Core Logic Lua Engine codes (Logic Flow) (LVM) Lua interface Core Engine
  • 12. • Lua APIs – Call to LVM through events/triggers base – C APIs to work with LVM – Auxiliary library provides basic functions to check, register, debug, … LVM – Use C APIs to build core functions • Lua Interface – Call to core logic through exports APIs – Provides APIs (game APIs) to work with core logic – Use C APIs to build, register, and exports APIs
  • 13. Quick Sample function OnPlayerUseItem(nItem) core.InstanceObj(OBJ_KIND_ITEM, nItem) if item.GetKind() == ITM_KIND_HP then local nItemHP = item.GetAttribute(ITM_ATTR_HP) local nPlayerHP = player.GetCurrentHP() local nAddHP = 0.2 * nPlayerHP if nAddHP > 0 and nAddHP < player.GetMaxHP() then player.SetCurrentHP(nAddHP) player.Message('Player: '..player.GetName()..' use item '..item.GetName()) end end end
  • 15. • Compile to byte-code – Popular use – Use luaC module included in library – Modify luaC with keys for more secure • Encrypted – Little use – Use keys-pair to encrypted – Use signed file, CRC
  • 16. • Simple code function Add(a, b) return a + b end print(Add(100, 200)) • Byte-code
  • 18. • C APIs are too low-level • Error messages are very confusing  • No try-catch, no exceptions • Hard to debug • Hard to interfaces with unlike C/C++ • Once LVM is crashed, it’s not likely to recover and the service is crashed too  • Hard to implement reload feature at run-time • For extreme speed, LuaJIT is a good choice 