-
[Req]Custom User Code Object
I would like an object similar to the BASIC object, but instead with these features:
General:
-Runs simultaneously with the MMF2 application
-Uses a simple C syntax with support for various variable types and expandable array support for them
-Supports the ability for users to define thier own functions before the void main(void){}
-Good error reporting with reason, explination, and line number + character position
Specific unique features:
-Users can call any function at all, and in MMF2 we can add conditions like "On any function called" "On specific function called" and have expressions like FunctionName$ (for any function), FunctionParam$(index [0 based]) and same for numbers, ParamVarType$(index [0 based]) which returns the kind of variable that was passed as a parameter, and NumParams(). All for the function that triggered the condition. It should be an immediate condition.
-The code should pause automatically until in MMF2 you tell it to continue or you return a value. There should be a separate way to return entire arrays to a variable.
-Option in properties & runtime check/not check user function calls for user defined functions (in case they made one with the same name as one in our code) to go with this there should also be a condition "User has defined function with name 'blah'"
-Option to enable the use of #include "SomeFile.c"
-Allow ability to create, change, get, and rename variables in the code at runtime
-Allow editing of code at runtime (when code running is paused) & setting current line/stepping out of for loops and while loops
I know this is a lot of stuff, but I won't actually start to need it for a few months, maybe more. I just want to request it now that that it's done/near done when I need it. I am sure it will benifit everyone to have this ability, as it will make things a lot easier when it comes to complete user modability with games and software. For example, this could be used so that you can easily update your game without users having to redownload the exe, you just make it download the latest code file from your webspace and it interprets that. This is quite a lot of features, and I may pay for it to be made if need be. (I just hope not :crazy:) I hope this extension isn't just way to hard to make.
Examples of use:
User's Code (completely random junk just to demonstrate some things)
Code:
void MyFunction(unsigned char RndNum = 34, string RndStr = "Some random string", bool OnRndOff){ //Functions can have a 'default value'
unsigned int RndTimes = 0; //if one is not given in the function
while(RndTimes <= GetSomeNumber() && RndTimes != GetBadNumber()){ //call. They don't have to have one,
MakeSomethingHappen(RndNum, OnRndOff); //however, it just makes the code
AddSomeEffects(RndStr); //shorter sometimes.
}
return;
}
float RangeLimit(float InVal, float LowLim = -128, float HighLim = 127){
float TempR = InVal;
if(InVal < LowLim){
TempR = LowLim;
}
else if(InVal > HighLim){
TempR = HighLim;
}
return(TempR);
}
void Main(void){
int Boog = -57;
char array ConetP;
bool RandomUnusedBoolean = (5 > 7 && 4 <= 4.01 || 96 > 100);
while(true){
DoSomethingCool();
MyFunction(RangeLimit(Boog, -40, -2 + AnyNumber()));
Boog++;
ConetP[StrCmbVal("num", Boog)] = ObjPosX("Active 2"); //Arrays can have values named by a number or string
if(Conet{["num5"] == 102){ //so that there are easier to identify array values
DisplayRandomPointlessTextMessage("Yay you win!");
}
/* DeleteRandomObject();
CreateRandomObject(RandPos(0), RandPos(1)); */
}
}
And then the MMF2 code would look like this:
-Start of frame: Load user code from text (or file)
-User code is loaded: Start running code
-Function "GetSomeNumber" is called: return number Rand(1000) as type "unsigned short" //There is also one for returning a string (only one type of string variable) and some method of returing an entire array. Oh, and also some events for returning a true/false boolean value.
-Function "GetBadNumber" is called: return number 666 as type "EVIL" //If you give it a variable type the extension doesn't recognize it should assume one based on a property that can also be changed at runtime.
-Function "MakeSomethingHappen" is called & {compare two general values} NumParams() = 2 & Parameter 1 is true /* 1 is the second parameter, this condition is for booleans */: blah blah delete object FunctionParam(0), Return Void
... and ect for all the other functions that weren't defined in the user's code.
So, to sum it all up, this extension would be a way to implement the ability for users of our applications to add more functionality than is provided, or make more dynamic levels with a level editor, or other things that could be quickly done with this extension (like mentioned above), if made.
Conditions:
-Any Function is called [immediate]
-Function "name" is called [immediate]
-Parameter # is true [negatable for false]
-User Code is Loaded [negatable]
-On Error [immediate] - Syntax in code or internal extension error
-Code is Paused [negatable]
-Code is Running [negatable]
-Inside for loop [negatable]
-Inside while loop [negatable]
-End of User Code [immediate]
-Non-User-Defined variable is called [immediate]
-Function is waiting for return [negatable]
-Variable "name" exists [negatable]
-Variable "name" is undefined [negatable]
-Variable is True [negatable] - for boolean variables
-Variable is Global [negatable] - true if declared before void main(void){} or if declared anywhere else with the prefix global, eg "global unsigned short long SomeRandomVar = 7;"
-Variable is an Array [negatable]
Expressions:
-FunctionName$() - for 'Any Function is called' or 'Function is waiting for return'
-NumParams() - for current function selected by condition
-FunctionParam$(0-based param ID) - for current function selected by condition
-FunctionParam(0-based param ID) - for current function selected by condition
-ParamVarType$(0-based param ID) - for current function selected by condition, returns the type of variable that is being passed as a parameter
-ErrorString$() - for On Error
-ErrorLine() - for On Error
-ErrorChar() - for On Error
-VariableType$("name") - returns the type of variable that the variable is defined as
-VariableValue("name") - for numbers & booleans (returns 1 for true and 0 for false)
-VariableValue$("name") - for strings & booleans (returns "true" for true and "false" for false and "undefined" if the variable is undefined)
-VariableCount() - total number of currently defined variables
-VariableName$(0-based index of a currently defined variable)
- some expressions for array variables (??)
-GetCode$() - returns all the user code that is loaded into the object currently
Actions:
-Load Code from File "path\name.c"
-Load Code from Text "code"
-Start Code
-Stop Code
-Pause Code
-Unpause Code
-Go to Line
-Set ignore function calls of user functions on/off # [0 is off and 1 is on]
-Get out of current for loop/while loop and move on to the next code
-Get out of all for loops/while loops [both current and any parent loops, eg While(true){for(bool Always = true; Always; Always = true){while(true){}}} would exit all of those and move on]
-Save entire code session to file (not needed, but would be really cool)
-Load entire code session from file (again not needed but would be cool)
-Function: Return number # as type "type"
-Function: Return bool # [0 is false and 1 is true]
-Function: Return string "return string"
-Function: Return (void)
-Non-User-Defined-Variable: return number # as type "type" *
-Non-User-Defined-Variable: return bool # [0 is false and 1 is true] *
-Non-User-Defined-Variable: return string "return string" *
-Non-User-Defined-Variable: return undefined *
-User Variable: set number variable "name" to # *
-User Variable: set boolean variable "name" to # [0 is false and 1 is true] *
-User Variable: set string variable "name" to "string" *
-User Variable: set variable "name" as undefined *
-*: also have similar actions for array variables
Notes about Arrays - Arrays don't have to be implemented, but it'd be super cool of they were.
-Define by "{variable type} array {variable name};" eg "string array MyStringArray;"
-Assign values with identifiers as strings or numbers, eg MyStringArray["RandomString"] = "sjgfasuicftnr346tr8q27rwiehio"; or MyStringArray[-97] = "negative nintey-seven";
-Grab values the same way
-Via MMF2 handle arrays more in depth with the conditions, expresions, and actions. This way we can make functions available to the user to further interact with arrays.
-Set one array from another array, eg "string array MyOtherArray = MyStringArray;"
-Add values from one array into another, replacing values that may already exist, via MMF2.
-Modifying every value in a number array with ++, --, +=, -=, *=, /=, and =, eg MyOtherArray = "same";
-ect...
I think that's all I can think of for now. This will definantly be a bit of a project. If you are confused about anything at all, please ask to I can clarify. I want to make sure everything is understood properly. After all, this extension will benifit us in many ways. ;) Also please alert me if you cannot figure out what I mean if there are inconsistencies, things that aren't clear enough, or mistakes that you can't figure out what was originally meant.
Super-ultra-mega-deluxe thanks,
-LB
-
Re: [Req]Custom User Code Object
I'm not sure I understand where you're going with this. XLua is already a viable bridge between MMF and almost limitless C Module capabilities. What then would this extension do that couldn't reasonably be done in XLua?
-
Re: [Req]Custom User Code Object
I'd have to agree with Retriever2. There's also the .NET object.
-
Re: [Req]Custom User Code Object
that's it strictly for C? But btw its one of best described requests that I saw here on forums!
-
Re: [Req]Custom User Code Object
I'm trying to go for a simplistic C syntax, like just the basics of what people will understand. I have tried LUA and the .net extension (which I can't get to work without crashing) and so far I see a bit more complex structures that aren't really needed for something as simple as calling functions through MMF2 or user-made functions.
-
Re: [Req]Custom User Code Object
Err, we have an extension SDK if you want to code in C ;)
-
Re: [Req]Custom User Code Object
How are my game users suppost to make an extension and have me rebuild my game just for thier level!? I want it so that they can add some simple code to thier level and change the game's gameplay slightly to fit thier level.
-
Re: [Req]Custom User Code Object
Then what's wrong with Lua? You're trying to tell me that Lua is overcomplicated compared to C?
errr
-
Re: [Req]Custom User Code Object
Isn't Lua syntax even quite similar to C syntax?
-
Re: [Req]Custom User Code Object
There are marked differences between Lua and C. However, Lua is not a complex language by any stretch. This is the kind of stuff Lua was designed for.
-
Re: [Req]Custom User Code Object
I've been wanting something that would directly call MMF2 actions. Rather than having a condition for reading a file and if it contains Restart Frame than restart, it would be great to have an extension that uses a file and calls the commands without preprogrammed MMF2 code.
If there was an extension that could read C++ files, that would complete the AI that I'm designing. Right now it's based on multiple loops and preprogrammed code, which was dang hard to make; it's even harder to extend the AI's functions without restarting it.
-
Re: [Req]Custom User Code Object
Quote:
Originally Posted by SortaCore
an extension that could read C++ files
*facepalm*
-
Re: [Req]Custom User Code Object
The general idea is quite good but i don't like the idea of linking it to just C style code. What would be better is some sort of general code parser extensions to make custom code formats or just use current formats with simple code syntax and link them in to MMF. This is probably possible now with most readable formats but could maybe get quite complex setting it up depending on what syntax you wanted so a extension could work better for something like that. Although maybe with this idea you could just use something like XLua and make custom code parser librarys if possible.
-
Re: [Req]Custom User Code Object
Well, what do you suggest? Making an MMF2 style editor for the code? That'd be crazy as heck to make an MMF2 editor for an MMF2 game/app! The reason I want to use this C code style is because it is simple to learn yet powerful, just like MMF2. It's for advanced things, like for users who really want to kick thier level up a notch for a competition, ect.
I have looked and looked through all the LUA stuff and most of what I want to do is very difficult to do. :(
-
Re: [Req]Custom User Code Object
Unless you have an example of what is so difficult to do in XLua that is so easy with a C syntax extension, I just can't see your argument. Personally I get the feeling that you see then/end replace curly braces and a few keyword changes and panic over the syntax.
I've looked over your proposal a couple times and I'm still scratching my head as to what exactly it's supposed to do, but it looks essentially one-way, that is as your C code is running it can call "MMF Functions", but not vice-versa. All of the Lua objects are two-way, but they can be used in a one-way fashion if that's what you want. XLua also has full variable/array manipulation capabilities.
-
Re: [Req]Custom User Code Object
you should really test xLua it's all you asked for and more... You'll just have to learn an easier language...
-
Re: [Req]Custom User Code Object
Looking at XLua, I am having trouble finding what I asked for. I don't really mind syntax or anything like that (of course as long as it is sane) but I see that in the example the variables and functions haven't got a return type. This bothers me slightly in terms of memory usage. Sure, it's not that big of a deal, but I want to have more control over everthing. So, I tried editing some of the code to have some return types and it instead returned errors.
XLua looks really cool and close to what I want, but I need to know how to fully use it.
Thanks for pointing it out. :)
-
Re: [Req]Custom User Code Object
Lua is a dynamically typed language, akin to JavaScript, Python, or PHP. Internally, everything is stored in a double, or a table (an efficient ordered map .. think PHP associative arrays).
Personally, if you're going to build on top of a platform like MMF which already entails a severe overhead just dealing with the event infrastructure, there's no point in worrying about a few bytes here and there in the scripting language. IF in special cases memory is a problem (see the GC post by Pixelthief in the Lua forum), custom C modules are available or can be written to address special needs.
It's not going to be a perfect analogue to what you want, but I consider some of the proposal to be impossible, or at least highly impractical (e.g. arbitrarily stopping a script, jumping to lines .. this is all debugger behavior and quite sophisticated short of embedding a full C debugger directly into your application). Both .net and Lua at least gives you a reasonable mechanism for loading new code at runtime.
If you're still not convinced that it performs well enough, http://lua-users.org/wiki/LuaUses Lua is used in numerous high-profile commercial games and projects.
-
Re: [Req]Custom User Code Object
Have you tried Basic Object, it uses basic language, very easy to use and learn.
and have some features that will allow to calculate and organize data in short time.
-
Re: [Req]Custom User Code Object
Although Lua is so easy you're basically shooting yourself in the foot if you use a primitive language like that instead.
-
Re: [Req]Custom User Code Object
Quote:
Originally Posted by FVivolo
Have you tried Basic Object, it uses basic language, very easy to use and learn.
and have some features that will allow to calculate and organize data in short time.
FVivolo the basic object does not have what I am looking for.
@Retriever2: OK, I'll thanks for the info. :) I think I'll stick to XLua for you unless something dire comes up. ;)
-
Re: [Req]Custom User Code Object
Quote:
Originally Posted by Jamie
Although Lua is so easy you're basically shooting yourself in the foot if you use a primitive language like that instead.
Well Jamie, i know XLua has a lot potential (excellent by the way, a lot of contributors make it better everyday) but believe me the way basic object is done, help a lot to reduce calculation inside MMF.
-
Re: [Req]Custom User Code Object
And Lua doesn't do that just as easily but a lot more extensively?
-
Re: [Req]Custom User Code Object
FVivolo, as far as I can see the BASIC object just runs a script and lets you change variables. It doesn't let you interact with the script very much at all, and it also seems that the script does stuff on it's own that MMF2 app has no control over.
-
Re: [Req]Custom User Code Object
Well the script can be modify in run time, as basic allow to do, you can use load (load a different program), run and rerun, also clear memory.
You have full control and connection when you use subroutine (gosub) and during action, you choose which allow you more benefits in your project even in condition when you trigger a condition using MMFTAG command.
What basic doesn´t do is to interact with other lib created by user (excellent point in XLUA) and to be kind of object oriented is also another good point.
But you may use different script saved inside your project or add new ones during runtime in basic.
At the end, what i wanted to say in my first suggestion, is that maybe the basic object will help you :blush:
for instance
void Main(void){
int Boog = -57;
char array ConetP;
bool RandomUnusedBoolean = (5 > 7 && 4 <= 4.01 || 96 > 100);
while(true){
DoSomethingCool();
MyFunction(RangeLimit(Boog, -40, -2 + AnyNumber()));
Boog++;
ConetP[StrCmbVal("num", Boog)] = ObjPosX("Active 2"); //Arrays can have values named by a number or string
if(Conet{["num5"] == 102){ //so that there are easier to identify array values
DisplayRandomPointlessTextMessage("Yay you win!");
}
/* DeleteRandomObject();
CreateRandomObject(RandPos(0), RandPos(1)); */
}
}
The example you presented may be done in basic like this:
10 LET Boog= - 57: DIM ConetP[128]="": ExFlag = 1
20 WHILE ExFlag
30 GOSUB 100: REM "Do Something Cool Subroutine"
40 GOSUB 200: REM "AnyNumber Subroutine"
50 GOSUB 300: REM "Ramnge Limit Subroutine"
60 Boog = Boog +1
70 LET ConetP[Boog] = ObjPosX_2: REM "THIS IS SET BEFORE TO CALL THE SCRIPT, USING SET INTEGER VALUE IN ACTION MENU"
80 IF ConetP[Boog] <> 234 THEN 100
90 MSGTIT "THIS IS THE TITLE": ? "Yay you win"
100 MMFTAG "Object in MMF"; REM "THIS COMMAND WILL ALLOW TO TRIGGER A CONDITION INSIDE MMF"
110 END
-
Re: [Req]Custom User Code Object
Quote:
Originally Posted by Fvivolo
10 LET Boog= - 57: DIM ConetP[128]="": ExFlag = 1
20 WHILE ExFlag
30 GOSUB 100: REM "Do Something Cool Subroutine"
40 GOSUB 200: REM "AnyNumber Subroutine"
50 GOSUB 300: REM "Ramnge Limit Subroutine"
60 Boog = Boog +1
70 LET ConetP[Boog] = ObjPosX_2: REM "THIS IS SET BEFORE TO CALL THE SCRIPT, USING SET INTEGER VALUE IN ACTION MENU"
80 IF ConetP[Boog] <> 234 THEN 100
90 MSGTIT "THIS IS THE TITLE": ? "Yay you win"
100 MMFTAG "Object in MMF"; REM "THIS COMMAND WILL ALLOW TO TRIGGER A CONDITION INSIDE MMF"
110 END
I hate to break this to you but..
http://en.wikipedia.org/wiki/2010
-
Re: [Req]Custom User Code Object
-
Re: [Req]Custom User Code Object