SlideShare a Scribd company logo
1 of 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
• 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
What’s Lua?
• 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
Lua Benefits
2. Core Engine & Lua Model
Configs
Settings
(XML, INI,
TXT, …)
Game Logic Process
(Behaviors, AI, …)
Control Flow
Core Engine
Configs
Settings
(…, LUA)
Lua Engine
Control Flow
Core Engine
LUA Logic
Process
(Behaviors,
AI, …)
3. Lua Integrations Model
Core Logic
(Logic Flow)
Lua Engine
(LVM)
Lua
codes
Lua APIs
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
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
Quick Sample
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 
Lua in Games

More Related Content

What's hot

Configuration primer
Configuration primerConfiguration primer
Configuration primerfeanil
 
Using Aws As A Game Server (AWS UG Bandung)
Using Aws As A Game Server (AWS UG Bandung)Using Aws As A Game Server (AWS UG Bandung)
Using Aws As A Game Server (AWS UG Bandung)Aswin Juari
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them AllTim Fairweather
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Alex S
 
Ansible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David KarbanAnsible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David Karbanansiblebrno
 
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017Jumping Bean
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleKnoldus Inc.
 
Ansible basics workshop
Ansible basics workshopAnsible basics workshop
Ansible basics workshopDavid Karban
 
Understand & develop ember addons
Understand & develop ember addonsUnderstand & develop ember addons
Understand & develop ember addonsDilip Kushwaha
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
E yantra robot abstractions
E yantra robot abstractionsE yantra robot abstractions
E yantra robot abstractionsAkshar Desai
 
Dot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soonDot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soonRichard Rabins
 
Ansible module development 101
Ansible module development 101Ansible module development 101
Ansible module development 101yfauser
 
Script up your application with Lua! -- RyanE -- OpenWest 2014
Script up your application with Lua! -- RyanE -- OpenWest 2014Script up your application with Lua! -- RyanE -- OpenWest 2014
Script up your application with Lua! -- RyanE -- OpenWest 2014ryanerickson
 
Introduction to Phoenix Framework (Elixir) 2016-01-07
Introduction to Phoenix Framework (Elixir) 2016-01-07Introduction to Phoenix Framework (Elixir) 2016-01-07
Introduction to Phoenix Framework (Elixir) 2016-01-07Svein Fidjestøl
 

What's hot (20)

Configuration primer
Configuration primerConfiguration primer
Configuration primer
 
Using Aws As A Game Server (AWS UG Bandung)
Using Aws As A Game Server (AWS UG Bandung)Using Aws As A Game Server (AWS UG Bandung)
Using Aws As A Game Server (AWS UG Bandung)
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
 
Ansible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David KarbanAnsible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David Karban
 
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
unga - boosting opensim
unga - boosting opensimunga - boosting opensim
unga - boosting opensim
 
Celery introduction
Celery introductionCelery introduction
Celery introduction
 
Chugalug
ChugalugChugalug
Chugalug
 
The future of node
The future of nodeThe future of node
The future of node
 
Ansible basics workshop
Ansible basics workshopAnsible basics workshop
Ansible basics workshop
 
Understand & develop ember addons
Understand & develop ember addonsUnderstand & develop ember addons
Understand & develop ember addons
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
E yantra robot abstractions
E yantra robot abstractionsE yantra robot abstractions
E yantra robot abstractions
 
Dot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soonDot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soon
 
Ansible module development 101
Ansible module development 101Ansible module development 101
Ansible module development 101
 
Hands on ansible
Hands on ansibleHands on ansible
Hands on ansible
 
Script up your application with Lua! -- RyanE -- OpenWest 2014
Script up your application with Lua! -- RyanE -- OpenWest 2014Script up your application with Lua! -- RyanE -- OpenWest 2014
Script up your application with Lua! -- RyanE -- OpenWest 2014
 
Introduction to Phoenix Framework (Elixir) 2016-01-07
Introduction to Phoenix Framework (Elixir) 2016-01-07Introduction to Phoenix Framework (Elixir) 2016-01-07
Introduction to Phoenix Framework (Elixir) 2016-01-07
 

Viewers also liked

Знаки зодіаку
Знаки зодіакуЗнаки зодіаку
Знаки зодіакуRoman Shatskyi
 
My Leaders And Role Models Felipe
My Leaders And Role Models FelipeMy Leaders And Role Models Felipe
My Leaders And Role Models Felipeguestfa1196
 
