Jump to content

[Lua] Enable/Disable scripts


Rick
 Share

Recommended Posts

Will we be able to enable or disable entire scripts in LE3D? In making this marble game I'm using all entity scripts with a generic minimal main script so I often need to disable and enable between scripts to get the functionality I want. In LE2 I'm using the message system, targeting, and custom entity script variables to do this but would be nice to have a default way to tell the engine/editor to not call a certain instance of script methods. I don't know how far it can be taken because I believe there are multiple methods the engine/editor will call by default so not sure if you do an all or nothing thing but might be nice to determine what you can enable/disable. I would think the most basic separation would be update & draw methods.

 

Maybe something like:

 

scriptInstance:Disable(ALL)

scriptInstance:Disable(DRAW)

scriptInstance:Disable(UPDATE)

 

 

An example of how I'm doing this and would do it in LE3D from my understanding of the system Josh wants is as follows:

 

I have a LevelStart entity in my scene. The level starts by having the camera behind the marble which has it's own script to allow player movement BUT it starts out disabled so the player can't move yet. The LevelStart entity starts some music and does a 3, 2, 1, GO countdown. When it reaches GO it enables the marble script which allows the player to move the marble. The connection between the 2 is the target system.

 

When they reach the Goal entity, that script will disable the marble script so the player can't move anymore. It kicks off some music and changes scenes to the next scene.

 

Being able to enable/disable parts or all scripts out of the box is useful. Just checking that this was thought of.

Link to comment
Share on other sites

Hi Rick

funny that your example is exactly what i have done for my starting race game,menu then player locked until 3,2,1,go

then freed until the race finish and finally locked again to launch the menu at last.

I am ok with you that is a bunch of variables, tags and headaches to make it working as i wanted

but i would not be against doing this with more ease,

by the way, best wishes and lot of coding...

AMD Ryzen 5900HX - Nvidia RTX 3070 - 32 Go - 1To SSD - W11

Link to comment
Share on other sites

Guest Red Ocktober

at first glance this sounds interesting... being able to stop and start a lua script...

 

but after thinking about it for a short while, i'm concluding that something like this is equivilant to

the GOTO programming command... not OOP compliant in my opinion...

 

hear me out on this before you take away my drink...

 

lua, i would imagine would be used primarily to get objects alive and working in the editor, right...

well... shouldn't all "living" objects be "alive" all the time... ready to respond to stimulus... and idle

when not responding to anything... and destroyed when no longer needed...

 

i'm thinking that the need to start and stop a script is an indication of a poorly thought out

logic... i don't see any need for it...

 

ok... i'm ready... who's the designated driver tonight... ;)

 

--Mike

Link to comment
Share on other sites

I like talking things out so I won't try to take your drink away but will just state my case.

 

The need I have for this is because I'm creating scripts like a Timer (for example). I'll be showing all of this and how I'm working with it in a few days but it's working out pretty slick and it's somewhat how I'm thinking LE3D will work but not sure.

 

I'm using the targeting system and messaging system as outputs from one script to others. A common theme I'm finding is enable/disable of certain parts to get a flow of functionality. It is my understanding LE3D will have a similar output/input type of system so I would think this would be handy.

 

Below is some of the components I've been working on most the day.

 

To follow the flow of the screenshot top left is a timer object. By default it's set to enabled, while all the other components are set to disabled. I have the timer set to an interval of 2 seconds and only run once in the properties. It's target 0 is the P-Var component. When the 2 seconds of the timer are up it sends the "enable" message to the P-Var (this message is configurable in the properties).

 

P-Var is a persistent storage for variables (uses an xml file to pair name/value variables that need to be saved through runs of an exe). You define the xml file to read and the variable name in the file to get the value for. When it gets that value it to sends messages messages to it's targets and the msg to send is configurable by target. If this case target 0 is linked to the If component so I'm sending a "compare" msg, it also passes as extra data the value Pi-Var read in.

 

The IF component has a setting that you give a value. It will compare that value with the value passed in from Pi-Var (in this case) and if they match it'll fire it's messages to it's target. In this case it has the sound component as target 0 and it will send an "enable" message to it so it plays it's sound.

 

So the Timer object is the only thing that starts out being enabled (because I only want the sound to play 2 seconds after the game starts AND if the data in the file matches the data in my IF statement). I think perhaps the work enable/disable could be talked about, but this is how I thought of it. Sometimes I may want a sound to play right away when the scene is loaded so in that case I would enable it in the editor. Each of these scripts have enable/disable.

 

I'm actually really excited about the possibility of this kind of style and if this could be LE3D's Lua implementation because it will allow non programmers the chance to actually get some kind of functionality into their game without coding. I understand this is controversial to some of the programmers in LE, but I think there could be a future in it within LE.

 

scripts.png

Link to comment
Share on other sites

Guest Red Ocktober
The need I have for this is because I'm creating scripts like a Timer (for example). I'll be showing all of this and how I'm working with it in a few days but it's working out pretty slick and it's somewhat how I'm thinking LE3D will work but not sure.

 

