Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26

Thread: Inventory

  1. #21

    Default Thanks again...

    Okay thanks- that'll hold me for a while- even though the Vector2 thing is a bit confusing...

    Regards, NinjaNumberNine

  2. #22

    Default

    Quote Originally Posted by Seth View Post
    Check the scripts from Treeworld, it does the block breaking with head thing. To make it also pop out a coin you would need to create a coin in script about when it dies.
    How do you call an entity from another entity's script? I've been experimenting but nothing works.. Programming's like that, i guess, no guessing allowed.

  3. #23
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Quote Originally Posted by NinjaNumberNine View Post
    How do you call an entity from another entity's script? I've been experimenting but nothing works.. Programming's like that, i guess, no guessing allowed.
    Not sure what the question is - are you wondering how to communicate with another entity from an entity, or create a new entity from withing an entity script?
    Seth A. Robinson
    Robinson Technologies

  4. #24

    Default Re: Inventory

    I had meant, how can you create/access another entity? Are their any "permissions" needed for that? For example, to create a coin, then make it move up and out of the block (which turns just changes from the "active" image to "unactive", How would you "call up" the other entity and tell it to replace yourself?

    Sorry for the experience that I don't have...

    NNN

  5. #25
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Ok, considering the topic of this thread is inventory we've gotten off track, please make a new topic if you have any more questions.. it's just so it's easier for other people to find answers during searches.

    But here is the answer - I think you want to know how to "spawn" a coin.

    Don't replace the current entities graphic to look like a coin, it's cleaner to just make a coin object.

    Check worlds/RT_TreeWorld/script/static/ent_brick.lua

    When you hit this with the players head, it needs to make a bunch of 'brick chunks' to fly around. These are spawned entities, look at this function it has:

    Code:
    function AddDebris(vPos, vForce)
    
    	ent = CreateEntity(this:GetMap(), this:GetPos()+vPos, "misc/ent_brick_chunk.lua");
    	ent:AddForce(vForce);
    	ent:SetPersistent(false);
     	Schedule(800, ent:GetID(), "this:GetBrainManager():Add(\"FadeOutAndDelete\",'');");
    
    end
    This creates an entity and gives it the "misc/ent_brick_chunk.lua" script. (you could change this to the coin script and it would spawn a coin instead)

    The parameters are a position offset and velocity so the chunks start moving.

    The FadeAndDelete brain kills the chunks after a bit.

    Notice it's making changes to the newly created entity (like with ent:SetPersistent(false); ) - you can also use ent:RunFunction("SomeFunc", optionalParms, etc); to run a function inside its .lua script/namespace.

    The functions can return values etc, so this provides a way to communicate with other entities if you need to.

    It actually calls it like this:
    Code:
    function Crumble()
    
    	//Bust up this brick
    	this:SetDeleteFlag(true);
    	GetSoundManager:Play("audio/mario/smash.wav");
    	
    	//create the particles that fly off
    	AddDebris(Vector2(0,0), Vector2(-2,-2));
    	AddDebris(Vector2(20,0), Vector2(2,-2));
    	AddDebris(Vector2(0,20), Vector2(-1,-2));
    	AddDebris(Vector2(20,20), Vector2(1,-2));
    
    end
    
    function OnDamage(normal, depth, enemy, damage, userVar, projectile)
    	Crumble();
     end
    So you see it makes four chunks and makes them fly off in different directions.

    These same concepts work fine for spawning anything.
    Seth A. Robinson
    Robinson Technologies

  6. #26

    Default Thanks

    Wow, why didn't I think of that... I spent hours looking at those scripts, and I had changed the visuals around to suit my purpose... Guess I'll have to chalk it off to that dratty brain of mine...
    Anyway thanks, and yeah I'm gonna need a new thread (maybe several)... I just got the first Biotux DR out the door, and found all kind of problems at the last minute... Maybe it's just me but at least 4 other people have tried (and failed) to get NovaShell to run under linux. Several versions of Linux. I had trouble getting Clanlib installed there as well... I know it's not your fault (as I blame most of it on me, the rest on ClanLib and whatever's left I say is Novashell's fault).
    So, thanks for all and see you in the new thread!
    NinjaNumberNine

Similar Threads

  1. Can't get into inventory screen
    By in forum Dink Smallwood HD
    Replies: 1
    Last Post: 08-25-2004, 11:22 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •