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, T
XT, …)
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

Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them AllTim Fairweather
 
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 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
 
E yantra robot abstractions
E yantra robot abstractionsE yantra robot abstractions
E yantra robot abstractionsAkshar Desai
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
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
 
Terraform + ansible talk
Terraform + ansible talkTerraform + ansible talk
Terraform + ansible talkJames Strong
 
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
 
Understand & develop ember addons
Understand & develop ember addonsUnderstand & develop ember addons
Understand & develop ember addonsDilip Kushwaha
 

What's hot (20)

Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
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 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
 
The future of node
The future of nodeThe future of node
The future of node
 
Chugalug
ChugalugChugalug
Chugalug
 
Ansible basics workshop
Ansible basics workshopAnsible basics workshop
Ansible basics workshop
 
E yantra robot abstractions
E yantra robot abstractionsE yantra robot abstractions
E yantra robot abstractions
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
mtl_rubykaigi
mtl_rubykaigimtl_rubykaigi
mtl_rubykaigi
 
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
 
Terraform + ansible talk
Terraform + ansible talkTerraform + ansible talk
Terraform + ansible talk
 
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
 
Understand & develop ember addons
Understand & develop ember addonsUnderstand & develop ember addons
Understand & develop ember addons
 

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
 
High-Performance Computing with C++
High-Performance Computing with C++High-Performance Computing with C++
High-Performance Computing with C++JetBrains
 
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
 
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
 
Ansible nice-pdf-copy-for-pres
Ansible nice-pdf-copy-for-presAnsible nice-pdf-copy-for-pres
Ansible nice-pdf-copy-for-presManmohan Singh
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Yuta Iwama
 
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.
 
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
 
TestUpload
TestUploadTestUpload
TestUploadZarksaDS
 
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
 
SMP implementation for OpenBSD/sgi
SMP implementation for OpenBSD/sgiSMP implementation for OpenBSD/sgi
SMP implementation for OpenBSD/sgiTakuya ASADA
 

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
 
High-Performance Computing with C++
High-Performance Computing with C++High-Performance Computing with C++
High-Performance Computing with C++
 
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
 
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
 
Ansible nice-pdf-copy-for-pres
Ansible nice-pdf-copy-for-presAnsible nice-pdf-copy-for-pres
Ansible nice-pdf-copy-for-pres
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016
 
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...
 
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
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
TestUpload
TestUploadTestUpload
TestUpload
 
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...
 
SMP implementation for OpenBSD/sgi
SMP implementation for OpenBSD/sgiSMP implementation for OpenBSD/sgi
SMP implementation for OpenBSD/sgi
 

More from Son Aris

Main land china mobile app market 2014. what you need to know
Main land china mobile app market 2014. what you need to knowMain land china mobile app market 2014. what you need to know
Main land china mobile app market 2014. what you need to knowSon Aris
 
Vietnam Digital Marketing Market Overview
Vietnam Digital Marketing Market OverviewVietnam Digital Marketing Market Overview
Vietnam Digital Marketing Market OverviewSon Aris
 
Mobile Game In China 2013-2014
Mobile Game In China 2013-2014Mobile Game In China 2013-2014
Mobile Game In China 2013-2014Son Aris
 
Japans social gaming market 2013
Japans social gaming market 2013Japans social gaming market 2013
Japans social gaming market 2013Son Aris
 
In mobi app_insight_report
In mobi app_insight_reportIn mobi app_insight_report
In mobi app_insight_reportSon Aris
 
Ogdc 2013 am i ready to go startup
Ogdc 2013 am i ready to go startupOgdc 2013 am i ready to go startup
Ogdc 2013 am i ready to go startupSon Aris
 
Ogdc 2013 zing me mobile
Ogdc 2013 zing me mobileOgdc 2013 zing me mobile
Ogdc 2013 zing me mobileSon Aris
 
Ogdc 2013 the importance of in game event
Ogdc 2013 the importance of in game eventOgdc 2013 the importance of in game event
Ogdc 2013 the importance of in game eventSon Aris
 
Ogdc 2013 spine anim20131
Ogdc 2013 spine anim20131Ogdc 2013 spine anim20131
Ogdc 2013 spine anim20131Son Aris
 
Ogdc 2013 psychology applied 2013
Ogdc 2013 psychology applied 2013Ogdc 2013 psychology applied 2013
Ogdc 2013 psychology applied 2013Son Aris
 
Ogdc 2013 prototyping mobile games
Ogdc 2013 prototyping mobile gamesOgdc 2013 prototyping mobile games
Ogdc 2013 prototyping mobile gamesSon Aris
 
Ogdc 2013 network stragegy for mmo game
Ogdc 2013 network stragegy for mmo gameOgdc 2013 network stragegy for mmo game
Ogdc 2013 network stragegy for mmo gameSon Aris
 
Ogdc 2013 monetization experience
Ogdc 2013 monetization experienceOgdc 2013 monetization experience
Ogdc 2013 monetization experienceSon Aris
 
Ogdc 2013 mobile game trend in southeastasia
Ogdc 2013 mobile game trend in southeastasiaOgdc 2013 mobile game trend in southeastasia
Ogdc 2013 mobile game trend in southeastasiaSon Aris
 
