home home

shots shots

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


DECORATE like extends for CubeScript

by asmanel on 02/05/2016 21:41, 14 messages, last message: 04/27/2016 23:04, 2022 views, last view: 08/09/2020 02:11

I suggest this for any game using CubeScript, not a specific one.

Several Doom ports, ZDoom and the ZDoom based ports, use a definition language called DECORATE (http://zdoom.org/wiki/DECORATE).

It's used to define several kinds of things, such as monsters and weapons.

For now, in games using CubeScript, such things are stored in hardcoded arrays, in the C++ Source Code

I suggest start with things like this (http://cubeengine.com/forum.php?action=display_thread&thread_id=1&start=15250#74505) then extend it with:
* other properties
* event based trigger (when the monster/weapon wielder/etc...
* a way to know and edit others' properties
* etc...

In other words, the idea is extend the CubeScript to provide it at least (more if possible) the possibilities of DECORATE...

   Board Index   

#1: ..

by chasester on 02/09/2016 01:01

OR

You can link in an actual script language (not just a macro forwarder[which is what cube script basically is]) and then you can put script on each objects using classes rather than archaic function code that needs to be recycled over and over to create similar objects. Furthermore objects can have properties and methods, allowing for more oo type programing rather than arbitrary global namespace variables which are hard to follow and hard to maintain. I know people who have put lua, into cube. I personally put angelscript into tesseract. But really any open source or library based scripting language goes in pretty easy, because of the way the command.cpp is set up. You could implement something using the current setup of cubes entity system, but honestly it would be hackish at best and limited, bulky etc.

chasester

reply to this message

#2: ..

by asmanel on 02/09/2016 22:27

I don't want bind CubeScript to an other language nor replace it.

I know CubeScript is a rustic language. It's old and its style is unusual.

I don't know well how it evolved in the games using the Cube 2 Engine or Tesseract.

In the Cube Engine side, however, the CubeScript was improved several times after it was said, nearly each time, this language wasn't longer improvable...

Actually, it easily can be extended at adding hardcoded variables and commands. The aliases also can be used by hardcoded functions.

My idea is implement it this way

reply to this message

#3: ..

by chasester on 02/10/2016 21:11

My point is that cube script is essentially

#define MYCOMMAND(a,b,c) { code
is
put
here
} // aka a macro

its just a macro that you can use at run time. This really isnt a language, its no more then an expanded command line. It should not, be expanded into much more then it does, because it is already extremely hard to code in, and provides no IDE or type casting or classes etc. Which will become more of a problem the more that you try to let it do. This will lead to hard to read buggy code, that people will voluntarily steer clear of :)

Cube script was meant to interface ui elements, run basic commands, and allow for some customization. IT probably already does to much, and leads to much frustration (at least for me) every time i have to code with it. Its best to put an actual script language into cube rather than trying to hack something to work for something that it was not intended to be for.

reply to this message

#4: ..

by asmanel on 02/11/2016 01:13

According to what I understood, CubeScript hardcoded variable and commands , ok, implemented via macros but not a so simplistic way.

The way it's implemented allow to add commands this way in most of the C++ source code :

type acommand (arguments) {
code
of
the
command
}

COMMAND(acommand, args);
//This is enough to use this as native CubeScript funtions


Hardcoded variables are implemented a similar way.

Here are the macros :

// nasty macros for registering script functions, abuses globals to avoid excessive infrastructure
#define COMMANDN(name, fun, sig) static bool __dummy_##fun = addcommand(#name, (void (*)())fun, sig)
#define COMMAND(name, sig) COMMANDN(name, name, sig)
#define COMMANDF(name, sig, inlinefunc) static void __dummy_##name inlinefunc ; COMMANDN(name, __dummy_##name, sig)

#define VARP(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, true)
#define VAR(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, false)
#define VARN(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, NULL, false)
#define VARNP(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, NULL, true)
#define VARF(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, false)
#define VARFP(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, true)

#define FVARP(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, true)
#define FVAR(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, false)
#define FVARF(name, min, cur, max, body) extern float name; void var_##name() { body; } float name = fvariable(#name, min, cur, max, &name, var_##name, false)
#define FVARFP(name, min, cur, max, body) extern float name; void var_##name() { body; } float name = fvariable(#name, min, cur, max, &name, var_##name, true)

#define SVARP(name, cur) char *name = svariable(#name, cur, &name, NULL, true)
#define SVAR(name, cur) char *name = svariable(#name, cur, &name, NULL, false)
#define SVARF(name, cur, body) extern char *name; void var_##name() { body; } char *name = svariable(#name, cur, &name, var_##name, false)
#define SVARFP(name, cur, body) extern char *name; void var_##name() { body; } char *name = svariable(#name, cur, &name, var_##name, true)


This is from the file command.h of the AssaultCube Reloaded source code (probably identical to the AssaultCube one).

In the Cube source code, there is a variant, with only six of these seveteen macros, in cube.h.

In each cases, the functions called are in command are in command.cpp.

It maybe is as hacky as the Quake 3 fast inverse square root(https://en.wikipedia.org/wiki/Fast_inverse_square_root) but it allow easy adds of hardcoded variables and commands.

You claim the CubeScript isn't a true script language and can't be improved. I disagree with both.

The CubeScript is a true script language. It's its purpose.

And about improving the CubeScript, anyone can do it if he/she can compile a game using it.


About DECORATE like features with CubeScript There is something similar to what I suggest in Platinum Arts Sandbox (using the Cube 2 Engine) but in this game, there is a file for each object (you can't define several objects in an same file) and a folder and a folder for each type of objects (the type of an object depend on the name of the folder where it's defined).

The way I thought to implement this doesn't need several files.

reply to this message

#5: CUBE SCRIPT -.-

by chasester on 02/12/2016 18:00

Cube script is an advance command line interface, (in my opinion). To be a "real language" (in my book), you must have at least the following:
type definitions: the ability to define a variable as a particular type.
classes: or some type of structure that allows you to store variables and functions.
Protection: some type of interface, that allows you to be able to protect key variables functions etc from being accessed from any file. (All thing in cube are global, so this mean i can rename a key variable an not even know it, completely screwing up my game.)
Function Parameters: Though cube does have parameters, there is not structure them, meaning that functions must have a list of parameters, limited/required by a number. (In cube you can call a function [really cant even call them that tbh] with as many or as few args are you want [up to the max amount of args].

Cube Script is at best hacking, but its a good hack when used for binding keys, or calling basic interface like gui or simple command interfaces. If you try attaching more than necessary you just end up with a very big unmanageable mess, and a lot of coping and pasting code, and checking things that really just get annoying after a while. if(= numargs 1) [ ] if(= numargs 2) [ ] ect. its really just annoying tbh.

@Fast inverse square root
This is one function, not an entire interface. What you are doing is like trying to knock down a stone wall with a sword. Ya you can do it, after a long and very painful time. Many years later, you may have cracks in the all. But tnt is better fast, more efficient, it may cost a little more (memory, frame speed etc) but the benefits majorly out lay the problems, LIKE MAJORLY.

I've implemented as (angel script) into tesseract. I'm sure assault cube would be just as easy to implement it into. Or lua if you prefer. Honestly just adding a few extra commands to cube really isn't gonna fix any of the entity issues in cube.

But regardless, You either agree or you don't, so gl with what ever path you choose :)

chasester

reply to this message

#6: ..

by asmanel on 02/13/2016 03:32

Most of the existing programming languages, including several popular ones, such as the Pascal (not longer popular today but very popular by the past) and the C, doesnt't match your defintion.

However, the hardcoded variables have limits. You can't set them beyond these limits. There also are read only variables. In AC/ACR there also are two other securities :
* the contexts mechanism, that prevent the use of unusual commands depending on the context.
* the command const, that works like alias except what is set with const can't be modified again.

Coding with CubeScript doesn't need copy/paste more than with C and it isn't harder to manage or read

Things like "if(= numargs 1) [ ] if(= numargs 2) [ ]" are rare and dumb.

About the fast inverse square root, I never said it was an interface. I just said this function looked as hacky (strange) as the macros that allow easy adds of commands.

I don't believe it harder or longer than replace CubeScript with an other language.

About AssaultCube, there is a modded version of the server program using Lua instead of CubeScript but the AC developpers seem to prefer CubeScript, like, apparently, most of the AC community.

reply to this message

#7: ..

by chasester on 02/15/2016 20:05

Ok :)

Think what you like :) gl

reply to this message

#8: ..

by asmanel on 02/20/2016 02:21

This discussion isn't over.

Please, don't be reserved and don't follow the "others will do it" logic (https://framasphere.org/posts/894244)

reply to this message

#9: Re: ..

by suicizer03 on 02/20/2016 11:09, refers to #8

Exactly, now you should do it =P.

reply to this message

#10: Re: ..

by Papriko on 02/20/2016 12:37, refers to #8

Isn't that exactly what you did/do? "Here's my idea, now get to work!"
And now you tell others not to act that way and get to work on your suggestion. Don't you see the irony in this?
You proposed the idea, so you should do the main bulk of work.

reply to this message

#11: Re: ..

by suicizer03 on 02/20/2016 13:04, refers to #8

Some more serious answer;

It seems like you're one of the very few who care that the "importcube" feature isn't working like it could work (or in the way you've described).
I suggest you make a mod for it that it does.

reply to this message

#12: ..

by asmanel on 02/21/2016 14:07

I'll do it.

For now, I'm trying to fix compiling problems to compile a game using the Cube Engine.

Once this game successfilly compiled, I'll be able to start the work to implement it.

reply to this message

#13: ..

by Zamwa on 04/26/2016 02:02

People posted some threads if it's any help http://quadropolis.us/node/3761 http://quadropolis.us/node/2560

It's a small change for sauer and tesseract but I know a mech game using cube 2 could use it well! Though who knows if it will become active again!

https://code.google.com/archive/p/mech-arcade/

reply to this message

#14: ..

by asmanel on 04/27/2016 23:04

These two thread on Quadropolis are about compiling problems. I had compiling problems but, now, it work fine.

About mech-arcade, it seems to only be a data mod, but it contain nice content.

reply to this message

   Board Index   


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2020
website by SleepwalkR © 2001-2020
34519869 visitors requested 49442291 pages
page created in 0.013 seconds using 10 queries
hosted by Boost Digital