Jump to content

Mordred

Members
  • Posts

    118
  • Joined

  • Last visited

Everything posted by Mordred

  1. Hello fellow leadwerkers, it's me again and even though i am ashamed a bit, i have another question to ask. Refering a previous posting about how to access variables between different scripts i managed to get this set up quite well. But now i have another, mhm well, luxuary issue. It's a bit hard to always write something like: self.target.script.hud.script.strength = self.target.script.hud.script.strength + 1 thus i know that if i use: str = self.starget.script.hud.script.strength the engine only stores the actual value of "[...].strength" into "str". Now i know from C++ that you can use references (&<name>) and pointers (*name) to point to the memoryadress where those values are stored. So basically i do not want to have the actual value of "strength" to be stored in "str" but the memory adress, so i can use a shortcut to pass variables onto that adress. Is that possible in LUA too?
  2. So, it seems as if you know what "tiled terrains" is. Could you explain it's use to me? That'll be interesting. According to it's name i would think that you create a larger terrain and breack it down to several smaller tiles, is that correct?
  3. Thanks Patrick, that reply contained more detail than expected, yet very interesting. Thanks for sharing this with me (us!). Btw. the "standard" edition of World Machine is 99 bucks and it seems as if you are allowed to use it comercially too. I honestly do not believe that i have to have worldmaps that need 32 cpu cores to render or such, but well, you'll never know. In the end you can upgrade from standard to prof. i believe. I'm not sure what they mean with "tiled terrains" and "automation / scripting" though. But that means, i do not need those functions right now
  4. Darn, again a super stupid error. I didn't really think about that, i always though i wrote it uppercase...well, thank you a lot again Rick!
  5. Hey Rick, that sounds quite interesting, but somehow i do not get the "hang" on it. So, would be cool if you (or someone else) could explain it to me a bit further. I'd like to do the following: Generate a script named "Skillsystem", that script contains several "Script.XYZ" variables holding stats (like strength and such --> yes i know i maybe could use tables but i'm not that far into the code yet). How do i acces the value stored in "strength" from another script and how do i write into the "Skillsystem" script new values? A simple link between "HUD" and "FPSPlayer" didnt work. I did enter "Script.hud = nul --entity "HUD"" in the FPSPlayer script and i linked the entity carrying "Skillsystem.lua" onto it. Skillsystem.lua again has the player as "target". So from what i read the idea was to get access to functions / variables in this manor: self.HUD.script:<Function>() or self.HUD.strength or smth. like this, well, it always returns an error like "attemt to index field 'HUD' (a nil value)". So basically i added this line to FPSPlayer.lua - Script.hud = nil --entity "HUD" and want to call it this way: - context:DrawText("Strength" .. self.HUD.strength, 200 ,200) while strength is not a function but only a variable defined in "HUD" (while HUD points to skillsystem.lua)
  6. Oh, hey Josh, it seems i did oversee your question. Sorry 'bout that. In case you're still curious why i do not want to do it on my own is, that i do not want to bother attaching "targets" to maybe dozens or hundreds of (stationary) entitys in the gameeditor. But it seems, that creating one entity and saving it as a prefab does save the "target" somehow (even though, the "target" value is shown as empty, it somehow did work without the need to attach the player again). It's just, i'm lazy and looking for the easiest way to work around that
  7. @ Patrick, may i ask how (if at all) you create open areas at the moment? I mean, what tools do you use and how do you import those? Do you model those in a program like blender and import the .fbx file?
  8. Well, i gonna have to look into it i'm not really sure how the raycasting thing work right now, but i already watched a tutorial from Aggro that did explain it quite good, so i might have to take another look into it Again my thanks for all your suggestions, i very much appreciate all your help!
  9. hi, i tried WM myself (Free Edition) for now and i am thinking to geht it too. The Results are Quote cool and i believe its One of the easier and faster ways to generate quite Big Procedural maps. Right now im still struggling of i Should Buy it or not but the more i think about it the closer i get to "yes"
  10. I think the way YouGroove explained might be quite good for my idea's. I do not want to use that "Player" variable for mobile entities (like hostile mobs or os) but for interactive stationary objects. Say if i want to cut down a tree i want to have the tree automatically know that the result (for e.g. "you choped 10 logs") pass the values to the player without having to bother attaching the script to the whole forest at all. Hostile entities are another thing, here i have to say that i'm gonna use the way like in darkness awaits. That's how i actually managed to get my first script in the other topic up n running. Besides that i could use that script for all interactive stuff so it's just "checking for the player in the proximity" once i "use" the object (using function Script:use()). Anyways, i have to take a deeper look into those options. Thanks for showing the possibilitys to me
  11. Okay, thank you Rick, so it might occur "slow" in the first place, bit later on it might be simply better to attach the "player" script manually, because: the more often i use that the longer the iteration lasts since it has do to the same work several times. Did i understand it correct? I was hoping for a builtin function that wouldn't need to "check all entities" at all. Well, anyways, you did answer my question, thanks!
  12. Hey guys, since i had to do quite some work to get my script actually targeting the player i'm wondering if this is somehow easier achieved? For e.g. if i define a script variable like the player HP i can predefine it with the value "100", is that possible with "self.target" too? Oh: Before that happens... i do not want to drag the player into the affiliated fiel in the script entity, i want to do this code wise. And i do not really want to have to bother arround with the range between the script entity and the player. Just a simple, playing, "self.target = set.player()" or so would be cool
  13. It's basically the same i did earlier today. You have to set a "target" in your colission script, once you did that you can access functions within the target script using for e.g. self.target.script:<function>() Here's the code i did so far, it passes a damage value (named xDamage) from this code, to the "FPSPlayer" script (Atually: Its more to the "entity carrying the FPSPlayer script" than to the script itself) using its builtin "Hurt()" function. You just have to make sure that the "self.target" somehow point's to your Character, i did this using the "GetEntityNeighbors" function like done in the "EnemyAI" Script. -- give access to code in "GetEntityNeighbors.lua" import "Scripts/Functions/GetEntityNeighbors.lua" Script.target = nil --entity "Target" Script.damage = 0 -- float "Damage" Script.teamid = 2 --choice "Team" "Neutral,Good,Bad" function Script:Use() -- load entities within range (30) of self.entity into "entities", only load entities that have scripts attached local entities = GetEntityNeighbors(self.entity,30,true) local k,entity -- loop thrrough the result of "entities". k = key, entity = result for k,entity in pairs(entities) do -- only select entities with teamid == 1 ("good") if entity.script.teamid == 1 then -- and if the entity has at least 1 health remaining if entity.script.health>0 then local d = self.entity:GetDistance(entity) -- set self.target = resulting entity self.target = entity end end end -- prepare random function math.randomseed(os.time()) if self.target ~= nil then -- randomize the damage dealt a bit, setting the "min damage" value if self.damage > 0 then if self.damage > 5 then minDmg = self.damage - 4 else if self.damage > 2 and self.damage <= 5 then minDmg = self.damage - 2 else minDmg = self.damage end end -- actual code randomizing the damage. Damage is dealt between "minDmg" and "self.damage" (the value is set in the assets browser) xDamage = math.floor(Math:Random(minDmg, self.damage + 1)) -- fire function "Hurt" at self.target --> thus the player or entite that was found before. self.target.script:Hurt(xDamage, self.target) end end end My bad, didnt say that.... forgive me welcome to Leadwerks bansama
  14. actually, i know he bought it via steam and that a few days ago already. I do not believe that there's an automatic "import" process from steam to leadwerks, or am i wrong? How did other steamusers get access to the workshop? Now i'm curious
  15. here's the "streamlined" code with a few comments. Hopefully others may profit from it Again my thanks to YouGroove for trying to solve my issue, without his comment i wouldn't have tried to access "self.target.script:Hurt" -- give access to code in "GetEntityNeighbors.lua" import "Scripts/Functions/GetEntityNeighbors.lua" Script.target = nil --entity "Target" Script.damage = 0 -- float "Damage" Script.teamid = 2 --choice "Team" "Neutral,Good,Bad" function Script:Use() -- load entities within range (30) of self.entity into "entities", only load entities that have scripts attached local entities = GetEntityNeighbors(self.entity,30,true) local k,entity -- loop thrrough the result of "entities". k = key, entity = result for k,entity in pairs(entities) do -- only select entities with teamid == 1 ("good") if entity.script.teamid == 1 then -- and if the entity has at least 1 health remaining if entity.script.health>0 then local d = self.entity:GetDistance(entity) -- set self.target = resulting entity self.target = entity end end end -- prepare random function math.randomseed(os.time()) if self.target ~= nil then -- randomize the damage dealt a bit, setting the "min damage" value if self.damage > 0 then if self.damage > 5 then minDmg = self.damage - 4 else if self.damage > 2 and self.damage <= 5 then minDmg = self.damage - 2 else minDmg = self.damage end end -- actual code randomizing the damage. Damage is dealt between "minDmg" and "self.damage" (the value is set in the assets browser) xDamage = math.floor(Math:Random(minDmg, self.damage + 1)) -- fire function "Hurt" at self.target --> thus the player or entite that was found before. self.target.script:Hurt(xDamage, self.target) end end end
  16. But thanks for trying YouGroove [Edit] OMFG it's SO mega easy.... the problem was that i called "self.target:Hurt(xDamage)", but it actually has to be "self.target.script:Hurt(xDamage)". Didnt see the forest due to all those trees well. in case someone else might be interested, i gonna add a few comments to my code and will post it as it works right now in a few hours.
  17. Oh, no sorry, i explained it wrong. The Code you posted above goes error free, i even get the "self.target" to point to the players entity in memory (i did see that in debug mode) The error occurs on the last line of code: self.target:Hurt(xDamage) "attempt to call method 'Hurt' (a nil value)" But the variable xDamage is filled with a number (even if i replace it by "5" it's the same error) and if i add (xDamage, self.target) it's still the same error [Edit] Tried to make a function Script:Test() --> printing a message to console. I do get the same error, so the problem seems to be the value in self.target .... do i have to convert the memory adress i do get to smth. else maybe?
  18. function script Hurt(damage, DistributorOfPain) --> that's actual in the basic "FPSPlayer.lua" script without changing it. I already thought, that the "nil" error might come due to the fact i only fill "damage" in the "Hurt()" function above, but i even tried to set the "DistributorOfPain" to self.target (since i lack another target i could use....) but that doesnt work either. Besides that, the value in "DistributorOfPain" is not used in the FPSPlayer script at all. function Script:Hurt(damage,distributorOfPain) if self.health>0 then self.sound.damage[math.random(#self.sound.damage)]:Play() self.health = self.health - damage dmgReceived = damage self.hurtoffset = Vec3(math.random(-1,1),math.random(-1,1),0):Normalize()*30 local blood = {} local n=1 blood.texture=self.image.blood[math.random(1,4)] blood.intensity=1 table.insert(self.bloodoverlay,blood) if self.bloodindex>4 then self.bloodindex=1 end if self.health<=0 then self:Kill() end end end [Edit] Besides, it did work before when i set the Target via drag n drop into the script by hand that way. It's only not working since i tried to get the target automagically.
  19. i did remove the Archive from my dropbox and attached it to the board itself. Thanks again Josh for mentionening that posibility bananatree.zip [Edit] Attached the correct model. Another information: You have to drag and drop the "Childnodes" onto the "Root" folder within the scenetab to be able to delete the childnodes itself. bananatree version2.zip
  20. Hello fellow Leadwerkers, i have a little problem. I'm trying stuff and i have reached a place where i cannot continue further without help. Basically i want to do the following: Create a box, that box has a script attached named "Damage" that's being run on "Use", so if i press "E" it's fired up, the "Damage" script shall target the player and do random damage. I got it all running if i add the target via "Script.target = nil --entity "Target" followed by dragging the "Player" onto that field in the assets tab. But now i'm lazy, i want to use that scrip on several places and i do not want to add the target "Player" every time by hand. So my idea was to look into the "MonsterAI.lua" script how that is solved. I ended up with smth like this: import "Scripts/Functions/GetEntityNeighbors.lua" Script.target = nil --entity "Target" Script.damage = 0 -- float "Damage" Script.teamid = 2 --choice "Team" "Neutral,Good,Bad" function Script:Use() local entities = GetEntityNeighbors(self.entity,30,true) local k,entity for k,entity in pairs(entities) do if entity.script.teamid == 1 then if entity.script.health>0 then local d = self.entity:GetDistance(entity) local pickinfo=PickInfo() self.target = entity end end end math.randomseed(os.time()) System:Print("I'm in the tree use function") if self.target ~= nil then if self.damage > 0 then if self.damage > 5 then minDmg = self.damage - 4 else if self.damage > 2 and self.damage <= 5 then minDmg = self.damage - 2 else minDmg = self.damage end end xDamage = math.floor(Math:Random(minDmg, self.damage + 1)) self.target:Hurt(xDamage) end end end My idea was to set the TeamID for that script to "bad" == 2 (whilst the player is "good" == 1), so it will only run if it has contact with the player. The Problem is, i have no idea how to get the result of "return entity.script" as a valid target to use it in the 2nd half of the script (following the lines after "self.target = entity.script"). I'm basically quite sure that i didn't understand how it works at all, so any help, especially if someone could explain my error, would be appreciated. Thanks in advance! [Edit] Did some slight changes to the original code, so now the "self.target" points to the correct entity, but still i get a "called nil" when trying to access "self.target:Hurt(xDamage)". Even though i was able to see in debugmode that the adress stored in "self.target" is actually the player (and thus the target i want).
  21. Hey Josh, just want to ask if i can remove those files from my dropbox, or do your still need them?
  22. 1st Question: When it's dono 2nd Question: Indie = only LUA, full (it's more "extended" since the Indieedition is a fullversion too) has C++ & LUA support 3rd Question: that's not 100% sure by now, but Josh is looking into it if / how it works.
  23. Hehe thanks for your response Christian, but you're sadly too late. I already found the problem and was able to fix it. The Shader has to be of type "sprite" instead of the default "diffuse".
  24. If i might respond to your suggestion, Christian . That might work with this quite easy shape (btw. it's not pure plane walls, but i see that suggestion might work). The problem comes with other, larger, models with more tris. For e.g. i own a few premade houses that have several layers, or dungeon tunnels that are more smooth / round than simple boxes. And tbh it's a lot of work to make those invisble boxes for all your models. You're doing the models in a diff. program to make live easier in the first place, not to place them and to have build invisble layouts all arround (if i would do that, i could build the model in Leadwerks in the first place). Anyways, as mentioned Josh is already into it
  25. Hello Josh, i made a "_Crashtest.map" and i added the model (without skins) into the archive. I hope it's okay that it's uploaded at dropbox.com <here was a link before> The reproduce the Crash: 1. Add the Model to the assets 2. place the model in the worldviewer 3. in the scene tab remove the nodes "bananatree_bananatree" and "banantree_trunk" from the mothernode named "STATIC_MESH" 4. you can delete only one of the 3 resulting items 5. after you save the map and restart Leadwerks it's giving you the "ACCES_VIOLATION" as stated above The mapfile in the archive does already have that model placed and it will crash when loading.
×
×
  • Create New...