i hear ya Rick... but really... it sounds like you're going the rube goldberg route on this one...

 

a self sufficient object that doesn't need external logic i think would be the better approach... look at all other lua based objects in the editor... they just need to be dropped into the editor and they work...

 

design a timer object with start, stop, reset methods... and forget about stopping the script... it's really not the way to go...

 

 

--Mike

Link to comment
Share on other sites

look at all other lua based objects in the editor... they just need to be dropped into the editor and they work...

 

The problem with that approach, I feel, is that you still have to be a programmer or know a programmer to make that happen. I'm trying to help the non programmers and I don't want to do that by creating a very specific model script just for 1 person. I'd rather like to reach more people with reusable components they can assemble themselves. I've used C#, C++, & Lua back and forth back and forth and I've programmed a good number of game elements for each language probably twice lol. My personal findings of doing that is that the Lua components, even with logic, to be neatly bundled and use again and again. Even in LE2's less than ideal target/message system.

 

design a timer object with start, stop, reset methods... and forget about stopping the script... it's really not the way to go..

 

Honestly that's basically what I've done I just called things enable/disable. Stopping a timer component is basically the same as stopping the script that is the timer object. When thinking about other components like GUI elements and such I may want to disable the update method of the script so no input can be had (if the control is disabled) but still keep the drawing part enabled so it's still drawn.

 

The way the timer object works is by updating the timer in the Update() method of the script. Right now when I disable I have a variable inside this specific script that holds if the timer is enabled or disabled. Then inside the Update() method of this component I check that variable and if it's enabled I update the timer code. Any component that would have a constant ticking or drawing could benefit from being able to disable/enable those components directly instead of indirectly like I'm doing.

 

The reason I don't feel I'm doing the below image is because he's not using reusable components and he's solving a much simpler problem then a video game ;). I currently have about 15 components that I reuse over and over again between about 14 scenes where the entire game logic is inside the scene by combining these components to make the entire game. For this game I'm purposely breaking things down to smaller components that I can see being used in other games and by other people. I don't pretend it's the prettiest in LE2's design but it's a proof of concept I think.

 

rube-goldberg.jpg

Link to comment
Share on other sites

Guest Red Ocktober
Stopping a timer component is basically the same as stopping the script that is the timer object.

 

no... it's not... and this key misunderstanding is why you can't see what i'm trying to point out to you...

 

The reason I don't feel I'm doing the below image is because he's not using reusable components and he's solving a much simpler problem then a video game

 

you also fail to understand the rationale behind the image as well as behind the picture... the fact that he's not using reusable components is irrelevant... it's the fact that he's going around the dark side of the moon to accomplish a simple task... sorta what i see you doing here... :D

 

I'm trying to help the non programmers and I don't want to do that by creating a very specific model script just for 1 person. I'd rather like to reach more people with reusable components they can assemble themselves.

 

then design a timer with a start stop switch... that way you'll be able to just drop it into the editor... and the player could "press the switch"...

design it so that the "isRunning" property is exposed and visible to the user, so that he/she or anyone can start stop it at will (collision wise, pick wise, whatever)... no coding necessary...

 

also, if someone wants to start or stop it from code, make the thing message or event aware...

 

this way you'll have an object thaqt you can distribute to anyone and they can just pop it into the editor and not have to worry about starting or stopping any script... if you make it intuitive they'll know what to do to start and stop it...

 

just like a well designed door object... the designer wouldn't have to tell you how to open it, would he...

 

 

 

hey... you seem intent on doing it the start script/stop script way... all i'm doing is trying to point out why i think it's the wrong way, in my humble opinion... i'm sure you're gonna argue till time immortal, and do it the way you want... that's ok, eventually the realities of development will force itself upon you and you'll see what i'm talking about... :P

 

