Jump to content

bansama

Members
  • Posts

    64
  • Joined

  • Last visited

Posts posted by bansama

  1. If you need to do this, create an empty script (I call my dummy.lua) and attach it to that entity. CSG objects will get collapsed and not be seen by themselves unless they have mass or a script attached.

     

    Aha! Now I remember reading about that somewhere. Thanks for reminding me. I tried giving it mass as a scene object and it spun off into the void killing me. Was funny to watch, but not very helpful.

     

    ?? What are you trying to do with this? I assume the pressure pad itself is a model/entity? You can attach a script to that model that looks for the player colliding (in Collision() check the entity's name that gets passed in and see if it's player). Then you have the player position from there.

     

    This is where it gets a bit complicated to explain. But basically, like the teleport tutorial (I think that was in one of your topics) I want to teleport the player between different points on the map. However, I want to do so in a manner that player doesn't know it's happening. I figure to do this, I need two identical locations in different parts of the map. When they hit the pressure plate, they should teleport. But in a manner that keeps their current position and rotation relative to the pressure plate they hit. Looking at the teleport tutorial, it didn't look like the player was keeping this information.

     

    If you've played Stanley's Parable, then that should give you an idea of why I want to seamlessly transport players, so that I may change the world around them without them realising it.

     

    Looping like that will always be slower than getting your entities another way. I would avoid looping like that if at all possible, and generally it's very possible to avoid having to do that. If you do have to loop, looping on startup will be better than looping during playing.

     

    That makes sense. Thanks.

  2. So I looked at this code for getting entities:

     

    for x=0,App.world:CountEntities()-1 do
    local entity = App.world:GetEntity(x)
    if entity:GetKeyValue("type") == "player" then
    self.target = entity
    end
    end

     

    And changed it so that it printed out entity names. Doing that, I notice it doesn't fetch the name of entities with collision set as a scene/have a mass of 0. So if I have the my floor as an entity with a mass of 0, set as a scene, is there no way to get its name?

     

    I really want define the floor as a parent for a pressure pad so I can get the local coords of the player in respect to that pressure plate.

     

    I tried setting the pressure plate as the parent for the player and lets just say bad things happened.

     

    I also wonder if it's best to fetch entities with such a loop as opposed to specifically defining the one I wish to use via Script. Wouldn't the faster of the two be better -- and wouldn't the fastest be Script? Or am I misunderstanding something?

  3. I'm looking at the Entity::SetPosition documentation and it mentions the following: "Local coordinates are relative to the entity parent's space". But it doesn't mention how you define this. Is this defined with SetParent? I realise this is probably stupidly obvious, but the clarification would be appreciated!

     

    What I am hoping to do is get an entity's local position relative to the object it is colliding with.

     

    Could someone also explain matrix in the context of GetMatrix/SetMatrix? What would it be used for? Does it significantly differ to position and rotation or does it contain the same type of information?

     

    Thanks!

  4. Just wanted to say thanks for the help, I'm now starting to understand how to pass variables between scripts using the flow editor and defining entities to be dragged and dropped with "Script.entityName = nil --entity", etc.This has allowed me to fetch the player entity's position when they collide with a trigger box and to output that as string displayed along with debug/FPS information.

     

    This now raises some more questions, but I figure it'll be better to make new topics for those.

  5. I'm trying to understand why you think you would need globals in the situations you mentioned.

     

    Did I say that? It wasn't my intention so apologies for any confusion. I'm trying to avoid globals. Thanks for the information on linking scripts and the idea of using another file to store information in. I'll be trying to work out how to use both.

  6. While I understand that globals are bad (it's the same with PHP and I expect all languages), I'm still left wondering how I can pass variables actually set within a script to another script or function. Say I wanted to pass the remaining amount of ammo, or wanted to define a longer string (for a journal entry or similar) can that still be done with the flow editor? Is there a way to do it without the flow editor?

     

    In other words, how can pass information I can't realistically set with the defined input box that appears in Leadwerks when --string, etc. is used?

  7. This was done off memory but it should work.

     

    This does indeed work. Which means I probably made an error. Based on this, I'll look tomorrow at the first two scripts I tried to use and see if I can figure out why they didn't work.

     

    Thank you.

     

    @shadmar Thanks. I'll look at that too.

    @Mordred That was a little over my head, but thanks.

  8. This is one way to pass variables around between objects when outputs raise inputs.

     

    Thanks for the reply. I guess I don't fully understand it though as I can't get it to work (yet). I copied the text in the script you linked to, and added Script.Text = "" (I've tried this alternately with both text and Text in case the difference matters as I notice you have alternated between the two). In the same file I added the Script:GetText() example you provided and created the SetText counterpart in the display script.

     

    In the flow editor GetText() is shown in <>, but SetText() is not. Does this indicate a problem?

     

    I added a little if/elseif loop to the function I'm using to output text to check if self.text is empty, which it is. So I think I'm still not passing the variables correctly. I'm not even sure how I should be calling the functions. When I try to set a variable with text = SetText(text), I get an error about attempting to call global "SetText" (nil value). So I guess my PHP knowledge is not going to help me here.

     

    The reason I want to do this instead of just outputting the text with the collision script is that I figure the need to pass variables will be important, and outputting to the screen is a good way for me to test if something I code works or not.

  9. I picked up Leadwerks on Steam earlier this week. As such I have very little experience with it. I also currently have no experience with Lua. So forgive me if this question is a little silly.

     

    As the title suggests, I would like to pass variables between scripts. For example, I want one script tied to an entity/object in the scene to manage what happens when there is a player collision with it. I want another script to manage text output to the screen based on such collisions.

     

    How would I pass a variable set in the collision script to the text output one? Could someone please point me in the right direction?

×
×
  • Create New...