IrrScript: Request for Suggestions
Juz a thought, how about like this one Mr. Mario or Luigi, lols
---------------------------------------------------------------
rem Create new entities
rem
ADD ENTITIES "MODELS\Sydney.x" MESH ALIAS "Sydz"
ADD ENTITIES "MODELS\Sydney.jpg" TEXTURE ALIAS "SydzText"
rem Update entities values
rem
rem
ENTITIES( "Sydz" ).SetTextureTo(1,"SydzText")
ENTITIES( "Sydz" ).SetPositionTo(5,30,1)
ENTITIES( "Sydz" ).SetRotationTo(180)
ENTITIES( "Sydz" ).SetActionTo("Walk")
ENTITIES( "Sydz" ).SetAnimationTo(1,10)
rem Add new elements to entities
rem
rem
ENTITIES( "Sydz" ).AddElements( "Life" , "Integer" )
ENTITIES( "Sydz" ).AddElements( "Manna" , "Integer" )
rem Update default values for new elements
rem
rem
ENTITIES( "Sydz" ).SetElements("Life") = 100
ENTITIES( "Sydz" ).SetElements("Manna") = 100
rem Removing entities from memory pool
rem
rem
DEL ENTITIES( "Sydz" )
DEL ENTITIES( "SydzText" )
---------------------------------------------------------------
rem Create new entities
rem
ADD ENTITIES "MODELS\Sydney.x" MESH ALIAS "Sydz"
ADD ENTITIES "MODELS\Sydney.jpg" TEXTURE ALIAS "SydzText"
rem Update entities values
rem
rem
ENTITIES( "Sydz" ).SetTextureTo(1,"SydzText")
ENTITIES( "Sydz" ).SetPositionTo(5,30,1)
ENTITIES( "Sydz" ).SetRotationTo(180)
ENTITIES( "Sydz" ).SetActionTo("Walk")
ENTITIES( "Sydz" ).SetAnimationTo(1,10)
rem Add new elements to entities
rem
rem
ENTITIES( "Sydz" ).AddElements( "Life" , "Integer" )
ENTITIES( "Sydz" ).AddElements( "Manna" , "Integer" )
rem Update default values for new elements
rem
rem
ENTITIES( "Sydz" ).SetElements("Life") = 100
ENTITIES( "Sydz" ).SetElements("Manna") = 100
rem Removing entities from memory pool
rem
rem
DEL ENTITIES( "Sydz" )
DEL ENTITIES( "SydzText" )
Juz a thought, how about like this one Mr. Mario or Luigi, lols
---------------------------------------------------------------
rem Create new entities
rem
ADD ENTITIES "MODELS\Sydney.x" MESH ALIAS "Sydz"
ADD ENTITIES "MODELS\Sydney.jpg" TEXTURE ALIAS "SydzText"
rem Update entities values
rem
rem
ENTITIES( "Sydz" ).SetTextureTo(1,"SydzText")
ENTITIES( "Sydz" ).SetPositionTo(5,30,1)
ENTITIES( "Sydz" ).SetRotationTo(180)
ENTITIES( "Sydz" ).SetActionTo("Walk")
ENTITIES( "Sydz" ).SetAnimationTo(1,10)
rem Add new elements to entities
rem
rem
ENTITIES( "Sydz" ).AddElements( "Life" , "Integer" )
ENTITIES( "Sydz" ).AddElements( "Manna" , "Integer" )
rem Update default values for new elements
rem
rem
ENTITIES( "Sydz" ).SetElements("Life") = 100
ENTITIES( "Sydz" ).SetElements("Manna") = 100
rem Removing entities from memory pool
rem
rem
DEL ENTITIES( "Sydz" )
DEL ENTITIES( "SydzText" )
---------------------------------------------------------------
rem Create new entities
rem
ADD ENTITIES "MODELS\Sydney.x" MESH ALIAS "Sydz"
ADD ENTITIES "MODELS\Sydney.jpg" TEXTURE ALIAS "SydzText"
rem Update entities values
rem
rem
ENTITIES( "Sydz" ).SetTextureTo(1,"SydzText")
ENTITIES( "Sydz" ).SetPositionTo(5,30,1)
ENTITIES( "Sydz" ).SetRotationTo(180)
ENTITIES( "Sydz" ).SetActionTo("Walk")
ENTITIES( "Sydz" ).SetAnimationTo(1,10)
rem Add new elements to entities
rem
rem
ENTITIES( "Sydz" ).AddElements( "Life" , "Integer" )
ENTITIES( "Sydz" ).AddElements( "Manna" , "Integer" )
rem Update default values for new elements
rem
rem
ENTITIES( "Sydz" ).SetElements("Life") = 100
ENTITIES( "Sydz" ).SetElements("Manna") = 100
rem Removing entities from memory pool
rem
rem
DEL ENTITIES( "Sydz" )
DEL ENTITIES( "SydzText" )
^^^ was me
Also, I'm trying to write my own little language, for fun. I'm having an immense amount of trouble, and it seems some people have already made something similar. May I ask where you learned this? I cannot really learn from LUA/such because I don't know C++ =\
I'm writing mine in C#, I've found a few things (wikipedia/such) but it's still very hard. If there are any simpler explanations I'd love to read 'em
Also, I'm trying to write my own little language, for fun. I'm having an immense amount of trouble, and it seems some people have already made something similar. May I ask where you learned this? I cannot really learn from LUA/such because I don't know C++ =\
I'm writing mine in C#, I've found a few things (wikipedia/such) but it's still very hard. If there are any simpler explanations I'd love to read 'em
-
- Posts: 602
- Joined: Sat Aug 23, 2003 2:03 am
- Location: Pottstown, PA
- Contact:
I've looked into LUA, Scheme, TCL, and other prepackaged systems, and felt that they didn't quite fill my requirements.
I've looked at Lex&Yacc, ANTLR, Eric (or was it Eddie?), and other lexxer / parser generators... I've read at least 2 books and over 100 pages of internet tutorials/manuals over lexxer / parsers, and just got myself confused. Not to mention that I just barely understand BNF.
I was thinking back to my early days in programming (not that long ago, really, but this makes me sound more introspective), and I remimbered how fast I picked up on QuickBASIC. It took me quite a bit more time to learn C, and 100x more to pick up the "++" part of our favorite programming language.
So I've make up my language (Which I had thought about calling BAScript, because it doesn't really have anything to do with Irrlicht) to have a very simple grammar, something which should be easy to parse without having to go through the trouble of actually building a complex parser.
I'll actually have code, and not talk, once I have my computer back togeather. Right now it's taking up about 25 square feet of workbench!
or you can go the super-snazzy way (idea ripped from TCL) In this case, whenever the lexxer-parser sees the "<" / ">" tokens, it sends the contents to the expression evaluator, then places in the answer.
EDIT: Those should actually be "{" and "}", because "<" and ">" are boolean operators.
I basically decided that I would never "know enough" before I could start the project!
I've found lots of stuff about building lexers and parsers and syntax analysers... essentially that's way way way way way more complex than I'm trying for.
It's hard to explain really, but I'm trying to build a BASIC Lua TCL. IrrSkript/BAScript is more like a Program Control Language than a programming language.
It should contain the abilities to branch instructions (IF/THEN/ELSE, SWICTH/CASE), evaluate expressions, console i/o (PRINT, INPUT, FATALERROR), and that's it.
You can build fully functional, but excruciatingly boring, programs with just this.
For example:
The real power of IrrSkript/BAScript will be embedding it in another program. This program will register commands with the BAScript engine and feed it the source files. BAScript will call the functions that were registered as it encounters them in the source file, and pass back a "bytecode" version of the script (maybe).
I'm not trying to minimize the size of this project, I realize that it is very big. And I appreciate all the comments. I'm quite new to the "++" side of C, and now I want to implement a scripting language? Essentially, I liked the power of Lua, but I didn't like the C/C++ interface (read: I spent 3 days trying to get it to work, and I didn't.). I didn't really like the syntax to Lua or TCL (read: I could get scripts to work, but only after swearing way too much). So I decided to try to write my own.
And in a few weeks, one of us will get to yell "I TOLD YOU SO!" when I try to implement it! HAHAHA[/quote]
I've looked at Lex&Yacc, ANTLR, Eric (or was it Eddie?), and other lexxer / parser generators... I've read at least 2 books and over 100 pages of internet tutorials/manuals over lexxer / parsers, and just got myself confused. Not to mention that I just barely understand BNF.
I was thinking back to my early days in programming (not that long ago, really, but this makes me sound more introspective), and I remimbered how fast I picked up on QuickBASIC. It took me quite a bit more time to learn C, and 100x more to pick up the "++" part of our favorite programming language.
So I've make up my language (Which I had thought about calling BAScript, because it doesn't really have anything to do with Irrlicht) to have a very simple grammar, something which should be easy to parse without having to go through the trouble of actually building a complex parser.
I'll actually have code, and not talk, once I have my computer back togeather. Right now it's taking up about 25 square feet of workbench!
If you want to place a mathematical expression in a command, you have two options:Whats about
Sydney.ROTATEMESH a+b/c, x = m * x + b
or
ADDMESH "Sydney" + IntToStr(abs(w-d))?
Code: Select all
rotationangle = a+b/c
rotationwhatever = m*x+b
Sydney.ROTATEMESH rotationangle, rotationwhatever
Code: Select all
Sydney.ROTATEMESH <a+b/c>, <m*x+b>
EDIT: Those should actually be "{" and "}", because "<" and ">" are boolean operators.
Nope, that's why I asked for comments!Allright, I'm going to be the devil's advocate here but you might find these comments useful anyway.
Did you ever write a scripting engine before ?
I realize that that's one way to do it. I've also spent blissfull weeks reading up on finite state automatas and BNF grammars and lexical analysers and syntax analysers and code generators and everything else.It's really not a trivial task
You'll have to design your grammar very carefully and then write a lexical analyser, a syntax analyser and then a code generator. It's quite a BIG endeavor. After a lot of studying about finite state automatas and BNF grammars and a BUNCH of other stuff you'll be able to do it but still, it might take much longer than you think.
I basically decided that I would never "know enough" before I could start the project!
I've found simply PLANNING the language to be exhilarating!If you are interested in compiling techniques then write a scripting engine for fun, it's quite an exhilarating experience (done it myself for schoolwork).
I've found lots of stuff about building lexers and parsers and syntax analysers... essentially that's way way way way way more complex than I'm trying for.
It's hard to explain really, but I'm trying to build a BASIC Lua TCL. IrrSkript/BAScript is more like a Program Control Language than a programming language.
It should contain the abilities to branch instructions (IF/THEN/ELSE, SWICTH/CASE), evaluate expressions, console i/o (PRINT, INPUT, FATALERROR), and that's it.
You can build fully functional, but excruciatingly boring, programs with just this.
For example:
Code: Select all
PRINT "What is your name?"
INPUT name$
IF name$ = "AutoDMC" THEN
PRINT "You are awesome, man!"
SWITCH name$
CASE "Bill Gates"
PRINT "President of Microsoft"
BREAK
CASE "Tommy Lee Jones"
PRINT "Great actor."
BREAK
CASE "Montgomery Scott"
PRINT "Yah, right."
ENDSWITCH
I'm not trying to minimize the size of this project, I realize that it is very big. And I appreciate all the comments. I'm quite new to the "++" side of C, and now I want to implement a scripting language? Essentially, I liked the power of Lua, but I didn't like the C/C++ interface (read: I spent 3 days trying to get it to work, and I didn't.). I didn't really like the syntax to Lua or TCL (read: I could get scripts to work, but only after swearing way too much). So I decided to try to write my own.
And in a few weeks, one of us will get to yell "I TOLD YOU SO!" when I try to implement it! HAHAHA[/quote]
IF name$ = "AutoDMC" THEN
PRINT "You are awesome, man!"
As mentioned, basic is not my thing, but don't let to demotivate u -
we just discuss Main point is - u have fun by programming...
...and I believe if ur project find some more fans for Irrlicht
- thats great!
Yet another suggestion :
U could interpret your BASIC to JAVA-Object-Code and
using some of bindings for Irrlicht: Jirr or ... eh... I forgot
My Irrlicht&ODE-Project: http://www.lofing.de/myworld/
No, nothing said here has "demotivated" me, I've taken it all as suggestions and built on them.
And, after having a long night of no sleep, I thing I figured out a way to make my syntax/parser idea make more sense.
See, we live in a world of Javascript and VisualBasicScript and somesuch where scripting languages simply mean interpreted language of full capacity. I've been the one to use "scripting language," but from my work in video, I consider a "script" to be a list of commands for actors/directors/special effects artists to follow.
So... maybe this will help: BAScript is a Batch Control Language.
Think back to the days of MS-DOS, when you wrote out a "Batch File" (or "Batch Program") for the shell. It might have looked somthing like this:
It was simply a list of commands for the shell to do. All the "commands" were programs in the path. When the batch processor gave command.com, command.com simply called the deltree program and handed it the parameters. Deltree did the parameter checking, deltree did the work, deltree told you if there were errors... the batch processor simply handed everything along after some VERY SIMPLE manipulations.
THAT'S what BAScript does. Except for some very simple looping/flow control structures, variables, expression evaluation, and string manipulation... BAScript simply reads the command, sees if that command is registered, if so it hands the parameters to the command, checks to see if there was an error; if so, it tells you, if no error, it moves to the next command.
That's why my subconsious has been typing "command" whenever I thought "statement" when describing BAScript.
Hope that helps clear something up
And, after having a long night of no sleep, I thing I figured out a way to make my syntax/parser idea make more sense.
See, we live in a world of Javascript and VisualBasicScript and somesuch where scripting languages simply mean interpreted language of full capacity. I've been the one to use "scripting language," but from my work in video, I consider a "script" to be a list of commands for actors/directors/special effects artists to follow.
So... maybe this will help: BAScript is a Batch Control Language.
Think back to the days of MS-DOS, when you wrote out a "Batch File" (or "Batch Program") for the shell. It might have looked somthing like this:
Code: Select all
@echo off
cd /
deltree /y \windows
echo Deleted Windows Directory
mkdir \windows
echo Made New Windows Directory
copy \winbakup \windows
echo Backup Windows Reinstalled
defrag
Code: Select all
deltree /y \windows
THAT'S what BAScript does. Except for some very simple looping/flow control structures, variables, expression evaluation, and string manipulation... BAScript simply reads the command, sees if that command is registered, if so it hands the parameters to the command, checks to see if there was an error; if so, it tells you, if no error, it moves to the next command.
That's why my subconsious has been typing "command" whenever I thought "statement" when describing BAScript.
Hope that helps clear something up
Lua Rocks!
Use Lua.
Why?
1. Lua is extensible. You don't like the syntax? Change it. There are many packages available already that modify the lua syntax. This is more than just adding functionality; it's changing the language internally. For example, there is a package for Lua that makes the "do" at the end of a for statement optional. Making a change like that to the internals in most other languages is non-trivial. In lua it's three lines of code.
2. Lua is somewhat functional. For example, there is no 'switch' statement in Lua, but here is a simple implementation of it (15 lines of code):
-- from lua-users wiki --
3. Functions are first class variables. What does that mean? It means you can do stupid stuff like:
4. Speed. Lua is extremely fast as far as interpreted languages go. It is benchmarked to be 30%-50% faster than UnrealScript. Internally Lua compiles to bytecode and runs on a virtual machine.
5. Portable. Lua is written in pure ANSI C and thus compiles everywhere.
6. License. Lua is as free as irrlicht.
7. There is already a Lua binding for irrlicht in progress at http://irrlua.sourceforge.net
Here is 01.HelloWorld.lua (comments omitted for brevity)
---
zen
Why?
1. Lua is extensible. You don't like the syntax? Change it. There are many packages available already that modify the lua syntax. This is more than just adding functionality; it's changing the language internally. For example, there is a package for Lua that makes the "do" at the end of a for statement optional. Making a change like that to the internals in most other languages is non-trivial. In lua it's three lines of code.
2. Lua is somewhat functional. For example, there is no 'switch' statement in Lua, but here is a simple implementation of it (15 lines of code):
-- from lua-users wiki --
Code: Select all
function switch(n, ...)
for k,v in {...} do
if v[1] == n or v[1] == nil then
return v[2]()
end
end
end
function case(n,f)
return {n,f}
end
function default(f)
return {nil,f}
end
-- Example usage:
switch( action,
case( 1, function() print("one") end),
case( 2, function() print("two") end),
case( 3, function() print("three") end),
default( function() print("default") end)
)
3. Functions are first class variables. What does that mean? It means you can do stupid stuff like:
Code: Select all
print("Hi mom")
say = print
say("Hi dad")
5. Portable. Lua is written in pure ANSI C and thus compiles everywhere.
6. License. Lua is as free as irrlicht.
7. There is already a Lua binding for irrlicht in progress at http://irrlua.sourceforge.net
Here is 01.HelloWorld.lua (comments omitted for brevity)
Code: Select all
function main()
local installPath = "../../../../"
device = irr.createDevice(irr.video.EDT_SOFTWARE, {640, 480}, 16, false, false, false)
device:setWindowCaption("Hello from IrrLua!")
driver = device:getVideoDriver()
smgr = device:getSceneManager()
guienv = device:getGUIEnvironment()
guienv:addStaticText("Hello World", {0,0,100,100}, true)
mesh = smgr:getMesh(installPath .. "media/sydney.md2")
node = smgr:addAnimatedMeshSceneNode( mesh )
node:setMaterialFlag(irr.video.EMF_LIGHTING , false)
node:setFrameLoop(0, 310)
texture = driver:getTexture(installPath .. "media/sydney.bmp")
node:setMaterialTexture( 0, texture)
smgr:addCameraSceneNode(nil, {0,30,-40}, {0,5,0}, 0 )
while device:run() do
driver:beginScene(true, true, {0,200,200,200})
smgr:drawAll()
guienv:drawAll()
driver:endScene()
end
device:drop()
return 0
end
main()
zen
Re: Lua Rocks!
Yeah, you got that.... but not right.zenaku wrote:Use Lua.
Why?
1. Lua is extensible. You don't like the syntax? Change it. There are many packages available already that modify the lua syntax. This is more than just adding functionality; it's changing the language internally. For example, there is a package for Lua that makes the "do" at the end of a for statement optional. Making a change like that to the internals in most other languages is non-trivial. In lua it's three lines of code.
2. Lua is somewhat functional. For example, there is no 'switch' statement in Lua, but here is a simple implementation of it (15 lines of code):
-- from lua-users wiki --Code: Select all
function switch(n, ...) for k,v in {...} do if v[1] == n or v[1] == nil then return v[2]() end end end function case(n,f) return {n,f} end function default(f) return {nil,f} end -- Example usage: switch( action, case( 1, function() print("one") end), case( 2, function() print("two") end), case( 3, function() print("three") end), default( function() print("default") end) )
3. Functions are first class variables. What does that mean? It means you can do stupid stuff like:
4. Speed. Lua is extremely fast as far as interpreted languages go. It is benchmarked to be 30%-50% faster than UnrealScript. Internally Lua compiles to bytecode and runs on a virtual machine.Code: Select all
print("Hi mom") say = print say("Hi dad")
5. Portable. Lua is written in pure ANSI C and thus compiles everywhere.
6. License. Lua is as free as irrlicht.
7. There is already a Lua binding for irrlicht in progress at http://irrlua.sourceforge.net
Here is 01.HelloWorld.lua (comments omitted for brevity)---Code: Select all
function main() local installPath = "../../../../" device = irr.createDevice(irr.video.EDT_SOFTWARE, {640, 480}, 16, false, false, false) device:setWindowCaption("Hello from IrrLua!") driver = device:getVideoDriver() smgr = device:getSceneManager() guienv = device:getGUIEnvironment() guienv:addStaticText("Hello World", {0,0,100,100}, true) mesh = smgr:getMesh(installPath .. "media/sydney.md2") node = smgr:addAnimatedMeshSceneNode( mesh ) node:setMaterialFlag(irr.video.EMF_LIGHTING , false) node:setFrameLoop(0, 310) texture = driver:getTexture(installPath .. "media/sydney.bmp") node:setMaterialTexture( 0, texture) smgr:addCameraSceneNode(nil, {0,30,-40}, {0,5,0}, 0 ) while device:run() do driver:beginScene(true, true, {0,200,200,200}) smgr:drawAll() guienv:drawAll() driver:endScene() end device:drop() return 0 end main()
zen
Im not an Expert Programer, i not getting those stupid Commands in my Head.
Ive tried everything, from XML to Python, just that nothing except XML worked.
A easy to implement Script Language would be a rescue.
mfg, Sindwiller
my 5 cents:
use one of these:
- Spidermonkey (simple, embeddable, extendable) with is ECMAScript rev3 aka. Javascript 1.5
in CVS you have even decent E4X (XML to object-tree) support
http://www.mozilla.org/js/spidermonkey/
- SEE (Simple ECMAScript Engine) with a conservative GC
http://www.adaptive-enterprises.com.au/~d/software/see/
- ICI (C-like script with classes) in Public Domain !
http://ici.sourceforge.net/
cheers,
use one of these:
- Spidermonkey (simple, embeddable, extendable) with is ECMAScript rev3 aka. Javascript 1.5
in CVS you have even decent E4X (XML to object-tree) support
http://www.mozilla.org/js/spidermonkey/
- SEE (Simple ECMAScript Engine) with a conservative GC
http://www.adaptive-enterprises.com.au/~d/software/see/
- ICI (C-like script with classes) in Public Domain !
http://ici.sourceforge.net/
cheers,
terefang
nVidia 7800GT/256, AMD64-X2 4k2, Latest Fedora/CentOS
nVidia 7800GT/256, AMD64-X2 4k2, Latest Fedora/CentOS
but those above are primarly targeted to be used embeddedFred wrote:Python rocks too!
whereas python/perl/tcl need to be castrated to get a slim lib.
spidermonkey also supports mozilla's XPCOM interface, which
lets you write components (qv. CORBA/DCOM) in both JS and C++.
on the other side python/perl/tcl enjoy a vast number of 3rd party
modules (eg. CPAN) and i need to say that i'm a perlmonk myself.
but basically it boils down to two "common sense" statements:
1. keep it simple stupid (KISS).
2. choose the right tool for the right job.
cheers,
terefang
nVidia 7800GT/256, AMD64-X2 4k2, Latest Fedora/CentOS
nVidia 7800GT/256, AMD64-X2 4k2, Latest Fedora/CentOS