lucid's Recent Forum Activity

  • 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

  • [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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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]
lucid's avatar

lucid

Member since 16 Jan, 2009

Twitter
lucid has 25 followers

Connect with lucid

Trophy Case

  • Entrepreneur Sold something in the asset store
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

24/44
How to earn trophies