C:\documents and settings\informatica\escritorio\mejores películas
C:\documents and settings\informatica\escritorio\mejores películasC:\documents and settings\informatica\escritorio\mejores películas
C:\documents and settings\informatica\escritorio\mejores películascubanitoo
 
My Leaders And Role Models
My Leaders And Role ModelsMy Leaders And Role Models
My Leaders And Role Modelsguest4afb721
 
Ctaf foro Sig_Teledeteccion
Ctaf foro Sig_TeledeteccionCtaf foro Sig_Teledeteccion
Ctaf foro Sig_TeledeteccionDaniel
 
Ecew 2012 kenneth_refsgaard
Ecew 2012 kenneth_refsgaardEcew 2012 kenneth_refsgaard
Ecew 2012 kenneth_refsgaardTheFocusGroup
 
Auto Retrato 2
Auto Retrato 2Auto Retrato 2
Auto Retrato 2anaruthi
 
La ilustracion 2
La ilustracion 2La ilustracion 2
La ilustracion 2anamogil
 
Benidorm marina
Benidorm marinaBenidorm marina
Benidorm marinaNosholto
 
Présentation you & me consulting
Présentation you & me consultingPrésentation you & me consulting
Présentation you & me consultingYouandme Casablanca
 
CW2008 Mill Turn Data Sheet
CW2008 Mill Turn Data SheetCW2008 Mill Turn Data Sheet
CW2008 Mill Turn Data SheetSolis
 
Csodaszepbarlangokceriel
CsodaszepbarlangokcerielCsodaszepbarlangokceriel
Csodaszepbarlangokcerielzsoltslideshare
 

Viewers also liked (19)

Знаки зодіаку
Знаки зодіакуЗнаки зодіаку
Знаки зодіаку
 
My Leaders And Role Models Felipe
My Leaders And Role Models FelipeMy Leaders And Role Models Felipe
My Leaders And Role Models Felipe
 
Twitter Masterclass
Twitter MasterclassTwitter Masterclass
Twitter Masterclass
 
C:\documents and settings\informatica\escritorio\mejores películas
C:\documents and settings\informatica\escritorio\mejores películasC:\documents and settings\informatica\escritorio\mejores películas
C:\documents and settings\informatica\escritorio\mejores películas
 
Construir Puentes y no muros
Construir Puentes y no murosConstruir Puentes y no muros
Construir Puentes y no muros
 
My Leaders And Role Models
My Leaders And Role ModelsMy Leaders And Role Models
My Leaders And Role Models
 
Lab so-abertos-unidade3
Lab so-abertos-unidade3Lab so-abertos-unidade3
Lab so-abertos-unidade3
 
Ctaf foro Sig_Teledeteccion
Ctaf foro Sig_TeledeteccionCtaf foro Sig_Teledeteccion
Ctaf foro Sig_Teledeteccion
 
Goza tu verano con APC
Goza tu verano con APCGoza tu verano con APC
Goza tu verano con APC
 
Spam
SpamSpam
Spam
 
Ecew 2012 kenneth_refsgaard
Ecew 2012 kenneth_refsgaardEcew 2012 kenneth_refsgaard
Ecew 2012 kenneth_refsgaard
 
Auto Retrato 2
Auto Retrato 2Auto Retrato 2
Auto Retrato 2
 
La ilustracion 2
La ilustracion 2La ilustracion 2
La ilustracion 2
 
Benidorm marina
Benidorm marinaBenidorm marina
Benidorm marina
 
Présentation you & me consulting
Présentation you & me consultingPrésentation you & me consulting
Présentation you & me consulting
 
Tecnologías emergentes
Tecnologías emergentes Tecnologías emergentes
Tecnologías emergentes
 
CW2008 Mill Turn Data Sheet
CW2008 Mill Turn Data SheetCW2008 Mill Turn Data Sheet
CW2008 Mill Turn Data Sheet
 
Csodaszepbarlangokceriel
CsodaszepbarlangokcerielCsodaszepbarlangokceriel
Csodaszepbarlangokceriel
 
Lekt 10 becm-pcr_decrypted
Lekt 10 becm-pcr_decryptedLekt 10 becm-pcr_decrypted
Lekt 10 becm-pcr_decrypted
 

Similar to Lua in Games

