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 : Every kind of wait for should enable multi-selecting within the SAME command (because long if-else if-else if statements are TERRIBLE.)
New Topic New Poll Post Reply
Poster Message
Xindaris
Level: Smiter
Avatar
Rank Points: 405
Registered: 06-13-2015
IP: Logged
icon Every kind of wait for should enable multi-selecting within the SAME command (+3)  
Please observe the following code:
Click here to view the secret text


If that seems tedious to you, imagine being the one trying to write it, making sure you got everything you needed to check for and didn't repeat yourself several times. This list isn't even done yet. The Wait for Entity command, and ONLY the Wait for Entity command, allows the use of such wonderful buttons as Shift+Click, Ctrl+Click, to select more than one option within the command to test for, all in one command. I contend that doing all sorts of things would be immensely less painful for everybody if we could have the same for "Wait for Entity Type" and "Wait for Item", and any other "Wait for"'s that test for a thing at a location that I may have forgotten. Please, please.

____________________________
109th Skywatcher

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


[Last edited by Xindaris at 02-01-2017 09:41 PM]
02-01-2017 at 09:38 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
hyperme
Level: Smiter
Avatar
Rank Points: 449
Registered: 06-23-2006
IP: Logged
icon Re: Every kind of wait for should enable multi-selecting within the SAME command (0)  
Due to the way DRODscript works internally, this probably isn't possible.

Most of the Wait For commands use take whatever you select and pass its numerical ID as an argument to the internal DROD code to check for things. Wait For Entity works differently, having a set of flags you can turn on and off. However, this is done using Computer Science Voodoo aka bit checking to send the composite flag through as a single number. Multi-selecting stuff in the other Wait For commands can't be done, as even basic data structures would require several changes to support.

The good news is that other ways to achieve this are possible. The simplest would be a 'Wait for Item Set' command, where each option would cover multiple elements. Obvious sets include Force Arrows, Disabled Arrows, Potions and Walls (All).

____________________________
[Insert witty comment here]
Qzvlkx?
02-02-2017 at 07:16 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
vittro
Level: Smiter
Avatar
Rank Points: 473
Registered: 04-17-2005
IP: Logged
icon Re: Every kind of wait for should enable multi-selecting within the SAME command (0)  
quote:
hyperme wrote:
Due to the way DRODscript works internally, this probably isn't possible.

Most of the Wait For commands use take whatever you select and pass its numerical ID as an argument to the internal DROD code to check for things. Wait For Entity works differently, having a set of flags you can turn on and off. However, this is done using Computer Science Voodoo aka bit checking to send the composite flag through as a single number. Multi-selecting stuff in the other Wait For commands can't be done, as even basic data structures would require several changes to support.


I don't see why a "multi Wait For item" command couldn't trivially be converted to an internal OR between multiple invocations of "Wait For item".

Psuedocode:

// UI
if(waitForItemListbox.selected() > 1)
{
    return WaitForAnyItemCommand{...};
}
else
{
    return WaitForItemCommand{...};
}

