108 lines
4.9 KiB
HTML
108 lines
4.9 KiB
HTML
<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">
|
|
<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>
|
|
<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");
|
|
}
|
|
});
|
|
</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> ›› </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>
|
|
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>
|
|
<div id="topic_content">
|
|
|
|
<p></p>
|
|
<p><span class="rvts60">Using Lua scripting</span></p>
|
|
<p><span class="rvts32"><br/></span></p>
|
|
<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>
|
|
<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="rvts60"><br/></span></p>
|
|
<p><span class="rvts60">Core Lua Documentation</span></p>
|
|
<p><span class="rvts32"><br/></span></p>
|
|
<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. Try searching on the Internet for "Lua tutorial". 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>
|
|
<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. You will probably also find useful information on the Internet.</p>
|
|
<p><span class="rvts60"><br/></span></p>
|
|
<p><span class="rvts60">GUI Frontend</span></p>
|
|
<p><br/></p>
|
|
<p>To use a Lua script, you need to create one in a text editor. The name of the file created should end in .lua to indicate that it is a Lua script.</p>
|
|
<p><br/></p>
|
|
<p>To run a Lua script, choose "Run Lua Script" ***from where*** In the dialog that pops up, click "Browse" and find the file you wish to run. This will insert the path of this file into the dialog. You can then click on "Run" to run the script or "Cancel" to return to FCEUX without running the script.</p>
|
|
<p><br/></p>
|
|
<p>To end a Lua script, choose "Stop Lua Script" ***from where***.</p>
|
|
<p><br/></p>
|
|
<p><span class="rvts60">FCEUX Lua Basics</span></p>
|
|
<p><br/></p>
|
|
<p>Your script will be constructed according to the rules of Lua, but you will use FCEUX-specific functions to interact with the emulator. 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>
|
|
<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>
|
|
<p>emu.speedmode("normal") -- Set the speed of the emulator</p>
|
|
<p><br/></p>
|
|
<p>-- Declare and set variables or functions if needed</p>
|
|
<p><br/></p>
|
|
<p>while true do</p>
|
|
<p> -- Execute instructions for FCEUX</p>
|
|
<p> emu.frameadvance() -- This essentially tells FCEUX to keep running</p>
|
|
<p>end</p>
|
|
<p><br/></p>
|
|
<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>
|
|
</div>
|
|
|
|
<div id="topic_footer">
|
|
|
|
<div id="topic_footer_content">
|
|
2016</div>
|
|
</div>
|
|
</body>
|
|
|
|
</html>
|
|
|