Announcement: Remember: you are giving away your fantastic ideas for free, and somebody else might even make money from them (or appear to). That's just how the world works! If you're worried about it, maybe you shouldn't post your ideas here.


Caravel Forum : DROD Boards : Feature Requests : Externally-settable Variables for default scripts (We'll probably never get this...)
New Topic New Poll Post Reply
Poster Message
Xindaris
Level: Smitemaster
Avatar
Rank Points: 500
Registered: 06-13-2015
IP: Logged
icon Externally-settable Variables for default scripts (0)  
So here's something that would be highly useful, but probably rather tough to implement in the current scripting system:

Wouldn't it be cool if, when designing a character script that can be reused in various situations, you could actually have variables that are determined when it's placed in the editor?

For example, say I want something to behave like a mirror for X pushes and then behave like an obstacle (more-or-less), but I want X to vary depending on where I'm using it. It would be neat if instead of having to copy and paste that character/script separately for each occasion, I could have a specially-designated variable in the general character script like "&Pushes" that gets shown as a text box when the character is placed the level-builder can fill in with a number, and whatever number was put in there gets used throughout that instance of the character's script. There are significantly more interesting uses, but hopefully this illustrates at least why this would be nice and a little better describes what I'm talking about.

I imagine the best implementation would have the script-writer include these "externally settable" variables with some special symbol and giving them a default value at the same time. Because of the way DROD handles variables in general, they would have to be inherently local and only apply to characters that directly call them (so, you'd have the variable name "&Pushes" in general, but no character that didn't have a default value for that variable set somewhere near the start of its script would be able to call it because the editor wouldn't ask for it on placing the character).

This kind of thing exists in Creeper World 3's coding system, if anyone's seen that; I don't know of much else that has something like it.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by mrimer at 04-11-2016 07:39 PM]
04-04-2016 at 06:49 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 2323
Registered: 12-28-2004
IP: Logged
icon Re: Externally-settable Variables (+1)  
It would be relatively easy to implement a scripting command which would do "Insert custom character's default script here", and it would be more than enough to do what you ask for.

But I guess we'll probably never get this... ;)

____________________________
I am a skelliopath.
04-04-2016 at 07:31 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 500
Registered: 06-13-2015
IP: Logged
icon Re: Externally-settable Variables for default scripts (0)  
I would love to have this option; it's what I originally thought "start global script" did before it messed up a hold I had in progress and I had to go learn what it actually does.

I do feel silly for not thinking about such a (relatively) simple workaround.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 04-11-2016 11:24 PM]
04-11-2016 at 11:23 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 500
Registered: 06-13-2015
IP: Logged
icon Re: Externally-settable Variables for default scripts (0)  
I'd like to note that I've found a genuine use case in which something like what I described here is necessary and probably not even skell's suggestion will work:

-Entity type A is supposed to generate entities of type B in the midst of its scripting and tell each such entity it generates some information.
-The "obvious" way to do this is to set some global variables and have entity type B read those global variables in as its local variables.
-But wait, there are TWO of entity type A in the room. Due to how move order works, if entity 1A (which moves first) generates entity 1B and sets the global variable to x, then entity 2A always moves before 1B does, and then entity 2A will OVERWRITE the global variable with the value y in the middle of trying to generate an entity 2B, so now 1B and 2B both read "y" as their Important Local Variable, which for 1B is the wrong value.

(I didn't imagine this issue up so much as ram my head straight into it while trying to figure out how to implement a custom element idea I had.)


Also, a perhaps better suggestion for how to implement this idea:
Make it so that, in addition to the "Generate Entity" command, there is a "Generate Entity with Local Variables" command which in its parameters has a pairing of every existing local variable (.Varname) with a place to put what you want to assign that variable to in the newly-made entity. If you don't put anything in the box next to a certain variable then it remains set at the default of 0 for the generated entity.
Or possibly it just has a big textbox where the scripter can type things like ".var1name = value1, .var2name = value2", etc. and which errors in the same way that setting a variable wrong does for any incorrect input.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 11-16-2016 04:51 AM]
11-16-2016 at 04:49 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
averagemoe
Level: Delver
Avatar
Rank Points: 84
Registered: 03-22-2012
IP: Logged
icon Re: Externally-settable Variables for default scripts (0)  
I see that this has been approved for the yellow arrow. What does that mean? Turn into monster will now mean start global script for my character type?

____________________________
Maybe it's me stereotyping, but I think Jobus is like the Jar Jar of DROD.
11-16-2016 at 05:39 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Nuntar
Level: Smitemaster
Avatar
Rank Points: 3210
Registered: 02-20-2007
IP: Logged
icon Re: Externally-settable Variables for default scripts (+1)  
No, it means at least one of the devs finds it interesting enough to mark it for future reference. If it gets added, it will be marked with a tick (and usually also the topic will get bumped to make it more visible).

If it ever gets added, it certainly won't be by changing the behaviour of "Turn into monster", which has the potential to break a ton of existing rooms.

____________________________
50th Skywatcher
11-16-2016 at 02:07 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Lucky Luc
Level: Smitemaster
Avatar
Rank Points: 1069
Registered: 08-19-2012
IP: Logged
icon Re: Externally-settable Variables for default scripts (0)  
quote:
Xindaris wrote:
-But wait, there are TWO of entity type A in the room. Due to how move order works, if entity 1A (which moves first) generates entity 1B and sets the global variable to x, then entity 2A always moves before 1B does, and then entity 2A will OVERWRITE the global variable with the value y in the middle of trying to generate an entity 2B, so now 1B and 2B both read "y" as their Important Local Variable, which for 1B is the wrong value.



While I kind of like the idea of having some less workaroundy way to do this, I don't think that's true. As far as I know, a generated entity will immediately start its script after generation, even before 1A continues its own execution. Before GoSub was added as a script command, this could actually be used to simulate function calls, though in a pretty memory-leaking kind of way. There may still be cases where this order might be problematic, but I can't think of one right now, so I guess for now the workaround might be enough.

(skell or any other DRODscript-god, please correct me if I'm wrong)
11-16-2016 at 02:24 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Feature Requests : Externally-settable Variables for default scripts (We'll probably never get this...)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.