Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » A Scripting Language.

This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
A Scripting Language.
Marcello
Member #1,860
January 2002
avatar

Didja try the makefile spellcaster pasted earlier?

Here's my slightly modified version.

Marcello

curtis warren
Member #3,898
September 2003

Yep. I get this error:

C:\spidermonkey>make -f makefile.txt
makefile.txt:42: *** missing separator.  Stop.

Which is this line:

# Pattern rules
COMPILE=gcc -c  -g -ggdb -Wall -Werror -w -o "$(OUTDIR)/$(*F).o" $(CFG_INC) "$<" -DXP_PC -DWIN32 -DEXPORT_JS_API -D_declspec=__declspec
...
$(OUTDIR)/%.o : spidermonkey/%.c
    $(COMPILE) # <----- this one

Marcello
Member #1,860
January 2002
avatar

That's cause you need to convert the spaces to tabs. Try my version.

Marcello

curtis warren
Member #3,898
September 2003

Yeah, your version worked. One question, though. Do you happen to know the command to make a shared library in gcc? Thanks, btw.
EDIT:
Ok, I found it.

Karadoc ~~
Member #2,749
September 2002
avatar

Just while we have so many people all fired up talking about scripting languages, I have a small question:

Is there an easy way to remove functionality from embedded Lua, or from Python or JavaScript for that matter?
I mean, if I use some scripting language, and I don't want the user to have the ability to erase files using a script in my program, then is there an easy way for me to just say "look. I want you as the scripting language, but you can't bring the following functions with you: fopen(), system(), ..." or whatever.

-----------

Korval
Member #1,538
September 2001
avatar

Quote:

I mean, if I use some scripting language, and I don't want the user to have the ability to erase files using a script in my program, then is there an easy way for me to just say "look. I want you as the scripting language, but you can't bring the following functions with you: fopen(), system(), ..." or whatever.

In Lua, you just don't give the script that ability.

The way it works, you have an object called the "lua_state". This object, conceptially, represents an instance of the interpreter. To give a script the ability to call a particular function, you register it with Lua. Now, Lua comes with a library of standard functions, one of which is for IO. If you don't register the IO library, and you don't expose user-defined functions to allow the script to write to a file, then it can't have IO.

If you want to have some scripts that can do this and others that can't, then you have several "lua_state" objects. For some "lua_state" objects, you allow IO, for others, you don't.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

In Lua, you just don't give the script that ability.

Yes, we all know how much you love lua, time to stop ranting.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro SVN Snapshots] - [Allegro TODO] - [Web Hosting]
"God Bless Joe Pesci" -- George Carlin
"Goto is the buldozer of coding. Sometimes, the buldozer is just the right tool for the job. Not often, but sometimes." -- LordBob

Marcello
Member #1,860
January 2002
avatar

javascript doesn't have fopen/system/etc. Plus it has a security interface thingy:

from the very very bottom of http://www.mozilla.org/js/spidermonkey/apidoc/jsguide.html said:

With JavaScript 1.3, the JS engine added security-enhanced API functions for compiling and evaluating scripts and functions passed to the engine. The JS security model is based on the Java principals security model. This model provides a common security interface, but the actual security implementation is up to you.

One common way that security is used in a JavaScript-enabled application is to compare script origins and perhaps limit script interactions. For example, you might compare the codebase of two or more scripts in an application and only allow scripts from the same codebase to modify properties of scripts that share codebases.

http://www.mozilla.org/js/spidermonkey/apidoc/jsguide.html

Although it doesn't seem uber-simple, I'm not sure how powerful you need that stuff in a game. That security manager is so you can have like core scripts in the game which can't be screwed up by scripts users load in.

Marcello

Zaphos
Member #1,468
August 2001

Python also has a system to run 'untrusted' scripts without being a security threat. By default, however, python lets a script do anything, so it would be a good idea to remember to implement that if you want to implement a user addon system.

TF: Actually, his comment was a relevant and good answer to the question, I thought. He probably only mentioned LUA because that's what he knows about.

Mark Robson
Member #2,150
April 2002

Bear in mind the NJS Javascript interpreter (google for it)

It's probably not as complete as the Mozilla one, but a lot smaller, simpler, and can be extended by adding new classes quite easily.

There is a class which enables File I/O, but I'm sure it can be removed at compiletime (or possibly runtime, by just setting its constructor to null)

Mark

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

TF: Actually, his comment was a relevant and good answer to the question, I thought. He probably only mentioned LUA because that's what he knows about.

What I read of that post, he's already said at least once in this thread.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro SVN Snapshots] - [Allegro TODO] - [Web Hosting]
"God Bless Joe Pesci" -- George Carlin
"Goto is the buldozer of coding. Sometimes, the buldozer is just the right tool for the job. Not often, but sometimes." -- LordBob

Marcello
Member #1,860
January 2002
avatar

Does njs javascrit interpreter have a compiler?

Marcello

Korval
Member #1,538
September 2001
avatar

Quote:

Yes, we all know how much you love lua, time to stop ranting.

I appologize for answering his question.

Quote:

What I read of that post, he's already said at least once in this thread.

Where? I may have mentioned that it was possible using Lua, but I certainly didn't mention the specific mechanics involved in actually accomplishing the task. And the specific mechanics involved are important to know when one is evaluating a language for use, based on a set of critera.

Karadoc ~~
Member #2,749
September 2002
avatar

Come on guys, stop the bickering. Sure it might be entertaining for you guys, but for the rest of us it's just spam.
If you want to talk about how much you hate each other or whatever it is, you should get together on MSN or something equally as not-near-me.

"Hey, how's it going?"
"Oh sure, I'm great."
"You would say that wouldn't you, you always think you're the greatest."
"Oh, and I suppose you think that you're better? You should just go back to your little hole."
"At least I have a little hole..."

heh.
Sorry, I'm just entertaining myself with the idea if having a hate meeting. If there is one thing I like, it's to hate.

As for the scripting stuff, thanks for the reply. If I feel like using one of those things, I think I'll go with PYTHON! It seems that it is just as good a language as the others, and perhaps a more useful language outside of scripting. I'd rather learn a useful language than a language just for the few games with scripts that I make.
Not to say the others aren't useful, I just like the look of Python. Lua, by the sound of it is the easiest to plug into your game, but I was put off by it about a year ago when I couldn't get the damn thing to compile without stuffing around with it for a long time... I figured that if compiling it was this bad, then making it work with my game wasn't going to be easy.

Well. Back to lurking for me.
waves

-----------

Marcello
Member #1,860
January 2002
avatar

Heh, I use javascript more frequently than any other scripting language. Mainly because I can use java and C++ for serious stuff. But between web and flash, javascript is used quite a bit.

I guess now that I have this possibility I should go back to paper and start designing the interface.

Marcello

 1   2   3   4 


Go to: