Jump to content

Search the Community

Showing results for tags 'Lua'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Blogs

  • Development Blog
  • Canardian's Blog
  • Beyond Civilization Blog Ext
  • Tyler's Blog
  • macklebee's Blog
  • B-Byrnes' Blog
  • Marleys Ghost's Blog
  • omid3098's Blog
  • Richardsimpo123456's Blog
  • DJDD's Blog
  • Rick's Blog
  • --
  • xtreampb's Blog
  • Economically Disadvantaged
  • klepto2's Blog
  • Old Blog
  • Chris Paulson's Blog
  • Davaris' Blog
  • nil
  • Rekindled Phoenix's Blog
  • Flexman's Blog
  • Kattemaksu Online
  • Marcousik's Creations Blog
  • EVE LBS Studio
  • Rendering puzzles
  • Screen Size Utility
  • Niosop's Blog
  • 1299 RTS Game Project
  • Blitzbat's Blog
  • gordonramp's Blog
  • Andy Gilbert's Blog
  • Marcus' Blog
  • JornAggror Blog
  • diedir's Blog
  • wayneg's Blog
  • Masterxilo's Blog
  • Dave Lee's Blog
  • peubuy's blog
  • OD Arts -Leadwerks Blog
  • The progression......
  • Ultra Software Company Blog
  • The Progression
  • Pancake's Blog
  • Test Blog
  • BLaBZ Blog
  • Pure³d's Blog
  • dreamhead Blog
  • RVL's Blog
  • DB's Blog
  • Toxin Games Development Blog
  • CombatHelo Blog (RSS Import)
  • Foolish's Blog
  • ZioRed's Corner
  • Toxin Games Twitter
  • Shard - Third Initiative
  • Shard's Blog
  • Soamp's Blog
  • Soamp's Blog
  • Laurens' Blog
  • JT`s warehouse district
  • Kennar's Blog
  • KiteFuchs' Blog
  • KiteFuchs' Blog
  • Rachel's Dev-Blog
  • Eagle's Blog
  • zaphos' Blog
  • please delete this blog
  • Afke's Blog
  • Richard Simpson
  • knowledgegranted's Blog
  • EdzUp(GD)'s Blog
  • aGameLife's Kelasel MMORPG Blog
  • tournamentdan's Blog
  • Beyond Civilization Blog
  • smashthewindow
  • AnniXa's Blog
  • AnniXa's Blog
  • Elemental Development
  • DigitalHax Blog
  • Aria's Blog
  • Strogg76's Blog
  • Clackdor's Blog
  • Leadwerks Project Status
  • simpleprogrammer's Blog
  • Pathfinding in LE.2.x
  • Naughty Alien's Blog
  • smashthewindow's Blog
  • Ali Salehi's Blog
  • Jardar's Blog
  • Chris Vossen's Development Blog
  • Scarlet Thread Studios' Blog
  • Kronos' Blog
  • Benton's Blog
  • ChrisV's Blog
  • tjheldna's Blog
  • shadmar's Blog
  • 3D Masons, LLC
  • Andy Gilbert's Enviro Models
  • ParaToxic's Blog
  • NarkLord's Blog
  • ChrisMAN's Blog
  • ChrisMAN's Blog
  • CGMan's Blog
  • The Game
  • Chris Tutorials
  • Leadwerks 3 Experience
  • An Alien Saga
  • klepto2 & Leadwerks 3
  • Inside the mind of eternal insomniac
  • josk's Blog
  • Shader Development in Leadwerks 3.1
  • 3D Coat : Column game making of
  • Einlander's Blog
  • Ginger George's Blog
  • I have a problem
  • Michael_J's Blog
  • nasamydifol's Blog
  • Digman's Blog
  • noesisGUI
  • SavageDogg38's Blog
  • Built from Ruins
  • Remaining Days
  • test_external_blog
  • The Hunt For Food Blog
  • Crazy Minnow Studio
  • CrazyMinnowStudio
  • Guppy's Blog
  • Playing Online
  • Evayr's Blog
  • DerRidda's Blog
  • Karl's Blog
  • whiterabbit's Blog
  • Tinyboss Games
  • abendkleider's Blog
  • sacguccireplica's Blog
  • Arena
  • Imchasinyou's Blog
  • xtom's Blog
  • Lua is better than you think.
  • mdgunn's Blog
  • Crime Closer
  • lxFirebal69xl's Blog
  • Wedmer's Blog
  • Lockdown, going forward.
  • Pump-Action Captain
  • Igor's Blog
  • Dead Anyway
  • Runenrise and more
  • reepblue's Blog
  • Slippy's Corner
  • LUA Musings
  • severjack's Blog
  • mikeporter's Blog
  • miko93's Blog
  • Megalocerous' Blog
  • lxFirebal69xl's Blog
  • aiaf's Blog
  • Lostghbear's Blog
  • echo $BLOG_NAME > blog_title.tmpl
  • johnadam111's Blog
  • Dwarf Beard
  • burgelkat's Blog
  • Charrua's Blog
  • peterpaul's Blog
  • joshmathews' Blog
  • Martin Kearl's Blog
  • Brutile's blog
  • tipforeveryone's Blog
  • Glushchenko Blog
  • Express Lab Games Blog
  • Blueapples' Blog
  • DooMAGE's Blog
  • Structura devblog
  • UltraEngine - Experiences, add-ons and other Stuff
  • martyj's Blog
  • Dragonfreak's Blog
  • Brutile's Blog
  • assigmenthelp
  • Case Study Assignment Help
  • How to deal with bad grade ?
  • How to deal with bad grade ?
  • GameDev Blog
  • devcjohnson's Blog
  • devcjohnson's Blog
  • THE WHAT? Blog
  • The Demurian Scribe
  • GUI Editor
  • GUI Tutorial
  • noob_shaders
  • The Seventh World
  • Phodex Games Blog
  • Leadwerks VS Source 2
  • Work in Progress - Scifi PBR Media
  • [C++] First Player game start
  • The Blog of Yue
  • Snowboarding Development Blog
  • Ocean: Rendering in Leadwerks 4
  • Game Ready Maps
  • Ultra App Kit (Advanced Custom Widgets)
  • Poking around
  • SALVATIONLAND
  • Road & Traffic infrastructure [Vehicle based path following]
  • Usefull Scripts & Components
  • Thirsty Panther
  • Direct Macro

Forums

  • Software
    • General Discussion
    • Programming
    • Game Artwork
    • Showcase
    • Suggestion Box
    • Bug Reports
  • Addons
    • Extensions & Plugins
    • Components
    • Addon Development
  • Platforms
    • Windows
    • Linux
    • macOS

Product Groups

  • Software

Categories

  • Tutorials
  • Games
  • Work in Progress

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location

  1. Editor in lua project open Save As window when i click Run or Debug Game Last update in Steam beta branch
  2. 1. New game 2. Esc to call menu 3. Press Main menu 4. Continue game 5. If no app is froze yet do paragraph 2 again. Usually it happens at 2nd continue game but often happen at 1st too, Same approach works for me in main C++ project, game.lua globals.lua main.lua
  3. Josh

    Color Changer

    This uses the Quake light animation presets to add some interesting color modulation to any entity. ColorChanger.zip The following presets are available: Normal Flicker Slow Strong Pulse Candle 1 Fast Strobe Gentle Pulse 1 Flicker 2 Candle 2 Candle 3 Slow Strobe Flourescent Flicker Slow Pulse Todo: The candle presents don't look right to me, but I'm not sure what they are supposed to look like. I remember them as being a gentle flicker. There is no interpolation between the nearest two values, it just grabs one single value, so it's not very smooth. I guess this is appropriate for the strobe effects, but not for others.
  4. Josh

    AmbientNoise

    Plays a sound continuously or intermittently. AmbientNoise.zip
  5. Josh

    MatchRotation

    This component will copy the rotation of another entity, with adjustable smoothing. MatchRotation.zip
  6. Hi there team, time no see... I'm still working on the v4.0 Update for my Steam game. And one of the addons inside this update, was the option of drive an Opel Kadett car... And here is my question about... I have develop the mirror effect with a Camera using RenderTarget option on a Texture, and then the script: Script.TexturaProyecta=""--string "Textura" function Script:Start() local tex=Texture:Load("Materials/MisTexturas/Camaras_Texturas/"..self.TexturaProyecta..".tex") self.entity:SetRenderTarget(tex) end This works fine, but i've got a problem with the final image... Is there a way for make MIRRORED the image on the mirror? I've tried mirroring the texture, or using 2 cameras, but nothing works for me. I've got the same problem on another map: Many thanks in advance for your help.
  7. Hello team, I'm going crazy with this bull****-idea... Is there any LUA command that allows us to obtain the name of the map we are on? I want to store the map name we are playing in a String variable, and then execute an IF to validate that value so that: - If I am in the map bull****.map a variable has "OK" text. - If I am in the map bullface.map the previous variable has "NotOK" text. (sight) I am unable to get the map name to save it in the global variable. And I don't know why... I have created a script where I enter manually the name... But that script (despite being assigned to a pivot in the map that is executed when the map is loaded) is not able to modify the value of the global variable defined in main.lua I have tried to use the mapfile variable used in main.lua of the project, but still don't know how to use it to get the name of the map we are on... This question may seem simple, but it's really driving me crazy.
  8. Hi everyone, I'm currently encountering an issue with a Pick operation in my Lua code and I'm hoping someone can help me figure out what I'm missing. Here's the context: I have a player controller, which is essentially a pivot that creates a light and a camera. The player controller doesn't involve any movement, the mouse position on the screen simply influences the camera rotation. I also have an enemy that randomly spawns and passes in front of the light, down a corridor. I want to check two things - if the light is on, and if the enemy crosses the light's path. If both conditions are met, I want to call a method from the player script to the enemy script. Here's the relevant part of my player controller code which handles the light being on and the Pick operation: function Script:UpdateWorld() [...] if not self.flashlight:Hidden() then local pickInfo = PickInfo() local i**** = self.entity.world:Pick( self.entity:GetPosition(), self.lightRayEnd:GetPosition(), pickInfo, .25, false, Collision.Character ) if i**** and pickInfo.entity:GetKeyValue("classname") == "npc_nurse" then pickInfo.entity.script:SetPlayerIsShiningLight() end end end The flashlight check works as expected. However, I'm having trouble with the Pick method. It seems to correctly pick up the enemy when it crosses the ray's path. But it also appears to pick up another entity. I've simplified my map to include only a floor for the enemy to walk on and the basic set-up for the player controller. I've confirmed that the KeyValue is being correctly set in the enemy script (in the Start method), and that the collision is set to Character. Through debugging (I've removed all the console debug statements from the code above for clarity), I found that when I test for the pick position, it returns 0,0,0. To make sure I wasn't missing something in my calculations, I created another pivot to mark the end of the raycast (self.lightRayEnd). Does anyone have any idea what I could be doing wrong, or what might be causing this issue? I appreciate any input or suggestions. Thanks!
  9. Hello. I'm currently designing how my A.I. will work and one mechanic I would like to implement is to have my monsters go into sleep mode when they are idling and when the light level < n However, I can't find anything inside the API about checking the light levels. Can I retrieve this information with a pick info? Kind regards, Ttiki
  10. Just some background: i am making a game for a research project for school. I have no prior experience with coding so I'm a bit dumb Here's my question: How do i code in my animations? there are a lot of little things out there but they don't help me, i would appreciate it if someone were to explain it to me for my specific case. i have all of the animations done, i made them in blender. so far the only code i have is from these two posts, however i've moved the camera so that it is from a third person view: this whole animation thing has really been demotivating as i just dont know what i need so it would be nice to move past this to something equally as painful to find out. btw whilst researching i found there is very little helpful information out there anymore. there are countless posts where there are videos and websites linked however there they are either taken down or private, which is annoying because they could be helpful. either way, thank you for reading, i hope you understand what i mean and hope you might help me. Honestly all i need is a step-by-step (kind of) guide to how i get my animations to show for all my characters.
  11. so I try to get the center of the screen and find the mouse position and then find the difference then using ATan(change in y/ change in x) to find the angle the object must rotate to and set the angle to that, the only issue is when the mouse x is <= 0 the object flips (so lets say the right side of the object was facing the mouse it then becomes the left side) I assume this issue is to do with the fact that ATan(change in y/change in x)=ATan(-change in y/-change in x) but here is my code:
  12. Tell me how to get a similar result, for bending fishing rods under load?
  13. khotan

    Fracture ?

    Can i create a fracture sim based with voronoi in Leadwerks that control over on vertices or edges ? is it possible ? Lua or C++?
  14. How do I tell if a variable is odd or even using Lua? % is used in other languages is it the same with Leadwerks?
  15. During development of Leadwerks Game Engine, there was some debate on whether we should allow multiple scripts per entity or just associate a single script with an entity. My first iteration of the scripting system actually used multiple scripts, but after using it to develop the Darkness Awaits example I saw a lot of problems with this. Each script used a different classname to store its variables and functions in, so you ended up with code like this: function Script:HurtEnemy(amount) if self.enemy ~= nil then if self.enemy.healthmanager ~= nil then if type(self.enemy.healthmanager.TakeDamage)=="function" then self.enemy.healthmanager.TakeDamage(amount) end end end end I felt this hurt script interoperability because you had to have a bunch of prefixes like healthmanager, ammomanager, etc. I settled on using a single script, which I still feel was the better choice between these two options: function Script:HurtEnemy(amount) if self.enemy ~= nil then if type(self.enemy.TakeDamage)=="function" then self.enemy.TakeDamage(amount) end end end Scripting in Turbo Game Engine is a bit different. First of all, all values and functions are attached to the entity itself, so there is no "script" table. When you access the "self" variable in a script function you are using the entity object itself. Here is a simple script that makes an entity spin around its Y axis: function Entity:Update() self:Turn(0,0.1,0) end Through some magic that is only possible due to the extreme flexibility of Lua, I have managed to devise a system for multiple script attachments that makes sense. There is no "component" or "script" objects itself, adding a script to an entity just executes some code that attached values and functions to an entity. Adding a script to an entity can be done in C++ as follows: model->AttachScript("Scripts/Objects/spin.lua"); Or in Lua itself: model:AttachScript("Scripts/Objects/spin.lua"); Note there is no concept of "removing" a script, because a script just executes a bit of code that adds values and functions to the entity. Let's say we have two scripts named "makeHealth100 and "makeHealth75". MakeHealth100.lua Entity.health=100 MakeHealth75.lua Entity.health=75 Now if you were to run the code below, which attaches the two scripts, the health value would first be set to 100, and then the second script would set the same value to 75, resulting in the number 75 being printed out: model->AttachScript("Scripts/Objects/MakeHealth100.lua"); model->AttachScript("Scripts/Objects/MakeHealth75.lua"); Print(entity->GetNumber("health")); Simple enough, right? The key point here is that with multiple scripts, variables are shared between scripts. If one scripts sets a variable to a value that conflicts with another script, the two scripts won't work as expected. However, it also means that two scripts can easily share values to work together and create new functionality, like this health regeneration script that could be added to work with any other scripts that treat the value "health" as a number. HealthRegen.lua Entity.healthregendelay = 1000 function Entity:Start() self.healthregenupdatetime = CurrentTime() end function Entity:Update() if self.health > 0 then if CurrentTime() - self.healthregenupdatetime > self.healthregendelay then self.health = self.health + 1 self.health = Min(self.health,100) end end end What about functions? Won't adding a script to an entity overwrite any functions it already has attached to it? If I treated functions the same way, then each entity could only have one function for each name, and there would be very little point in having multiple scripts! That's why I implemented a special system that copies any added functions into an internal table. If two functions with the same name are declared in two different scripts, they will both be copied into an internal table and executed. For example, you can add both scripts below to an entity to make it both spin and make the color pulse: Spin.lua function Entity:Update() self:Turn(0,0.1,0) end Pulse.lua function Entity:Update() local i = Sin(CurrentTime()) * 0.5 + 0.5 self:SetColor(i,i,i) end When the engine calls the Update() function, both copies of the function will be called, in the order they were added. But wait, there's more. The engine will add each function into an internal table, but it also creates a dummy function that iterates through the table and executes each copy of the function. This means when you call functions in Lua, the same multi-execution feature will be available. Let's consider a theoretical bullet script that causes damage when the bullet collides with something: function Entity:Collision(entity,position,normal,speed) if type(entity.TakeDamage) == "function" then entity:TakeDamage(20) end end If you have two (or more) different TakeDamage functions on different scripts attached to that entity, all of them would get called, in order. What if a function returns a value, like below?: function Entity:Update() if self.target ~= nil then if self.target:GetHealth() <= 0 then self.target = nil --stop chasing if dead end end end If multiple functions are attached that return values, then all the return values are returned. To grab multiple returned values, you can set up multiple variables like this: function foo() return 1,2,3 end a, b, c = foo() print(a) --1 print(b) --2 print(c) --3 But a more practical usage would be to create a table from the returned values like so: function foo() return 1,2,3 end t = { foo() } print(t[1]) --1 print(t[2]) --2 print(t[3]) --3 How could this be used? Let's say you had a script that was used to visually debug AI scripts. It did this by checking to see what an entity's target enemy was, by calling a GetTarget() function, and then creating a sprite and aligning it to make a line going from the AI entity to its target it was attacking: function Entity:UpdateDisplay() local target = self:GetTarget() self.sprite = CreateSprite() local p1 = self.entity:GetPosition() local p2 = target:GetPosition() self.sprite:SetPosition((p1 + p2) * 0.5) self.sprite:AlignToVector(p2 - p1) self.sprite:SetSize(0.1,(p2-p1):Length()) end Now let's imagine we had a tank with a main gun as well as an anti-aircraft gun that would ward off attacks from above, like this beauty I found on Turbosquid: Let's imagine we have two different scripts we attach to the tank. One handles AI for driving and shooting the main turret, while the other just manages the little machine gun. Both the scripts have a GetTarget() function, as the tank may be attacking two different enemies at once. We can easily modify our AI debugging script to handle multiple returned values as follows: function Entity:UpdateDisplay() local targets = { self:GetTarget() } --all returned values get put into a table for n,target in ipairs(targets) do local sprite = CreateSprite() self.sprites.insert(sprite) local p1 = self.entity:GetPosition() local p2 = target:GetPosition() sprite:SetPosition((p1 + p2) * 0.5) sprite:AlignToVector(p2 - p1) sprite:SetSize(0.1,(p2-p1):Length()) end end However, any scripts that are not set up to account for multiple returned values from a function will simply use the first returned value, and proceed as normal. This system supports both easy mix and match behavior with multiple scripts, but keeps the script code simple and easy to use. Scripts have easy interoperability by default, but if you want to make your function and variable names unique to the script it is easy to do so. Let me know if you have any other ideas for scripting in Turbo Game Engine.
  16. Heyas, Should Script:Collision be able to detect if something has spawned inside of a defined trigger area? I'm using a rectangular CSG with CollisionType:Trigger to define an a trigger area. I want to detect when another CSG (Collisiontype: Prop) spawns inside the trigger area but seems to fail in that regard. Does the spawning CSG need speed (momentum) to be detected? Thanks in advance!
  17. Hello every one ! So today i am making my third person code. In my code i need to compare the name of child i want and the name of each children(GetChildren()) but i have got this error. when i try to compare their name. CODE: function Script:GetChildByName(nameRequest) for i = 0 , self.entity:CountChildren() -1 do local ent = self.entity:GetChild(i) local entName = ent:GetKeyValue("name") if entName == nameRequest then System:Print(nameRequest + " has been found !") return ent end end return nil end
  18. Hey everyone, i'm really new at this so please be understanding. I'm trying to write a Script to open a Door with a floorswitch. The idea is to drop a box and activate the switch. I'm using the prefab boxes and the SlidingDoor.Lua. I saw this video below but the problem is that the script works only if you put the value name in the Script function Script:Collision (entity, position, normal, speed) if (entity: GetKeyValue ("name") == "crate_small") then self.component: CallOutputs ("Open") end end but what i want is to be able to assign or to change the object-door-opener from the Script tab, by creating a Script Entry, I just don't know how cause i'm really new at this. Thanks for your help.
  19. Hello every one ! Today i wanted to add c++ code to object but looks to accept only lua script ?‍♂️ It is possible to add c++ into this box Or we just use c++ into app.cpp (add class but every thing is connected to the app file) ?
  20. When considering the script system in Leadwerks 5, I looked at alternatives including Squirrel, which is used by Valve in many games, but these gave me a deeper appreciation for the simplicity of Lua. There are only a handful of rules you need to learn to use the language, it’s fun to use, yet somehow it does everything you could ever need. These were three big issues I had to solve. First, the Leadwerks 5 API makes extensive use of smart pointers, which our binding library tolua++ does not support. Second, I wanted better auto completion and a better user experience in the IDE in general. Third, if an external IDE is going to be used it needs to be able to interface with the Leadwerks debugging system. To support smart pointers, I found a new library called sol2 that does everything we need. @Rick and I discussed the idea at great length and I am happy to say we’ve come up with a design that is simple to use and quite a bit easier than Leadwerks 4.x even. The binding code is nowhere near done but at this point I can see that everything will work. @AggrorJorn suggested using Visual Studio Code as our official script IDE in Leadwerks 5, and after investigating I think it’s a great idea. The auto completion is quite good and the IDE feels more natural then anything I could come up with using a custom text editor made with Scintilla. In fact eliminating the built-in script editor in Leadwerks 5 relieves me of a lot of uncertainty and potential issues when this is written. Finally, VS Code has support for custom debuggers. I wrote an example command line debugger for Leadwerks and I will use this to show another programmer how to interface with Leadwerks. (I don’t plan on writing the debugger myself.) With your feedback and ideas are shaping up to make Leadwerks 5 a huge leap forward over our previous designs. The improved simplicity of the new script system is a big cognitive relief. Having fewer things to worry about makes life better in a subtle but definite way. There’s something else that consumes a lot of mental attention. Social media and the internet have grown and changed over the years and become more efficient at consuming our attention. (Many features of this site are designed the same way.) The scary thing is that normal non-technical people seem to be more vulnerable than nerds. We’ll fire up the Witcher and play for an hour, but regular people are checking their phones 24/7 for feedback and validation. It’s much much worse than any accusation we got as kids of being “Nintendo zombies” because we spent an afternoon playing games instead of staring passively at broadcast TV. People who play games generally don’t care about posting photographs of their food or collecting followers. Somewhere along the line the internet went from being a weird thing on your computer to the collective consciousness of humanity. Reality is online and the physical world around us is just a mirage, one possible instance of a million possible individual experiences. Maybe it was around the time they started using AI to optimize clickbait that things got out of hand. Although my career and the way I live my life are only possible through the internet, I am old enough to remember life before the web, and in many ways it was better. Things were more focused. Even the early web before clickbait ads and online echo chambers was pretty nice. You could go to a record store and hang out talking to people about new music. Printed paper magazines were a thing. I already removed the link to our Google+ page in the website footer and no one noticed. I think about deleting our Facebook and twitter accounts, or at least not linking to them on our site. Why must every website pay homage to these monopolies? What are they doing for me, besides a limited flow of hits that pale in comparison to what my own email list brings in? I have written about this before but now that it is fashionable to criticize social media I might act on it. I don’t know, we’ll see. Please like, share, and retweet.
  21. The Leadwerks 5 API uses C++11 smart pointers for all complex objects the user interacts with. This design replaces the manual reference counting in Leadwerks 4 so that there is no Release() or AddRef() method anymore. To delete an object you just set all variables that reference that object to nullptr: auto model = CreateBox(); model = nullptr; //poof! In Lua this works the same way, with some caveats: local window = CreateWindow() local context = CreateContext(window) local world = CreateWorld() local camera = CreateCamera(world) camera:SetPosition(0,0,-5) local model = CreateBox() while true do if window:KeyHit(KEY_SPACE) then model = nil end world:Render() end In the above example you would expect the box to disappear immediately, right? But it doesn't actually work that way. Lua uses garbage collection, and unless you are constantly calling the garbage collector each frame the model will not be immediately collected. One way to fix this is to manually call the garbage collector immediately after setting a variable to nil: if window:KeyHit(KEY_SPACE) then model = nil collectgarbage() end However, this is not something I recommend doing. Instead, a change in the way we think about these things is needed. If we hide an entity and then set our variable to nil we can just defer the garbage collection until enough memory is accrued to trigger it: if window:KeyHit(KEY_SPACE) then model:Hide()-- out of sight, out of mind model = nil end I am presently investigating the sol2 library for exposing the C++ API to Lua. Exposing a new class to Lua is pretty straightforward: lua.new_usertype<World>("World", "Render", &World::Render, "Update", &World::Update); lua.set_function("CreateWorld",CreateWorld); However, there are some issues like downcasting shared pointers. Currently, this code will not work with sol2: local a = CreateBox() local b = CreateBox() a:SetParent(b)-- Entity:SetParent() expects an Entity, not a Model, even though the Model class is derived from Entity There is also no support for default argument values like the last argument has in this function: Entity::SetPosition(const float x,const float y,const float z,const bool global=false) This can be accomplished with overloads, but it would require A LOT of extra function definitions to mimic all the default arguments we use in Leadwerks. I am talking to the developer now about these issues and we'll see what happens.
  22. Hi Leadwerkers :), I am wondering for quiet a while now, if and how the two things, I will explain in a second, are possible. First can I grab the "self" value of an function caller WITHOUT using arguments? I would expect this to work with the lua debug.getinfo() functionality? Maybe I better explain it with pseudo code: --Script 1: function Script:Test() Script2:CallingThis() end --Script 2: function Script:CallingThis() --get self of caller end Btw I have no idea how you offically call a "caller" maybe its calle? I dont know Second how to grab an arguments root variable. What I am already aware of is accessing variables like this self["myVariable"] so I could send self as argument 1 and "myVariable" as string in argument 2, but I am looking for a way to prevent this to optimize the code and lower the error rate. Again some pseudo code: --Script 1: Script.myVariable = 10 function Script:Test() Script2:CallingWithArgument(self.myVariable) end --Script 2: function Script:CallingThis(argument) --if I do anything with the variable argument here it only changes the local "argument" variable of course --this is stupid but I guess it will explain what I mean: local rootVariable = argument:GetRoot() rootVariable = 20 --> myVariable is changed to 20 within the Script 1 end You would do me a great favor if you would give me some input on this. I would be able to improve my code even more Thanks in advance for answering and have a nice day
  23. I have been working on a menubar widget and it came out pretty nicely. I thought i would release it either for people to have an example of what would be possible with the widget's flexibility or just for people to use it. For now it only works in C++ since it makes use of CallFunction(). MenubarElement.lua !! Make sure when you create the widget you create it last so it will render on top !! It allows horizontal rules and submenus. How to use: (C++) Create the widget and fill the menu float scale = gui->GetScale(); mnuBarItem = Widget::Create("Name", 2 * scale, 2 * scale, 60 * scale, 26 * scale, gui->GetBase(), "Scripts/GUI/MenubarElement.lua"); mnuBarItem->SetObject("backgroundcolor", new Vec4(0.7, 0.7, 0.7, 1.0)); mnuBarItem->AddItem("Temp0"); mnuBarItem->AddItem("Temp1"); mnuBarItem->AddItem("@-");//create a horizontal rule(menu seperator) mnuBarItem->AddItem("&Submenu");//this will hold the submenu created next //create a submenu from the last added item in the list mnuBarItem->CallFunction("C_CreateSubMenuFromLastItem"); mnuBarItem->CallFunction("C_AddItemToLastSubMenu", "Sub0_A"); mnuBarItem->CallFunction("C_AddItemToLastSubMenu", "Sub0_B"); mnuBarItem->CallFunction("C_AddItemToLastSubMenu", "Sub0_C"); // mnuAccount->AddItem("Temp2"); Catching widget events ProcessEvent(Event event) { if (event.id == Event::WidgetAction) { if (event.source == mnuBarItem) { if (event.data == 0) { // } else if (event.data == 1) { // } //(event.data == 2) horizontal rule // else if (event.data == 3)//submenu { int item = event.position.x;//submenu itemidx if (item == 0) { // } else if (item == 1) { // } else if (item == 2) { // } } else if (event.data == 4) { // } } } } Also it needs a call to update somewhere in your loop. Which is just used to update some delay timing. mnuBarItem->CallFunction("C_Update");
  24. Hi I am heavily working on my own user interface system at them moment and I wonder if there is a easy way to resize a loaded font. Example pseudo code for the functionality I am searching for: --Pseudo Code self.font = Font:Load("Arial", 6, Font.Smooth) --Load Font self.font:SetSize(10) --Change size during runtime I have a solution for this by preloading the font in all sizes and then change the rendered font. But this isn't memory efficient, or are Fonts so small that it makes no diffrence, either way it does create a lot of code Thanks for ideas in advance Markus from Phodex
  25. Hi Leadwerks fellows I think some of you may run into the same problem once in a while. The problem is the following. My AI wants to grab an item, but if, for whatever reason, this item gets released, while the AI is moving towards the item, the game just crashes, with no error. The same happens if I grab an item as a player and release the entity in my function, I fixed this by releasing the entity some time later in the loop. And yes I am testing my variables if they are nil, so I guess this could not be the problem... I think this has to do with the order how the loops are iterated through and I kind of understand the problem, but how to overcome this. Any safe solutions on how to release an entity, which is used somewhere else in the code? Thanks for reading so far and thanks for your help in advance! Markus from Phodex Games
×
×
  • Create New...