fceux/help/LuaGettingStarted.html

108 lines
4.9 KiB
HTML
Raw Normal View History

2012-03-23 20:30:31 +00:00
<html>
<head>
<title>Getting Started</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="HelpNDoc Personal Edition 3.8.0.560">
2012-03-23 20:30:31 +00:00
<link type="text/css" rel="stylesheet" media="all" href="css/reset.css" />
<link type="text/css" rel="stylesheet" media="all" href="css/base.css" />
<link type="text/css" rel="stylesheet" media="all" href="css/hnd.css" />
<!--[if lte IE 8]>
<link type="text/css" rel="stylesheet" media="all" href="css/ielte8.css" />
<![endif]-->
<style type="text/css">
#topic_header
{
background-color: #EFEFEF;
}
</style>
2012-03-23 20:30:31 +00:00
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/hnd.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
if (top.frames.length == 0)
{
var sTopicUrl = top.location.href.substring(top.location.href.lastIndexOf("/") + 1, top.location.href.length);
top.location.href = "fceux.html?" + sTopicUrl;
}
else if (top && top.FrameTOC && top.FrameTOC.SelectTocItem)
{
top.FrameTOC.SelectTocItem("LuaGettingStarted");
}
});
2012-03-23 20:30:31 +00:00
</script>
</head>
<body>
<div id="topic_header">
<div id="topic_header_content">
<h1>Getting Started</h1>
<div id="topic_breadcrumb">
<a href="LuaScripting.html">Lua Scripting</a> &rsaquo;&rsaquo; </div>
</div>
<div id="topic_header_nav">
<a href="LuaScripting.html"><img src="img/arrow_up.png" alt="Parent"/></a>
<a href="LuaScripting.html"><img src="img/arrow_left.png" alt="Previous"/></a>
<a href="Commands.html"><img src="img/arrow_right.png" alt="Next"/></a>
2012-03-23 20:30:31 +00:00
</div>
<div class="clear"></div>
</div>
<div id="topic_content">
<p></p>
<p><span class="rvts55">Using Lua scripting</span></p>
<p><span class="rvts32"><br/></span></p>
2012-03-23 20:30:31 +00:00
<p>Lua is built into FCEUX as of 2.1.2, and luapack DLL files are no longer needed in this and later versions.</p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>To run lua scripts in older versions of FCEUX, you will need the lua pack which can be found <a class="rvts18" href="http://fceux.com/luapack">here</a>. The .dll files must be unzipped in the same folder as fceux.exe.</p>
<p><span class="rvts55"><br/></span></p>
<p><span class="rvts55">Core Lua Documentation</span></p>
<p><span class="rvts32"><br/></span></p>
2012-03-23 20:30:31 +00:00
<p>If you have never programmed, you will probably want to start by learning the basic of Lua, which is too broad for the scope of this help file. &nbsp;Try searching on the Internet for "Lua tutorial". &nbsp;As of this writing, it's official homepage is <a class="rvts18" href="http://www.lua.org/">http://www.lua.org/</a></p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>If you are familiar with any programming language you will probably not have too much difficulty adjusting to the syntax and structure of Lua. &nbsp;You will probably also find useful information on the Internet.</p>
<p><span class="rvts55"><br/></span></p>
<p><span class="rvts55">GUI Frontend</span></p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>To use a Lua script, you need to create one in a text editor. &nbsp;The name of the file created should end in .lua to indicate that it is a Lua script.</p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>To run a Lua script, choose "Run Lua Script" ***from where*** &nbsp;In the dialog that pops up, click "Browse" and find the file you wish to run. &nbsp;This will insert the path of this file into the dialog. &nbsp;You can then click on "Run" to run the script or "Cancel" to return to FCEUX without running the script.</p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>To end a Lua script, choose "Stop Lua Script" ***from where***.</p>
<p><br/></p>
<p><span class="rvts55">FCEUX Lua Basics</span></p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>Your script will be constructed according to the rules of Lua, but you will use FCEUX-specific functions to interact with the emulator. &nbsp;For example, one of the most often-used functions is emu.frameadvance() which will tell the emulator to advance exactly one frame, which is the basic unit of time on an NES.</p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>In general, your script will probably want to be run until you tell it to stop, so it will look something like this:</p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>emu.speedmode("normal") -- Set the speed of the emulator</p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>-- Declare and set variables or functions if needed</p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>while true do</p>
<p> &nbsp; -- Execute instructions for FCEUX</p>
<p> &nbsp; emu.frameadvance() -- This essentially tells FCEUX to keep running</p>
<p>end</p>
<p><br/></p>
2012-03-23 20:30:31 +00:00
<p>The way instructions are sent to FCEUX is through a set of specially defined functions (and variables) which are called an API, the specification of which follows.</p>
<p></p>
<p class="rvps2"><span class="rvts13">Created with the Personal Edition of HelpNDoc: </span><a class="rvts14" href="http://www.helpndoc.com/feature-tour">Easily create Help documents</a></p>
2012-03-23 20:30:31 +00:00
</div>
<div id="topic_footer">
<div id="topic_footer_content">
2013</div>
2012-03-23 20:30:31 +00:00
</div>
</body>
</html>