Benefits/tutorial of Lua in games
Benefits/tutorial of Lua in gamesBenefits/tutorial of Lua in games
Benefits/tutorial of Lua in gamesaction.vn
 
Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engi...
Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engi...Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engi...
Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engi...Piccolo Engine
 
.Net overviewrajnish
.Net overviewrajnish.Net overviewrajnish
.Net overviewrajnishRajnish Kalla
 
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015Mike Broberg
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeDmitri Nesteruk
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Itzik Kotler
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101Rami Sayar
 
Ansible nice-pdf-copy-for-pres
Ansible nice-pdf-copy-for-presAnsible nice-pdf-copy-for-pres
Ansible nice-pdf-copy-for-presManmohan Singh
 
High-Performance Computing with C++
High-Performance Computing with C++High-Performance Computing with C++
High-Performance Computing with C++JetBrains
 
Transparent GPU Exploitation for Java
Transparent GPU Exploitation for JavaTransparent GPU Exploitation for Java
Transparent GPU Exploitation for JavaKazuaki Ishizaki
 
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
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Yuta Iwama
 
How to Play at Work - A Play Framework Tutorial
How to Play at Work - A Play Framework TutorialHow to Play at Work - A Play Framework Tutorial
How to Play at Work - A Play Framework TutorialAssistSoftware
 
Learn about Java framework for pen-based computing and the Livescribe Platfor...
Learn about Java framework for pen-based computing and the Livescribe Platfor...Learn about Java framework for pen-based computing and the Livescribe Platfor...
Learn about Java framework for pen-based computing and the Livescribe Platfor...Marakana Inc.
 
An Open Source Workbench for Prototyping Multimodal Interactions Based on Off...
An Open Source Workbench for Prototyping Multimodal Interactions Based on Off...An Open Source Workbench for Prototyping Multimodal Interactions Based on Off...
An Open Source Workbench for Prototyping Multimodal Interactions Based on Off...Jean Vanderdonckt
 
TestUpload
TestUploadTestUpload
TestUploadZarksaDS
 
Toward a gui remote-sensing environment built over OTB
Toward a gui remote-sensing environment built over OTBToward a gui remote-sensing environment built over OTB
Toward a gui remote-sensing environment built over OTBmelaneum
 

Similar to Lua in Games (20)

Benefits/tutorial of Lua in games
Benefits/tutorial of Lua in gamesBenefits/tutorial of Lua in games
Benefits/tutorial of Lua in games
 
Monkey space 2013
Monkey space 2013Monkey space 2013
Monkey space 2013
 
Top 10 python ide
Top 10 python ideTop 10 python ide
Top 10 python ide
 
Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engi...
Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engi...Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engi...
Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engi...
 
.Net overviewrajnish
.Net overviewrajnish.Net overviewrajnish
.Net overviewrajnish
 
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
Ansible nice-pdf-copy-for-pres
Ansible nice-pdf-copy-for-presAnsible nice-pdf-copy-for-pres
Ansible nice-pdf-copy-for-pres
 
High-Performance Computing with C++
High-Performance Computing with C++High-Performance Computing with C++
High-Performance Computing with C++
 
Transparent GPU Exploitation for Java
Transparent GPU Exploitation for JavaTransparent GPU Exploitation for Java
Transparent GPU Exploitation for Java
 
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
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016
 
How to Play at Work - A Play Framework Tutorial
How to Play at Work - A Play Framework TutorialHow to Play at Work - A Play Framework Tutorial
How to Play at Work - A Play Framework Tutorial
 
Learn about Java framework for pen-based computing and the Livescribe Platfor...
Learn about Java framework for pen-based computing and the Livescribe Platfor...Learn about Java framework for pen-based computing and the Livescribe Platfor...
Learn about Java framework for pen-based computing and the Livescribe Platfor...
 
An Open Source Workbench for Prototyping Multimodal Interactions Based on Off...
An Open Source Workbench for Prototyping Multimodal Interactions Based on Off...An Open Source Workbench for Prototyping Multimodal Interactions Based on Off...
An Open Source Workbench for Prototyping Multimodal Interactions Based on Off...
 
TestUpload
TestUploadTestUpload
TestUpload
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Toward a gui remote-sensing environment built over OTB
Toward a gui remote-sensing environment built over OTBToward a gui remote-sensing environment built over OTB
Toward a gui remote-sensing environment built over OTB
 

More from we20