(just kiddin' around :D have fun with your project, good luck)

 

--Mike

Link to comment
Share on other sites

sorta what i see you doing here...

 

Yeah, that's why I made both comments about that image. Making a video game isn't a simple task. One could probably say making a basic script to rotate a windmill model could be the simple task, but I'd say that's like brushing your teeth with a really bad toothpaste. The toothpaste would be better if you had a rotate logical entity that you could piece together things in the editor to make the blades rotate because it then can be applied to many different things that need to be rotated.

 

 

then design a timer with a start stop switch... that way you'll be able to just drop it into the editor... and the player could "press the switch"...

 

Some timers aren't triggered by a player pressing it. Also "press the switch" itself is a task that would need to be programmed. Josh's switch is nice and all but it's very specific and tied to his model. I feel if you ask a non programmer to adapt that thing to their own needs and they won't be able to because of what it entails.

 

 

design it so that the "isRunning" property is exposed and visible to the user, so that he/she or anyone can start stop it at will (collision wise, pick wise, whatever)... no coding necessary...

 

How would you propose this is done without coding?

 

 

this way you'll have an object thaqt you can distribute to anyone and they can just pop it into the editor and not have to worry about starting or stopping any script... if you make it intuitive they'll know what to do to start and stop it...

 

I think we are sort of on the same page but just slightly off. There really is no worrying about stopping or starting the script. Sending "enable" or "disable" output/message to it will do this for them.

 

 

It might seem a little more clear once I get this game out, but we aren't really that far off from each other I think as difficult as that might seem by the posts.

 

I guess a side point to the topic is to give many features to us from these scripts so we can put game logic in them instead of having them be just simple basic rotating windmill that LE2 pretty much is used for.

 

 

i'm sure you're gonna argue till time immorta

 

Not argue, discuss. You make a point, I make a point, and we go back and forth :D

Link to comment
Share on other sites

Guest Red Ocktober
Quote

design it so that the "isRunning" property is exposed and visible to the user, so that he/she or anyone can start stop it at will (collision wise, pick wise, whatever)... no coding necessary...

 

How would you propose this is done without coding?

simple...

design it so that it responds to being picked (onPick callback or event) or so that it responds to the user running into it (onCollision callback or event)... this way all the user has to do is look at it and press a mouse button... or run into it...

 

or come up with some other ingenious way of letting this timer object know it has to start itself... i'm sure there are a few other ways of making this thing a self sufficient game object...

 

 

Not argue, discuss. You make a point, I make a point, and we go back and forth

the point i'm trying to get you to see is starting and stopping scripts is not implementing programming logic... it's only a short sighted solution to plug up a flawed design...

 

what point are you trying to make... i really don't see any... and i am trying (seriously)...

 

all you're doing is trying to argue that the way you're doing this is perfectly sound, despite the reasons i've shown you to the contrary... but you provide no reasons in support of your argument, except possibly that this is the way you want to do it...

 

so... in light of your lack of a point to support any of your arguments... and because i really don't feel like getting into another one of your pointless back and forths... i concede :D

 

(sorry... you just bring out the best in me :D )

 

like i said above... do it your way... and good luck...

 

--Mike

Link to comment
Share on other sites

(sorry... you just bring out the best in me )

 

I know, sorry about that. I honestly don't try to. I just want to express my thoughts and opinions about things. We can disagree about those with some kind of respect and we have come a long way it would seem. Thanks for the good luck. I'll keep on truckin'.

Link to comment
Share on other sites

Programming such things could be easy if it was inside some game framework :

 

Update () {

 

if(varEntityEnabled) {

....

}

 

if(varGameStarted) {

....

}

 

}

 

It's very specific also, not all games will need that function.

Lot of games will just load the level and NPC and run all that, very far distant NPC will just do nothing : No AI, no frame animation update etc ...

 

 

For Lua and LE3D, i really don't have any clue on how will it work and how will it be ?

Possibility to make a complete complex game with Lua ?

 

Let's wait for the fisrt version , use it, that we will be able to propose perhaps some things :)

(But i share some same point of view on how could be the scripting side in some way that is very what is done on several other indie engines)

Majority of LE2 users are more pure programmers, and prefer to do all in C++, i like that way, but i would prefer also direct scripting of the gameplay directly in some simple Framework.

Sometimes some of us prefer to put all time on game creation and gameplay than coding.

Stop toying and make games

Link to comment
Share on other sites

Sometimes some of us prefer to put all time on game creation and gameplay than coding.

 

Are u serious dude?

 

How do you think game creation and game play is achieved? Yes the answer is coding. It certainly as hell is not with the artwork.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

I think his English isn't that good sometimes. I'm thinking he meant coding gameplay features instead of coding, say, a GUI system.

 

 

It's very specific also, not all games will need that function.

 

@ YouGroove, the idea of letting one disable/enable scripts or script functions was that it's just added functionality for us to use if we so wish. If one didn't want to go that route then they don't have to but having that feature wouldn't affect them in any way, but could affect the person wanting the feature in a big way. We don't always think of every single way something will be used so adding features that probably aren't that big of a deal to add is nice. That's all I was thinking.

Link to comment
Share on other sites

It depends on your game target also.

 

Basic turn based RPG gameplay is not that complicated at all ; if you have collision between chacracters and environement.

All the time you'll put will be for inventory , skills etc ...and a lot in the HUD and menus also.

In that case gameplay si trivial, i do that very fast in 3D Game Studio attaching script on entities and managing the variables of each entity and general ones.

But without solid 3D art and design it's useless specially for some RPG game !

 

Just take the 2D RPG toolkit RPG Maker, the tool have all you need to make some complete RPG, but all people using it just uses basic tiles provided, nothing

really beautifull or worked !

Even Final Fantasy 4 or 6 tiles are lot more beautifull than all stuf made with RPG Maker.

 

So no, not only the engine and programming will make the game.

 

And yes, programming will be needed indeed , i'll do C++ with LE3D , but if it uses Lua as 3D Game Studio use it :

each entitie have some action function that is called every frame so i'll instead use Lua only indeed :)

Stop toying and make games

Link to comment
Share on other sites

but if it uses Lua as 3D Game Studio use it :

each entitie have some action function that is called every frame so i'll instead use Lua only indeed :)

 

You can kinda do that already in LE2..... not that I'd recommend it for a whole game though.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

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.

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

 Share

×
×
  • Create New...