Jump to content

Evoke Events from scripts


Recommended Posts

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 by MKW
Link to comment

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....

Link to comment

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.

Link to comment

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...