Nielsen SEA Cross-platform Report 2014
Nielsen SEA Cross-platform Report 2014Nielsen SEA Cross-platform Report 2014
Nielsen SEA Cross-platform Report 2014we20
 
Hành vi và xu hướng sử dụng Internet tại Việt Nam
Hành vi và xu hướng sử dụng Internet tại Việt NamHành vi và xu hướng sử dụng Internet tại Việt Nam
Hành vi và xu hướng sử dụng Internet tại Việt Namwe20
 
Báo Cáo Hành Vi Người Tiêu Dùng Online
Báo Cáo Hành Vi Người Tiêu Dùng OnlineBáo Cáo Hành Vi Người Tiêu Dùng Online
Báo Cáo Hành Vi Người Tiêu Dùng Onlinewe20
 
Bao cao tai nguyen Internet 2014
Bao cao tai nguyen Internet 2014Bao cao tai nguyen Internet 2014
Bao cao tai nguyen Internet 2014we20
 
Report on Vietnam Internet resources 2014
Report on Vietnam Internet resources 2014Report on Vietnam Internet resources 2014
Report on Vietnam Internet resources 2014we20
 
Internet Trends 2014
Internet Trends 2014 Internet Trends 2014
Internet Trends 2014 we20
 
2014 ASIA-PACIFIC DIGITAL OVERVIEW
2014 ASIA-PACIFIC DIGITAL OVERVIEW2014 ASIA-PACIFIC DIGITAL OVERVIEW
2014 ASIA-PACIFIC DIGITAL OVERVIEWwe20
 
2014 internet trends
2014 internet trends2014 internet trends
2014 internet trendswe20
 
Personalized Recommendation - The Key for Engagement?
Personalized Recommendation - The Key for Engagement?Personalized Recommendation - The Key for Engagement?
Personalized Recommendation - The Key for Engagement?we20
 
VIETNAM E-COMMERCE REPORT 2013
VIETNAM E-COMMERCE REPORT 2013VIETNAM E-COMMERCE REPORT 2013
VIETNAM E-COMMERCE REPORT 2013we20
 
Báo cáo Thương mại điện tử Việt Nam 2013
Báo cáo Thương mại điện tử Việt Nam 2013Báo cáo Thương mại điện tử Việt Nam 2013
Báo cáo Thương mại điện tử Việt Nam 2013we20
 
ONLINE PAYMENT ACTUAL SITUATION & POTENTIAL
ONLINE PAYMENT ACTUAL SITUATION & POTENTIALONLINE PAYMENT ACTUAL SITUATION & POTENTIAL
ONLINE PAYMENT ACTUAL SITUATION & POTENTIALwe20
 
E-COMMERCE IN VN
E-COMMERCE IN VNE-COMMERCE IN VN
E-COMMERCE IN VNwe20
 
Online Mobile Game with Mobicom_eng ver.
Online Mobile Game with Mobicom_eng ver.Online Mobile Game with Mobicom_eng ver.
Online Mobile Game with Mobicom_eng ver.we20
 
NÓI VỀ TMĐT Ở VN
NÓI VỀ TMĐT Ở VNNÓI VỀ TMĐT Ở VN
NÓI VỀ TMĐT Ở VNwe20
 
MUA CHUNG VA KINH NGHIEM PHAT TRIEN SOHAPAY
MUA CHUNG VA KINH NGHIEM PHAT TRIEN SOHAPAYMUA CHUNG VA KINH NGHIEM PHAT TRIEN SOHAPAY
MUA CHUNG VA KINH NGHIEM PHAT TRIEN SOHAPAYwe20
 
MOBILE APP _VIET VER
MOBILE APP _VIET VERMOBILE APP _VIET VER
MOBILE APP _VIET VERwe20
 
MOBILE APP _ENG VER.
MOBILE APP _ENG VER.MOBILE APP _ENG VER.
MOBILE APP _ENG VER.we20
 
Phát triển Mobile Application
Phát triển Mobile ApplicationPhát triển Mobile Application
Phát triển Mobile Applicationwe20
 
Develop Mobile Application
Develop Mobile ApplicationDevelop Mobile Application
Develop Mobile Applicationwe20
 

More from we20 (20)

Nielsen SEA Cross-platform Report 2014
Nielsen SEA Cross-platform Report 2014Nielsen SEA Cross-platform Report 2014
Nielsen SEA Cross-platform Report 2014
 