// Interpreter
bool processCommand(WaitForItemCommand&) { /* as usual */ }
bool processCommand(WaitForAnyItemCommand& command) 
{
    for(entity : command)
        if(processCommand(WaitForItemCommand{entity}) 
            return true;

    return false;
}


____________________________
http://vittorioromeo.info
02-06-2017 at 06:14 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
hyperme
Level: Smiter
Avatar
Rank Points: 449
Registered: 06-23-2006
IP: Logged
icon Re: Every kind of wait for should enable multi-selecting within the SAME command (+2)  
Because that is not how the script runner works.

Each script command gets up to five integers, and that's it. By the time the script is run, the UI is gone.

edit: obviously set var text edition gets text, but that's the only exception, and still only a single value

____________________________
[Insert witty comment here]
Qzvlkx?

[Last edited by hyperme at 02-06-2017 08:09 PM]
02-06-2017 at 08:04 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Xindaris
Level: Smiter
Avatar
Rank Points: 405
Registered: 06-13-2015
IP: Logged
icon Re: Every kind of wait for should enable multi-selecting within the SAME command (0)  
Huh?

I genuinely don't understand what you mean by that. All the UI has to do is let the player select a bunch of things, and then that list of things is sent as an array or whatever to a function that uses a for loop to go "If... else if... else if..." FOR the architect instead of requiring them to do it all manually every single time. I don't see how that's particularly difficult to program in as something that happens when it's "compiling" the script or whatever; inefficient, maybe, but not difficult. Maybe there's no way to myscript-inject for it but there's no good reason to need a dynamically changing list of things to wait for, or even if there is it's an awfully smaller edge case than "any time I want to check for more than one kind of thing, ever".

Unless you're actually, seriously telling me that the problem of arrays not existing is really something built in to DROD's source code and isn't just something that the scripting isn't built for, but even THAT can be worked around by encoding the "which ones are selected" as a single binary number, in the order of the objects, with a "1" for "is selected" and a "0" for "is not selected". It should be possible even with that workaround to account for custom characters by virtue of the fact that a given hold "knows" what all of its custom characters are and in which order they're being displayed; otherwise it wouldn't be possible to add them into the list of things to select in "wait for entity" at all.

EDIT: Okay, 5 integers? That ought to be more than enough for the binary workaround to do the job. If some hold has enough custom characters to fill 5 integers' worth of space then something has gone horribly wrong.

____________________________
109th Skywatcher

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


[Last edited by Xindaris at 02-06-2017 08:16 PM]
02-06-2017 at 08:07 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
hyperme
Level: Smiter
Avatar
Rank Points: 449
Registered: 06-23-2006
IP: Logged
icon Re: Every kind of wait for should enable multi-selecting within the SAME command (+2)  
"All the UI has to do..." - person who has not seen DRODscript editor UI code.

But actually it turns out i was wrong! oh no :blush

Having looked again, it should be easy enough to extend the command class to have list of UINTs as a member variable. And sure, the UI can probably be poked into obeying*. The main issue is that to ensure that old scripts work, multi-waits would need to be their own separate commands. Additionally, you wouldn't be able to use _MyScriptF with them. Otherwise things are fine. :thumbsup

Note that 'pass binary flags' wouldn't work on general consumer hardware, since 64-bit architecture is the popular thing, and DROD is currently a 32-bit program. And there are more than 64 things to wait for. :D

Edit: Also four of those five integers are used for stuff like 'where do i look' so only F is available for deciding what is looked for. Custom IDs also start at some largish number I don't remember off the top of my head. Which actually could be an issue for the Wait Multi for Entity Type command. :fun

(*Most poking will occur in the "oh no i have to draw this 10+ wait list" stage. other parts of UI can be more easily setup)

____________________________
[Insert witty comment here]
Qzvlkx?

[Last edited by hyperme at 02-06-2017 09:06 PM]
02-06-2017 at 09:03 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Xindaris
Level: Smiter
Avatar
Rank Points: 405
Registered: 06-13-2015
IP: Logged
icon Re: Every kind of wait for should enable multi-selecting within the SAME command (0)  
I'm actually really sorry, this whole thread came from a place of frustration and I thought about what I wrote in the last post after writing it and within five minutes it was clear some of the stuff I was saying was dumb.

BUT, it would still definitely be worthwhile in terms of quality-of-life improvements to have a set of special "wait for/while multiple item" and "wait for/while multiple entity" commands that allow multi-selecting if at all possible. Not being able to inject with myscriptF what entity/item it is shouldn't matter at all because of how many things are already covered by the existing lists. Even if there are a few exceptions it's a whole lot easier to do all the standard stuff in one command and handle any extras in a couple of separate ones than to have to go through ten million different else if's.

____________________________
109th Skywatcher

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


[Last edited by Xindaris at 02-07-2017 01:24 AM]
02-07-2017 at 01:23 AM
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 : Every kind of wait for should enable multi-selecting within the SAME command (because long if-else if-else if statements are TERRIBLE.)
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.