lucid's Forum Posts

  • From what I can gather he wants to do something like:

    Sprite("Some text" & Sprite('A number'))

    This isn't possible, you must explicitly name the variable you want to use in an expression, it can't be dynamically built at runtime through other values/expressions.

    I think that was a typo that was causing his numeric nonsense glitch

    I think he meant to say

    somestring ="Some text" & Sprite('A number')

  • I don't think what you want to do is supported (dynamic private variable grabbing). You could put the sprite in a container with a hash table, but currently you can't set up initial hash table variables, so I'm not sure if that solution will appeal to you.

    I think you may have misunderstood him rich, I think what he's asking is perfectly possible, it's just that it was converting his string value to a numeric value

  • Actually, the + is used for addition where as the & is used for concatenation. I tried the + first unknowingly.

    http://apps.sourceforge.net/mediawiki/construct/index.php?title=Expressions

    I see, my mistake,

    just for info though

    The & operator is a very useful way of combining numbers in to strings. It automatically converts any numbers to a string and appends them. For example, instead of:

    "You have " + str(Player('lives')) + " lives left!"

    you can use the & operator like so:

    "You have " & Player('lives') & " lives left!"

    now, on to your question:

    if you copied this verbatim from your cap:

    SET NPC('STATUS'): NPC.Value(NPC.Value('STRING'))[/code:1nzvmaxx]
    that is where the problem is
    I'm sure it's a typo, but it should just be 
    NPC.Value('STRING')
    not 
    NPC.Value(NPC.Value('STRING'))
    
    the second one I'm not sure is even supposed to work, but it converts your private variable to it's native type.  private variables are numeric unless you use the private variable manager to create them.  this won't matter at all though if you take out the extra npc.value('.  construct automatically converts to whatever it should be
  • for the physics,

    Sprite[Physics].VelocityX[/code:1n72dx8u]
    this is an expression under the 'physics' tab when you double click your sprite
    and will return the left and or right speed of your object
    if Sprite[Physics].VelocityX is less than 0 it's going left, and if it's greater than 0 it's going to the right
    
    if you only want a simple left or right value:
    direction will be either -1 for left, 0 for not moving, or 1 for right if you :
    [code:1n72dx8u]
    direction = Sprite[Physics].VelocityX/abs(Sprite[Physics].VelocityX)[/code:1n72dx8u]
    abs is found under the system object and is the absolute value function 
    
    if you want more than just left or right and you want the actual angle it's moving at, that is also possible:
    [code:1n72dx8u]angle(0, 0, Sprite[Physics].VelocityX, Sprite[Physics].VelocityY)[/code:1n72dx8u]
    
    with bullet it would be the same thing, but with Sprite[Bullet].VectorX, etc instead of Sprite[Physics].VelocityX
    
    if you need the family to be both bullets and physics, there is a messier way to do it:
    
    make each object have a private variable LastX that gets set to the current x value at the end of each tick
    
    for left and right
    [code:1n72dx8u]LeftorRightness=sprite('LastX')-Sprite.x[/code:1n72dx8u]
    single left right value:
    [code:1n72dx8u]Xdirection=abs(sprite('LastX')-Sprite.x)/(sprite('LastX')-Sprite.x)[/code:1n72dx8u]
    for exact angle 
    [code:1n72dx8u]anglemovingat = angle(sprite('LastX'), sprite('LastY'), Sprite.X, Sprite.Y)[/code:1n72dx8u]
    the last action after getting this info should be:
    [code:1n72dx8u]sprite('LastX')=Sprite.X
    sprite('LastY')=Sprite.Y[/code:1n72dx8u]
    so that next tick, lastx and lasty will always equal the previous ticks x and y values
  • here is a working example

    please reply back if you have any more questions:

    http://dl.getdropbox.com/u/1013446/buttonap.cap

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • [quote:x2m8pny0]

    SET NPC('STRING'): "MOVEMENT" & NPC('NUMERIC')[/code:x2m8pny0]
    
    I believe it should be
    
    [code:x2m8pny0]SET NPC('STRING'): "MOVEMENT"   +   NPC('NUMERIC')[/code:x2m8pny0]
    
    with a '+' instead of an '&'
  • it's not that many unique animations, but I can think of a few good games with crazy amounts of rotations, mostly 16 bits racing games, like mariokart, and rock and roll racing for snes

  • yes, that is rather nice

  • I suppose this is more of a c++ question again, and I am looking elsewhere for answers as well.

    is it possible/what would be the best way to pass multiple parameters to the *void param to

    CallFunction(int id, void* param)

    as in CallFunction(SomeInt, *hellothere, 6,"what's up?", "how ya doin?")

    most of the time it will be just one type of variable, but I am curious about multiple types

    for now I am just calling the function several times, and it saves the params one by one

    and then there is a different id value I pass that let's it know when I'm done.

    can I pass a struct or an array, and is there a better way?

  • it wouldn't be classes

    but you can create your basic guy

    then right click | copy

    right click | paste clone

    then you can change the sprite you use

    but all other properties will remain

    because it is a new object that is just a clone of the original

  • thanks ash. I actually didn't know how to use the debugger, until I mentioned to david in chat that I didn't know how to use the debugger, and then he started to tell me, and then disappeared, so I messed around until I got it

    and the problem was actually pretty stupid

    I was returning a value before my object was created. I got used to the construct functions where you can do that

    anyway, as far as the object names and such. yeah. it's all going to be one huge initialize action at the beginning when it's final. it's separated into these actions as I go along, because I want to be able to test all these individual pieces out using triggers and events. so these smaller events are really just for debugging purposes until they work perfectly, and then it will only operate on the internal version

    on a side note though:

    it really is just initializing pointers. I have one main object that's going to contain pointers to everything in an index. all creation and destruction related to each of the plugins in the engine will go through the main object. when you run the initialize action, the dialog tells you what object type to choose for each parameter, this is how it gets pointers to all the object types it will be able to create.

  • hi again, k, having trouble creating an object

    I'll show what I've done, maybe you can catch a mistake, or tell me what I'm missing

    there's some other less related stuff in there, but it involves extracting parameters or some other likely problem spot:

    ADDPARAM(PARAM_OBJECT, "TypeA", "Choose the a TypeA object to initialize the pointer.");
    ADDACT("InitPointer", "Initialization", "Initialize Pointer(%o)", &ExtObject::aInitializePointer, "InitializePointer", 0);
    
    ////////////////////////////////////
    
    long ExtObject::aInitializePointer(LPVAL params)
    {
    	pTypeAPointer = params[0].GetObjectParam(pRuntime);
    	return 0;
    }
    //////////////////////////////////////////////////////////////
    
    ADDPARAM(PARAM_VALUE, "Object Type", "Choose which object to create");
    ADDPARAMDEF(PARAM_VALUE, "Layer", "Layer name or number, to create the object on.", "1");
    ADDACT("Create Object", "Creation", "CreateObject", &ExtObject::aCreateObject,"hh",0);
    
    /////////////////////////////////////////////////////////////////////
    
    long ExtObject::aCreateObject(LPVAL params)//returns object pointer
    {
    CRunLayer* pLayer = params[1].GetLayerParam(pRuntime, pLayout);
    if (params[0].GetInt() == 0)
    	{ObjectIndex[index]=pRuntime->CreateObject(pTypeAPointer,pLayer->number, pLayout);}
    }[/code:rqvp7l0h]
    
    EDIT, sorry, this may help:
    [code:rqvp7l0h]	CRunObject* ObjectIndex[500];
    	int index;
    	CRunObjType* pTypeAPointer;[/code:rqvp7l0h]
  • simple one

    how do I make an object destroy itself

    I can't find a aDestroy() action in the sprite cvs I'm assuming you need to

    #define COMMONACE_COUNT_DESTROY

    either way, do I have to explicitly destroy them

    with

    ExtObject::~ExtObject()[/code:2kpiwxmt]
    
    or is there a something in the sdk to do it?
    
    Edit:
    would it be pRuntime->DestroyObject(MyObjectPointer)?
  • [quote:34rfl3vm]Perhaps you could look at implementing LUA instead?

    as you may have been able to tell from some of my more newbish questions, I'm very inexperienced with programming. I took a class or two 9 years ago, and I've read half a c++ book here and there, but I have no real experience making something other than tutorials. The logic I'm using I understand completely, but I'm still looking up alot of pointer syntax on google frequently, and I'm only now giving real thought to #includes and such. so aside from learning how to make lua, I'd be learning how to use lua, and c++, and the sdk at the same time, and besides...lua's not what I need anyway:

    So sort of like a programming language?

    I'm sorry, not commands that you write out necessarily, but for instance, you have made animation systems in the editor, and saved your game file. Now in construct you can call an action from a character object, and the actions you call can be as high level as for sprite animations, but they'd be procedural and dynamic, with more options. And there will be environment objects for physics, and lighting with similar high level actions, conditions, and expressions. And so on and so forth for everything from AI to UI

    The idea is that after creating everything in the editor, you would include one of each of every engine object type, and at start of layout, you would call one initialize action on a main object that allows you to load your editor saved file, and initialize pointers to the different object types, and this one main object creates all instances of all objects, and snaps them together with pointers, and such, and set everything in motion. Amazingly, the main groundwork that I needed to work for the rest to work is mostly finished, and functioning stably. Wish me luck.

  • Ok,

    I have some pointer variables that I declared in main.h in the ExtObject definition

    but I realized at runtime all instances of my plugin shared these pointer variables

    but not the other variables

    for instance:

    class ExtObject : public CRunObject
    {
    public:
    //...all the sdk code ...//
            
       CRunObject* pMyPointer;
    	int MyInt;
    
    };[/code:3qbfajmq]
    
    at runtime MyInt stays unique to each instance of the plugin
    pMyPointer is like one variable shared by all instances of the plugin
    
    I say instances, but to clarify, this happens whether I have several instances of MyPlugin
    or if I have cloned MyPlugin several times so I have separate objects MyPlugin, MyPlugin2, etc...
    
    is there a way to avoid  this? I want each instance to have a unique pointer.