Hành vi và xu hướng sử dụng Internet tại Việt Nam
Hành vi và xu hướng sử dụng Internet tại Việt NamHành vi và xu hướng sử dụng Internet tại Việt Nam
Hành vi và xu hướng sử dụng Internet tại Việt Nam
 
Báo Cáo Hành Vi Người Tiêu Dùng Online
Báo Cáo Hành Vi Người Tiêu Dùng OnlineBáo Cáo Hành Vi Người Tiêu Dùng Online
Báo Cáo Hành Vi Người Tiêu Dùng Online
 
Bao cao tai nguyen Internet 2014
Bao cao tai nguyen Internet 2014Bao cao tai nguyen Internet 2014
Bao cao tai nguyen Internet 2014
 
Report on Vietnam Internet resources 2014
Report on Vietnam Internet resources 2014Report on Vietnam Internet resources 2014
Report on Vietnam Internet resources 2014
 
Internet Trends 2014
Internet Trends 2014 Internet Trends 2014
Internet Trends 2014
 
2014 ASIA-PACIFIC DIGITAL OVERVIEW
2014 ASIA-PACIFIC DIGITAL OVERVIEW2014 ASIA-PACIFIC DIGITAL OVERVIEW
2014 ASIA-PACIFIC DIGITAL OVERVIEW
 
2014 internet trends
2014 internet trends2014 internet trends
2014 internet trends
 
Personalized Recommendation - The Key for Engagement?
Personalized Recommendation - The Key for Engagement?Personalized Recommendation - The Key for Engagement?
Personalized Recommendation - The Key for Engagement?
 
VIETNAM E-COMMERCE REPORT 2013
VIETNAM E-COMMERCE REPORT 2013VIETNAM E-COMMERCE REPORT 2013
VIETNAM E-COMMERCE REPORT 2013
 
Báo cáo Thương mại điện tử Việt Nam 2013
Báo cáo Thương mại điện tử Việt Nam 2013Báo cáo Thương mại điện tử Việt Nam 2013
Báo cáo Thương mại điện tử Việt Nam 2013
 
ONLINE PAYMENT ACTUAL SITUATION & POTENTIAL
ONLINE PAYMENT ACTUAL SITUATION & POTENTIALONLINE PAYMENT ACTUAL SITUATION & POTENTIAL
ONLINE PAYMENT ACTUAL SITUATION & POTENTIAL
 
E-COMMERCE IN VN
E-COMMERCE IN VNE-COMMERCE IN VN
E-COMMERCE IN VN
 
Online Mobile Game with Mobicom_eng ver.
Online Mobile Game with Mobicom_eng ver.Online Mobile Game with Mobicom_eng ver.
Online Mobile Game with Mobicom_eng ver.
 
NÓI VỀ TMĐT Ở VN
NÓI VỀ TMĐT Ở VNNÓI VỀ TMĐT Ở VN
NÓI VỀ TMĐT Ở VN
 
MUA CHUNG VA KINH NGHIEM PHAT TRIEN SOHAPAY
MUA CHUNG VA KINH NGHIEM PHAT TRIEN SOHAPAYMUA CHUNG VA KINH NGHIEM PHAT TRIEN SOHAPAY
MUA CHUNG VA KINH NGHIEM PHAT TRIEN SOHAPAY
 
MOBILE APP _VIET VER
MOBILE APP _VIET VERMOBILE APP _VIET VER
MOBILE APP _VIET VER
 
MOBILE APP _ENG VER.
MOBILE APP _ENG VER.MOBILE APP _ENG VER.
MOBILE APP _ENG VER.
 
Phát triển Mobile Application
Phát triển Mobile ApplicationPhát triển Mobile Application
Phát triển Mobile Application
 
Develop Mobile Application
Develop Mobile ApplicationDevelop Mobile Application
Develop Mobile Application
 

Recently uploaded

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Recently uploaded (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

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. • 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 What’s Lua?
  • 5. • 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
  • 6. • 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 Lua Benefits
  • 7. 2. Core Engine & Lua Model
  • 8. Configs Settings (XML, INI, TXT, …) Game Logic Process (Behaviors, AI, …) Control Flow Core Engine
  • 9. Configs Settings (…, LUA) Lua Engine Control Flow Core Engine LUA Logic Process (Behaviors, AI, …)
  • 11. Core Logic (Logic Flow) Lua Engine (LVM) Lua codes Lua APIs 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. 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 Quick Sample
  • 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 