xana Posted October 10, 2015 Share Posted October 10, 2015 Bonjour, c'est encore moi le nul en ce logiciel. Bref en essayant de créer des map Random ne sachant pas si c'était possible je me suis dit autant faire beaucoup de portes en formes de mur qui en commencant la partie s'active ou non j'ai voulue reprendre le code de BushBoutton.lua mais sa ne semble pas fonctionner. Merci pour vos aide, si il existe des façon de générer des map je suis preuneur un peut comme Monstrum désoler pour la pub. Hello, it's me again a draw in software. In short, trying to create Random map not knowing if it was possible I thought as do many doors wall shapes that starting the game is activated or not I wanted to resume code BushBoutton.lua but its not working. Thank you for your help, if there is way to generate a map I can preuneur as Monstrum grieve for the pub. Script.enabled=true--bool "Enabled" Script.soundfile=""--path "Sound" "Wav Files (*.wav):wav" v = math.random(1,2) function Script:Start() if self.soundfile then self.sound = Sound:Load(self.soundfile) end end if (v = 1;){ function Script:Use() if self.enabled then if self.sound then self.entity:EmitSound(self.sound) end self.component:CallOutputs("Use") end end } if (v = 2;){ function Script:Use() if self.enabled then if self.sound then self.entity:EmitSound(self.sound) end self.component:CallOutputs("Use2") end end } function Script:Enable()--in if self.enabled==false then self.enabled=true self.component:CallOutputs("Enable") self.health=1 end end function Script:Disable()--in if self.enabled then self.enabled=false self.component:CallOutputs("Disable") self.health=0 end end function Script:Release() if self.sound then self.sound:Release() end end Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted October 10, 2015 Share Posted October 10, 2015 Bonjour, couple of threads that may help. http://www.leadwerks.com/werkspace/topic/12419-procedural-level-generation-lua/page__hl__procedural%20generation#entry90592 http://www.leadwerks.com/werkspace/topic/12430-procedural-generation/page__hl__procedural+generation Quote Link to comment Share on other sites More sharing options...
xana Posted October 12, 2015 Author Share Posted October 12, 2015 Merci pour les liens mais j'ai remarqué que c'est beaucoup plus compliqué que prévue donc je vais resté avec ma deuxième idée en tête celle du déclenchement aléatoire savez vous comment résoudre mon code qui est fort erroné Thank you for the links but I noticed that it is much more complicated than expected so I stayed with my second idea in mind that the random trigger you know how to fix my code which is very wrong Quote Link to comment Share on other sites More sharing options...
thehankinator Posted October 12, 2015 Share Posted October 12, 2015 To start with you need to put your random number generation in Start() or something. It also needs to be a variable that will stick around by the time the Use() function gets called so do something like this: function Script:Start() self.v = math.random(1,2) end Put all the checks for v within one Use() function. Something like function Script:Use() if self.enabled then if self.v == 1 then self.component:CallOutputs("Use1") elseif self.v == 2 then self.component:CallOutputs("Use2") end end end 1 Quote Link to comment Share on other sites More sharing options...
xana Posted October 16, 2015 Author Share Posted October 16, 2015 Merci pour le code mais étrangement après chaque démarrage du jeu ou en appuyant de nouveau sur le bouton le résultat et toujours le numéro maximum (dans mon code c'est 4) Thank you for the code but strangely after each start of the game or by pressing again on the result and still the maximum number button (in my code is 4) Script.enabled=true--bool "Enabled" Script.soundfile=""--path "Sound" "Wav Files (*.wav):wav" function Script:Start() self.v = math.random(1,4) end function Script:Use() if self.enabled then if self.v == 1 then self.component:CallOutputs("Use1") elseif self.v == 2 then self.component:CallOutputs("Use2") elseif self.v == 3 then self.component:CallOutputs("Use3") elseif self.v == 4 then self.component:CallOutputs("Use4") end end end function Script:Enable()--in if self.enabled==false then self.enabled=true self.component:CallOutputs("Enable") self.health=1 end end function Script:Disable()--in if self.enabled then self.enabled=false self.component:CallOutputs("Disable") self.health=0 end end function Script:Release() if self.v then self.v:Release() end end Quote Link to comment Share on other sites More sharing options...
thehankinator Posted October 16, 2015 Share Posted October 16, 2015 Are you seeding the random number generator? Try doing the following line of code before your math.random call. math.randomseed(Time:Millisecs()) self.v = math.random(1,4) I remember seeing a thread talking about how Time:Millisecs() wasn't the best way to get a random number but I can't remember where it was now, should work better than no seed though. os.time would create a problem for Game Launcher so I would avoid it. Quote Link to comment Share on other sites More sharing options...
xana Posted October 17, 2015 Author Share Posted October 17, 2015 Ça fonctionne merci, il devrai peut être rajouter plus de Script dans le system Thank you it works, it can be expected to add more in the system Script Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.