[QUOTE=thelinx;19232131]I may be way off, but isn't it compiled to bytecode?[/QUOTE]
This is pretty much it. It's like the .Net languages, compiled into a special bytecode and then ran by the virtual machine.
You can't run .Net programs without .Net framework installed for the correct VM, does that make them scripting languages rather than programming ones?
Same goes for Java.
The 'Scripting language' category is a subcategory of the 'Programming language' category.
Raw Lua files (.lua) are compiled into [url=http://luaforge.net/docman/view.php/83/99/ANoFrillsIntroToLua51VMInstructions.odt]Lua Bytecode[/url] (.luac) upon execution. This is known as [url=http://en.wikipedia.org/wiki/Just-in-time_compilation]Just In Time[/url] compilation.
Upon compilation, locals are resolved and functions are assigned their upvalues.
The bytecode resembles that of many other languages and could be likened to Assembly itself.
Chad, I recommend that you find a tutorial for Lua and stick with it. There are plenty available around.
Once you've learnt the basics, you can apply it to your project and continue to learn.
Having a project as your initial learning curve can be devastating to your future prospects as a programmer. I've seen it in a number of people.
Don't go for a tutorial such as [url=lua.org/pil/]Programming in Lua[/url], as it is too advanced. It's target audience is programmers already established in C looking to implement Lua in their application.
There are plenty out there. Google will help greatly in your learning stages, and onwards.
Remember to search before asking, as someone [i]has[/i] had a problem identical to yours, or extremely similar, before.
Good luck!
I knew it was compiled into something.
And generally, I class languages that aren't precompiled (eg C++ is precompiled, php & lua isn't) as scripted languages but that's just my interpretation.
This thread has been derailed to hell.
Chad, do whatever you want in Gmod, and with Lua. I wish you luck with your boring text game.
Why thank you! :dance:
I'm trying to find a program that will actually let me create one of those REAL text games that are in those black boxes.
c++
[editline]07:40PM[/editline]
:v:
:v:
I got that Lua for windows thing, I opened the 'Lua' and got a black box with text.
How to I open a lua file from my desktop?
[editline]07:49PM[/editline]
:argh: never mind :v:
What if I made a C++ app with Lua bindings that allowed folks to script a text based game!!?!?! lol
edit: I've been playing around with Lua and it appears it already has functions you would need to create a simple text game. All I have to do is embed it. I actually may have something done by the end of the day.
Right it's pretty easy to code, but I was trying to get some structure down in Lua. Anyways, here is the engine, have fun.
Screenshot:(It appears I made a typo. lol)
[URL=http://img64.imageshack.us/i/tgescreen.png/][IMG]http://img64.imageshack.us/img64/5642/tgescreen.png[/IMG][/URL]
Download:
[url]http://www.filefront.com/15229709/Text-Game%20Engine.zip[/url]
[QUOTE=iRzilla;19239303]22 lines of C++ simple enough.[/QUOTE]
You should be using:
[cpp]luaL_openlibs( LuaVM );[/cpp]
I coded mine in C. :/ I couldn't seem to get C++ working.
[QUOTE=Overv;19248428]You should be using:
[cpp]lua_openlibs( LuaVM );[/cpp][/QUOTE]
[cpp]luaL_openlibs( LuaVM );[/cpp]
I am fairly new to binding Lua to applications, and can't seem to bind Lua with C++ without writing a wrapper. Futhermore, I have tested your 22 lines of code, and it fails to compile where as the C code compiles correctly. So my question to you is, are you using some sort of wrapper? It appears as if you are not.
Can you post your output from the compile?
[editline]11:21AM[/editline]
Try including lauxlib.h, lua.h and lualib.h
[cpp]extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}[/cpp]
Should be sufficient.
[QUOTE=Anthoni_c;19241258]Right it's pretty easy to code, but I was trying to get some structure down in Lua. Anyways, here is the engine, have fun.
Screenshot:(It appears I made a typo. lol)
[URL=http://img64.imageshack.us/i/tgescreen.png/][IMG]http://img64.imageshack.us/img64/5642/tgescreen.png[/IMG][/URL]
Download:
[url]http://www.filefront.com/15229709/Text-Game%20Engine.zip[/url][/QUOTE]
Thank You!
Now I just need one little bit of help and then I will be off:
I need to make it so if I type a phrase it will open a file, such as something like
[I]The man asks you if you can spare some change, do you wish to spare some change? Yes or No?[/I]
When you type yes, it opens a file that says something like [I]You give the man some change and continue on...blah[/I]
How would I go about doing this?
[QUOTE=Chad Mobile;19254014]Thank You!
Now I just need one little bit of help and then I will be off:
I need to make it so if I type a phrase it will open a file, such as something like
[I]The man asks you if you can spare some change, do you wish to spare some change? Yes or No?[/I]
When you type yes, it opens a file that says something like [I]You give the man some change and continue on...blah[/I]
How would I go about doing this?[/QUOTE]
This approach seems incredibly impractical.
[QUOTE=iRzilla;19254110]Use include() maybe? :P[/QUOTE]
Doesn't exist in non-GMod Lua, use [url=http://lua.gts-stolberg.de/en/Basis.php#loadfile(filename)]loadfile[/url] instead.
[lua]
local func, err = loadfile("filename.lua")
if not func then
error( err )
else
func()
end
[/lua]
[QUOTE=Overv;19254174]This approach seems incredibly impractical.[/QUOTE]
That same approach is used in all of these kinds of games.
Actually, no, use [url=http://lua.gts-stolberg.de/en/Basis.php#dofile(filename)]dofile[/url], it's easier.
Chad breaking mah automerge!
I don't understand how to use this though.
I'm still trying to figure this out o.0
I did
[lua]
include( "level1.lua" )
[/lua]
to include the file for the 1st level, so I need a way to get from the main part to the 1st level.
[editline]05:44PM[/editline]
[QUOTE=iRzilla;19254591]Just use Visual Basic -_-
Please... :sigh:[/QUOTE]
I don't know Visual Basic and I don't really have any extreme reason to learn.
I just need one little thing to make this work, if I can get that then there really won't be much else I would need.
[editline]05:55PM[/editline]
edit:
woops lol i forgot to say what it was :doh:
If the person types 'yes' it loads one file, if they type 'no' it loads a different file.
How would I go about doing that?
I wish I hadn't missed this convo. In the read me it shows that I coded an include() function.
[code]
if (reponse == "yes") then
include( "level1_1.lua" )
else
include( "level1_2.lua" )
end
[/code]
Read the read me! I made a wrapper functions to make outputting to the console easier. I even make a game_info.lua that when load give the information need to set the title and such.
Ok thank you!
[editline]08:28PM[/editline]
i used that and it still just does 'Result:(whatever I typed)'
Well you have to edit the code.
[code]
response = Lin()
if (response == "y" or response == "Y") then
include( "level1_1.lua")
end
[/code]
Well I know I have to edit the code :P
It just didn't work.
[editline]09:28PM[/editline]
I still just get "Result:(whatever I typed)"
Show me your code, because I tried it my way and it worked.
in the game.lua:
[lua]
--This is where the primary game code goes
run = true
Lout( "As you awake in the small house,a man asks you for some change.\n Give it to him?\n" )
Lout( "--Y or N--" )
while (run) do
Lout( ">" )
cmd = Lin()
Lout( "Result: "..cmd.."\n" )
if (cmd == "quit") then
run = false
end
end
response = Lin()
if (response == "y" or response == "Y") then
Lout( "test")
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.