Ogdc 2013 lets remake the wheel
Ogdc 2013 lets remake the wheelOgdc 2013 lets remake the wheel
Ogdc 2013 lets remake the wheelSon Aris
 
Ogdc 2013 how to distribute content touser for social and mobile game
Ogdc 2013 how to distribute content touser for social and mobile gameOgdc 2013 how to distribute content touser for social and mobile game
Ogdc 2013 how to distribute content touser for social and mobile gameSon Aris
 
Ogdc 2013 how retention rate affects aniworld
Ogdc 2013 how retention rate affects aniworldOgdc 2013 how retention rate affects aniworld
Ogdc 2013 how retention rate affects aniworldSon Aris
 
Ogdc 2013 game design problem solving
Ogdc 2013 game design problem solvingOgdc 2013 game design problem solving
Ogdc 2013 game design problem solvingSon Aris
 
Ogdc 2013 choosing the right database for social mobile game
Ogdc 2013 choosing the right database for social mobile gameOgdc 2013 choosing the right database for social mobile game
Ogdc 2013 choosing the right database for social mobile gameSon Aris
 
Ogdc 2013 cross platform game development with html5
Ogdc 2013 cross platform game development with html5Ogdc 2013 cross platform game development with html5
Ogdc 2013 cross platform game development with html5Son Aris
 

More from Son Aris (20)

Main land china mobile app market 2014. what you need to know
Main land china mobile app market 2014. what you need to knowMain land china mobile app market 2014. what you need to know
Main land china mobile app market 2014. what you need to know
 
Vietnam Digital Marketing Market Overview
Vietnam Digital Marketing Market OverviewVietnam Digital Marketing Market Overview
Vietnam Digital Marketing Market Overview
 
Mobile Game In China 2013-2014
Mobile Game In China 2013-2014Mobile Game In China 2013-2014
Mobile Game In China 2013-2014
 
Japans social gaming market 2013
Japans social gaming market 2013Japans social gaming market 2013
Japans social gaming market 2013
 
In mobi app_insight_report
In mobi app_insight_reportIn mobi app_insight_report
In mobi app_insight_report
 
Ogdc 2013 am i ready to go startup
Ogdc 2013 am i ready to go startupOgdc 2013 am i ready to go startup
Ogdc 2013 am i ready to go startup
 
Ogdc 2013 zing me mobile
Ogdc 2013 zing me mobileOgdc 2013 zing me mobile
Ogdc 2013 zing me mobile
 
Ogdc 2013 the importance of in game event
Ogdc 2013 the importance of in game eventOgdc 2013 the importance of in game event
Ogdc 2013 the importance of in game event
 
Ogdc 2013 spine anim20131
Ogdc 2013 spine anim20131Ogdc 2013 spine anim20131
Ogdc 2013 spine anim20131
 
Ogdc 2013 psychology applied 2013
Ogdc 2013 psychology applied 2013Ogdc 2013 psychology applied 2013
Ogdc 2013 psychology applied 2013
 
Ogdc 2013 prototyping mobile games
Ogdc 2013 prototyping mobile gamesOgdc 2013 prototyping mobile games
Ogdc 2013 prototyping mobile games
 
Ogdc 2013 network stragegy for mmo game
Ogdc 2013 network stragegy for mmo gameOgdc 2013 network stragegy for mmo game
Ogdc 2013 network stragegy for mmo game
 
Ogdc 2013 monetization experience
Ogdc 2013 monetization experienceOgdc 2013 monetization experience
Ogdc 2013 monetization experience
 
Ogdc 2013 mobile game trend in southeastasia
Ogdc 2013 mobile game trend in southeastasiaOgdc 2013 mobile game trend in southeastasia
Ogdc 2013 mobile game trend in southeastasia
 
Ogdc 2013 lets remake the wheel
Ogdc 2013 lets remake the wheelOgdc 2013 lets remake the wheel
Ogdc 2013 lets remake the wheel
 
Ogdc 2013 how to distribute content touser for social and mobile game
Ogdc 2013 how to distribute content touser for social and mobile gameOgdc 2013 how to distribute content touser for social and mobile game
Ogdc 2013 how to distribute content touser for social and mobile game
 
Ogdc 2013 how retention rate affects aniworld
Ogdc 2013 how retention rate affects aniworldOgdc 2013 how retention rate affects aniworld
Ogdc 2013 how retention rate affects aniworld
 
Ogdc 2013 game design problem solving
Ogdc 2013 game design problem solvingOgdc 2013 game design problem solving
Ogdc 2013 game design problem solving
 
Ogdc 2013 choosing the right database for social mobile game
Ogdc 2013 choosing the right database for social mobile gameOgdc 2013 choosing the right database for social mobile game
Ogdc 2013 choosing the right database for social mobile game
 
Ogdc 2013 cross platform game development with html5
Ogdc 2013 cross platform game development with html5Ogdc 2013 cross platform game development with html5
Ogdc 2013 cross platform game development with html5
 

Recently uploaded

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
[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
 

Recently uploaded (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
[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
 

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, T XT, …) 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 