+MKW Posted March 26, 2008 Posted March 26, 2008 (edited) Is it possible to trigger user defined events from scripts? Example: I've got an item which represents the number of Bonus points the player got. Tasks like increasing, decreasing should be programmed once as event scripts related to this item. Anywhere in the game I just want to fire the according event, not write the same code again and again. Edited March 26, 2008 by MKW Quote
+Delta68 Posted March 26, 2008 Posted March 26, 2008 At a guess, I'd say put them into the .lua file between these two lines: -- #Author Functions Go Here# -- -- #End Author Functions# -- The builder might put quotes around the function names at the point at which they are called though so they would have to be edited before a final compile.... Quote
+cache_in_pocket Posted March 26, 2008 Posted March 26, 2008 You can create author defined functions, but they are difficult to call in a way that Builder won't complain about it; however, depending on what you are doing, it might be what you need. But, as an easy way to do what you are saying is to create a task. Create an event on 'Status change' (I think that's the one...I don't have builder running at my current location.) Then from within your script, you change the status of the task...complete = true/false. The only thing I haven't tried here is to reset the task within the event of the task. For instance, elsewhere in your program, you activate the task script.. Set ztaskEatBanana equal to true Then in the 'Status change' event of the EatBanana task, you do Set ztaskEatBanana equal to false to get it ready for the next time you call the task. Obviously in your task, you'd do and if then to test if the task.complete is true of false; but the problem is if lua can work recursively...i.e. make a call to the function it is currently in. If so, great...if not, you can check the condition before you set the task true or false or create a second task to clear the first task. Anyway, just an idea. If you don't want to experiment with it, I can do it later...I just don't have the time right now. Quote
+sTeamTraen Posted March 31, 2008 Posted March 31, 2008 but the problem is if lua can work recursively...i.e. make a call to the function it is currently in. Lua was invented by a bunch of academic computer scientists. Recursion will have been in there well before division or any math functions. Quote
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.