Jump to content

Mordred

Members
  • Posts

    118
  • Joined

  • Last visited

Everything posted by Mordred

  1. Thanks Josh, that's what i figured out too, but i am (well....was....) quite sure that it did work before using a terrain map in leadwerks of 1024by1024 and importing a 512by512 heightmap. But i'm not so sure as i was before anymore. If it's intended that the Leadwerks map has to be the same size as the heightmap you're importing than it's working as intended and we can close this topic.
  2. @ Rick, i gonna try to set smth. up in a few minutes (if i manage to get it up 'n runnin, i'm still new to all that stuff ) @ Josh, i'm refering to this thread "A good* 'seed' is os.time(), but wait a second before calling the function to obtain another sequence! To get nice random numbers use:" http://lua-users.org/wiki/MathLibraryTutorial They mention that you should wait a second between two math.random calls due to the fact that the random seed will be the same within a second. Anyways, i just added a simple, plain, math.randomseed(os.time()) into my app.lua and fired up a simple System:Print(math.random(1, 10) onto the console and had no issues at all, they numbers def. were random, even though i generated them in a "for" loop 10 times in a row. So basically, that means i'm doing smth. wrong. And i'm so stupid....i know what's my problem. In case someone is interested in knowing. I did a loop iterating the table i mentioned before. I than stored the item's value (predefined as "0") into the variable "ammount". I than "end"ed the iteration and started a new one working with that "ammount". I think everybody now knows what my problem is. The vallue in ammount was only the last value i received from the first loop. Basically like this: for a, b in pairs(self.target.script.inventory.script.xInventory) do if a == self.usedSkill then for y, x in pairs (B) do [b]ammount[/b]= x end end end for a, b in pairs(self.target.script.inventory.script.xInventory) do -- check if the used skill does exists in our table if a == self.usedSkill then for x, y in pairs(B) do [b]ammount[/b]= y + math.floor(math.random(0, 1 + (statvalue * (100 + skillvalue) / 1000))) i = i + 10 end end end The solution would be like this: for a, b in pairs(self.target.script.inventory.script.xInventory) do -- check if the used skill does exists in our table if a == self.usedSkill then for x, y in pairs(B) do ammount = y + math.floor(math.random(0, 1 + (statvalue * (100 + skillvalue) / 1000))) self.target.script.inventory.script.xInventory[a][x] = ammount self.target.script.hud.script.xSkills[self.usedSkill] = skillvalue + self.target.script.hud.script.skillgain self.target.script.hud.script.xStats[self.usedStat] = statvalue + self.target.script.hud.script.statgain end end end
  3. Hello Rick, thanks for your reply (again ). But wouldn't be it so that if i do add the seeding into App.lua that there's a quite high chance to get 2 "math.random(1, 100) in a row generating the same result, or am i wrong? For e.g. to randomize "Skillgains" i actually HAD to use two different seeds to prevent the "Skillains" happen at the same time with the same increasevalue.
  4. Hello Leadwerkers, [EDIT] Please be aware of my change at the end of the topic, might not be an error at all? [/EDIT] i recently were playing arround with the free edition of World Machine. I managed to get a decend island finished and wanted to export / import it in Leadwerks. Problem is: Everytime i use the .raw or .r16 format i do get an error "Failed to load heightmap", if i use the r32 format it does import the data, but i do only see sharp rock edges, not the actual isle i did export. Now i thought it might've been a setup fault from myself, so i tried another isle that i used before already, i had it saved and exportet the height map files again, but now i cannot import the heightmap without flaws (again, if it's raw or r16 it gives me an errour, if it's r32 it's only the sharp edges instead of the island). Then i thought: Maybe you're really too dumb, try the heightmaps Aggror provided earlier in the workshop. --> same error. So follow these steps to reproduce: 1. download the heightmaps from here: http://www.leadwerks.com/werkspace/files/file/472-21-high-detail-heightmaps/ 2. create a terrain (i tried size 1024 and 2048, as far as i know the terrain can be bigger than the hightfield, as long as the hightfields ain't bigger than the terrain). 3. import one of those heightfields 4. you do get the error mentioned above It might refer to a beta branch problem, because last week, when i was at release branch, i didnt have that problem at all. [EDIT] Might not be an error at all? If i choose the correct size of the terrain i can import the .raw files again. But it did work earlier without the need to create the exact same terrain size as the heightmap are as long as the terrain was bigger than the .raw. I was able to import a 512 size heightmap in a 1024 sized gameproject before... [/EDIT]
  5. Hello fellow Leadwerkers, I'm messing arround as usually. This time i'm trying to get a random function up n running. I did it the easy way for now, to know how it works, but it doesn't work as intended. I might want to say, that i do understand, that math.random is only pseudorandom, i have to shuffle the numbers before i really can use them with "math.randomseed ( os.time())" every time I need a new random seed. Thus no problem. I did use that in another script too and there it did work quite well, but now the following happens. I have a table, in this table several skillrelated items are stored (the table contains the skills "woodcutting" and quarrying, both values again contain several items (logs, bark, twigs....) with an initial value of 0. I now want to iterate this table, check if the "used skill" is within this table and, if it is, i want to increase each value of those items individually. So basically, i have 5 items stored, i want to add a random number to the first one and another random number to the 2nd one. But i always end up that all 5 items do get the exact same number. For a better understanding i gonna add the table and the loop in here. Hopefully, you do understand what i mean. It's sometimes hard to explain myself using english. Table: Script.xInventory = { woodcutting = { logs = 0, bark = 0, twigs = 0, leafs = 0, insects = 0 }, quarrying = { clay = 0, limestone = 0, granite = 0, basalt = 0, obsidian = 0, marble = 0, quartz = 0 } } Script: for a, b in pairs(self.target.script.inventory.script.xInventory) do -- check if the used skill does exists in our table if a == self.usedSkill then for x, y in pairs(B) do math.randomseed(os.time() + i) ammount = y + math.floor(math.random(0, 1 + (statvalue * (100 + skillvalue) / 1000))) i = i + 10 end end end As you can see, i added the math.randomseed(os.time() + i) into the loop. I did add +i (i is plus 10 every loop cycle) to avoid the script using the same time twice, since i already know that os.time() only counts within a second or so. I had the same problem using the "GetSpeed()" function though. Still the "random seed" seems to be always the same.
  6. Yea beo6, it is Thanks, well, i did start a bit, but while i was coding i made actually several changes and tried diff. aproaches already, i guess that'll happen quite a lot when you're still very new to all this Anyways, it makes fun! So it shall continue.
  7. Well, another example where that happens. If you look at the video of Arteria3d of the "OBM" Model it's a single character with several types of armor, clothing, faces etc. That's again one single large file containing everything. http://arteria3d.com/products/obm Anyways, if that's really not that often i just might've had some bad luck that i had contact to several of those files, in that case i have to admit that it's not really needed to change anything from what is possible right now. Well, i just wait for the response of the creator of those trees if i can get the stuff as individual files. Thanks for all your effort.
  8. Oh sorry @ Gamecreator in that case i missunderstood you. I thought your question was depending on Scenetab where you can hit "+" on such models (what doesn't work in this case sadly). Okay so basically, the engine is capable to "see" that there are several models in that .fbx file. But it sound's like a mess to select a specific one out of that file, especially in my case because the model consists of roughly 40 diff. trees. Just as i sidenote, i wrote the creator of the models if he can supply them as single files for each entity, no response yet though. But as said, those "multi model files" occured several times to me, so it would be a cool feature (well, i might add this to "feature request" in a while) to be able to just select and place the individual models.
  9. +1 But: From what i heard before that might lead to performance issues at some scale. For e.g. if you have 10 objects, each behind the other, and you're only able to see the one in front of you it seems to be so as if only the first (for you visible) model is being loaded / rendered. If you combine those 10 to a single entity the engine would have to load all 10 at once to only view the first one. Pls. correct me if i'm wrong. Nevertheless i would prefer that option myself too, since it makes life in some cases easier. so i'm still supporting this request
  10. Yea, well, but in this specific case i bought a whole set of Treemodels, with and without leaves. The .fbx file is one large File containing all trees, so far not a problem but. 1. i want to attach scripts on each individual tree 2. in the package are those models without leafs and i do not want to use those at all. Well, i gonna take a look if i can extract them on my own. I just was wondering if there's any information about how that's done in the future.
  11. Yea, okay, in this case i'm in the right place, since this is the "Bug report" forum. Thus it seems as if you were able to confirm my first thought that it might be a bug. Thanks. P.S. Surely the workarounds you mentioned work, but they might result in other problems. Anyways, i can work that out for now, but it would be far easier if the .mat file would be generated without the need to rename anything.
  12. Hi YouGroove, yes i do use the Steam Leadwerks 3.1 edition, right no in it's beta branch, but i had the same issue in the release branch too. You did take those 2 textures i added to the posting, yes? And no issues at all? Than i'm wondering why it keeps telling me that "grassdirt.mat" already exists and want's to overwrite it. Maybe i'm doing smth. wrong? I do extract the zip archive, i then copy both files into some folder in my leadwerks project (does it matter if it's a subfolder of "materials" or can i copy them anywhere? Actually i have a folder "new assets" added, but that's not a subfolder of "materials"). Leadwerks is going to convert the files after that into .tex format and than i just right click both textures and select "generate material", the material window pops up, i do this with the 2nd. .tex file and get the message "grassdirt.mat already exists, do you want to overwrite it?".
  13. It's actually the 2nd part you mentioned YouGroove. If i have a multimodel (it doesn't have to do with children or smth. like that, it's just that the file does contain more than 1 model at a time). I'd like to see a way to extract those sub objects to use them individually, as it is possible in Unity3d for e.g. The problem is: Several finished model files you can buy actually are (!) multiobject .fbx files. @Gamecreator, thanks for your reply too, but it's not that i want to access "child object". Say, you have 3 different tree models and want to save them. You can either use one file containing all 3 models, or 3 files containing a single model each. If i have the file containing the 3 models, i want to use those individually.
  14. Does anybody know if that "sub objects" thingy is on the "to do" list? Because i've seen several such .fbx files in the last few days...
  15. Hello, another (hopefully not to dumb) question. In this case it's about models in .fbx format. I have a modelpackage that contains only one .fbx file, but in this file are several different models included (trees and flowers). Is there a way to use the single models in Leadwerks 3, or do i have to somehow import the .fbs file into some program and export every model on it's own by myself? I know from Unity3d that you can access the several models containing a single .fbx file by clicking a small "arrow" near the package, thus it collapses and shows me the single parts. But i cannot export the single files as .fbx in Unity3d.
  16. Could you try this too? Import a 2nd file that's called map_test_map_2.jpg, that you should get the message that "map_test_map.mat" already exists (be aware, it say's: "map_test_map.mat" he, does remove the "_2" in the name. [Edit] Okay, now that's strange, if i use .jpg files i do not have that issue too, but if i use the textures added to this posting, i do have the problem.
  17. Hello fellow Leadwerkers, i had this issue several times now and i saw that it always happens if a source texturefile has an "_" (underscore) in its name. For e.g. grass_a.tex and grass_b.tex will both be saved as "grass.mat" and thus overwriting eachother. Someone else here who might confirm that issue? I did try to rename the sourcefiles before importing them into leadwerks. I did remove the underscore, so they were named like grassa.tex and grassb.tex and i had no further issues generating the .mat files, so it seems to be a bug to me.
  18. Ahh okay, thanks for mentioning that all, i think i slowly get a hang on it. It didn't actually pop up in my mind to simply switch both timers but now that i think about it it actually makes totally sense Thanks a lot, for the timer.lua file, and for your time explaining an helping me (and hopefully others too, i think such a timer is very usefull for most players ) [Edit] Well, yepp, that work's better. I still have to add 100 ms to the "longer" timer, but yea it makes sense now. Actually i thought that the starting time of both timers would be the same, but hell yes, they're using a value of like 0.00001 seconds to run or so.
  19. Yea, cool, it now doens't fire the script at "launch" directly anymore. But the timevalues still do not represent real miliseconds and i'm missing one "tick". I did it as follows, and i believe, if i understood you correctly, that it should be correct. Last issue is, that it doesn't count the "last" tick (thus at 10 seconds) at all, the function OnTick2 is only called 4 times instead of 5 times this way. Sorry to bother you again, but i didnt really understand how the "Timer.lua" works, if i would understand that it might be easier for me to figure out why it is at it is (in case you read this before i edited the posting: Forget what i told about the "timer is less than 2 seconds", that was my fault, my audiosample is 15 sec, not 9, thus i just thought the timer was to "fast" because the audio still played hehe) function Script:Start() self.timer = Timer:Create(10000, self, self.OnTick) self.timer2 = Timer:Create(2000, self, self.OnTick2) end function Script:OnTick() self.timer:Stop() self.timer2:Stop() end function Script:OnTick2() self.target.script.hud.script:Skillgain("strength", "woodcutting") self.target.script.inventory.script:AddItem("logs", 1) self.target.script.inventory.script:AddItem("insects", 3) self.target.script.inventory.script:AddItem("bark", 5) self.target.script.inventory.script:AddItem("twigs", 3) self.target.script.inventory.script:AddItem("leafs", 5) end function Script:Use() self.timer:Start() self.timer2:Start() [...] end [...] function Script:UpdateWorld() self.timer:Update() self.timer2:Update() end
  20. Okay, thanks to your explanations i now got that up n running. Thanks for mentioning the 2nd "UpdateWorld()" function, i didnt see that it's fixed now. Well, the timer and such now works, the interval is inserted in miliseconds i guess? Don't i have to multiply with "GetSpeed()"? I'm asking, because the timer are finished long before my sound ends (the soundfile takes roughly 9 seconds to loop through, the timer does stop after about 4 seconds). Mhmm okay, i did a bit more testing. It seems that if i use 2 timers: self.timer = Timer:Create(10000 * Time:GetSpeed(), self, self.OnTick) self.timer2 = Timer:Create(2000 * Time:GetSpeed(), self, self.OnTick2) even though that "timer" is set to 10.000, the timer2 only ticks 4 times (starting at 0 --> the moment i "use" the object). If i add 2.000 to "timer" i get the expected 5 ticks. And it doesn't matter if i add "Time:GetCurrent()", the initial value of 2000 miliseconds is in real to low somehow. Instead of 2000 miliseconds per tick, it's roughly only 1000. That's strange.
  21. Mhm, sorry Rick, but i somehow do not get it. I added the "import" row at the top, i do understand what this does, so no problem. I started both timers in the "use" function (not the "start" function because the timer only shall executed once the item is used), so far no problem too. I added an statement "if self.timer2 then"... thinking that the "timer2" is only "true" every 2 seconds, but here's my problem. "timer2" is always true. I do not understand how to access the value that actually say's "2 seconds are over, now execute the following code". I added the new code in case you might want to see it. Btw. i did try to say "if self.timer2 < 2000 then" or "if self.timer2.interval <= 2000" but it keeps saying that i try to access "timer2 (a nil value)" -- give access to code in "GetEntityNeighbors.lua" import "Scripts/Functions/GetEntityNeighbors.lua" import "Scripts/Timer.lua" Script.target = nil --entity "Target" Script.damage = 0 -- float "Damage" Script.teamid = 2 --choice "Team" "Neutral,Good,Bad" Script.active = false function Script:OnTick() end function Script:Use() self.timer = Timer:Create(10000, self, self.OnTick) self.timer:Start() self.timer2 = Timer:Create(2000, self, self.OnTick) self.timer2:Start() self.sound = Sound:Load("Sound/Impact/axe_chopping_wood.wav") self.sound:Play() -- 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 end local counter = 0 function Script:UpdateWorld() self.timer:Update() end function Script:UpdateWorld() if self.timer2 then self.target.script.hud.script:Skillgain("strength", "woodcutting") self.target.script.inventory.script:AddItem("logs", 1) self.target.script.inventory.script:AddItem("insects", 3) self.target.script.inventory.script:AddItem("bark", 5) self.target.script.inventory.script:AddItem("twigs", 3) self.target.script.inventory.script:AddItem("leafs", 5) end if self.timer then self.timer:Stop() self.timer2:Stop() end end
  22. Hello, it's me again I watched an tutorial of Aggror where he did show how to setup timers. Now i have an idea where i might use those timers, but i ran into a problem. What i want to achieve is the following: - Use an item - start an 10 seconds timer - while that timer run's every 2 seconds some code shall run My problem is: if i start the timer, the resulting time is float, and thus it maybe smth. like 6.8356. Now my first approach was to "floor" that value (to remove the fraction), so it results in 6. The following step i did was to use the modulus % to check if the fraction of "6 / 2" is 0, if yes --> fire the script, if no --> do nothing. Now as you can imagine the problem is....the "timer" does not only check every 1 or 2 seconds, but several times within a second and so the results the timer delivers, well, are like 6.8356, 6.84164, 6.84736 and thus i do have 3x the fraction of 0 after flooring / using the modulus. (But if i do not floor the "timer" i'll mostly never ever get an fraction of 0, because 1.99999 or 2.00001 are never divided by 2 with a 0 fraction). So my next idea to prevent that happening was to setup a counter variable and check it every run, my if statement does look like this: - local timefrac = math.floor(self.timer) % 2 - if timefrac == 0 and math.floor(self.timer) > 0 and counter == 0 and self.timer < 2 then Now, as you can imagine yourself, it's quite some work to setup the code that way, especially if you may intent to use this code in different places with different timefactors. So i'm wondering if someone could point me an easier way to achiev this. I might have to mention that this code runs in "function Script:UpdateWorld()" and the "StartTimer" is called once the attached entity is "used". Maybe it's easier to understand if i provice the code, so i gonna attach it to this posting. Logging.txt
  23. Hello Josh and thanks for your reply, just a minute before i read your answer i came to the same conclusion and it does work pretty well
×
×
  • Create New...