Jump to content

bansama

Members
  • Posts

    64
  • Joined

  • Last visited

Everything posted by bansama

  1. So another evening spent on this at last. But another evening where I feel I'm hitting my head against a brick wall. Right now, I'm pointing scripts to the player entity with Script.PlayerTarget = nil --entity and dragging the Player to the related box in the editor. But when I switch between projects, etc., this has often seems to be wiped out. So I need to keep setting it. It's frustrating, so I figure I should just tell the script directly that I want it to work with the player entity. for x=0,App.world:CountEntities()-1 do local entity = App.world:GetEntity(x) entInfo = entity:GetKeyValue("name") System:Print(entInfo) end As I think I've said before, the above works to output entity names to the Output window. This gave me the idea to use GetEntity() to specify the name directly with: self.PlayerTarget = App.world:GetEntity(Player) But this just throws back an error. I can find no documentation on GetEntity. Is there a simple way to state directly in a script that variable X should equal entity y, without using a loop like the above to search for it? [self.PlayerTarget = entity:GetKeyValue("Player") didn't seem to work either] On an unrelated note, I've noticed that the way in which I was outputting coordinates to the screen no longer works unless I'm in debug mode. function Script:PostRender(context) local font = Font:Load("Fonts/arial.ttf", 12) App.context:SetFont(font) App.context:SetBlendMode(Blend.Alpha) if self.Text ~="" then context:DrawText("Current output is " .. self.Text, 102, 22) end App.context:SetBlendMode(Blend.Solid) end This used to output text when "Running" the game but now only does so when "Debugging". Did something change? EDIT: Actually come to think of it, I don't recall seeing the FPS counter that usually displays either. Is there a hotkey toggle for that which I may have accidentally pressed?
  2. Is the code from Step 2 missing or is it the code you provided later in the post? Also, while I understand it's more work, I think a working example of this may be more helpful to those of us who are learning.
  3. So any suggestions on the best way to fetch player position? Am I right in thinking I will need to specify something as a parent in order to actually get local coordinates? It makes sense to me in theory, but I won't be able to try it out in practice until Saturday.
  4. 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. 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. That makes sense. Thanks.
  5. 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?
  6. While interesting, that still leaves me wondering why/how setting a matrix would be used.
  7. I specifically want their location. Now if that gets passed into Collision(), then great. How would I fetch it from there?
  8. 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!
  9. 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.
  10. 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.
  11. 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?
  12. 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.
  13. 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.
  14. 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...