Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Skemech

Beyond just a bool

Question

In the past, I don't think I was wording my questions carefully. This is the best way of asking. Basically, what can I use that acts like a bool, but has more than two options? Cause in my limited experience a bool allows only 2 options. but what if I need a script that has like 12 "if" statements all asking...

if ([Insert bool equivelant here] == 1)
	{
		Do_Something (1);
	}

if ([Insert bool equivelant here] == 2)
	{
		Do_Something (2);
	}

if ([Insert bool equivelant here] == 3)
	{
		Do_Something (3);
	}


so on and so on...

 

Share this post


Link to post

25 answers to this question

Recommended Posts

  • 3

int

 

You want to use an int, as you have been told over and over again.

 

Also, you're still not creating your scripts correctly. Your script as written will set option 1 to 1 and then immediately enter the "if (option 1 == 1) code because you're still not using "else if."

 

int option1 = 0;
int option2 = 0;

script 1 (void)
{
	if (option1 == 0)
	{
		Do_Something (1);
		//ALSO
		option1 = 1;
	}

	else if (option1 == 1)
	{
		if (option2 == 0)
		{
			//blah blah blah so on, and so on
		}
	}
}

 

 

If you have a BUNCH of these, you want to use switch/case. JUST LIKE I LINKED YOU TO IN A PREVIOUS THREAD.

 

int option1 = 0;
int option2 = 0;

script 1 (void)
{
	switch(option1)
	{
      case 0:
      {
          Do_Something (1);
          //ALSO
          option1 = 1;
      }

      case 1:
      {
          Do_Something (2);
          //ALSO
          option1 = 2;
      }

      case 2:
      {
          Do_Something (3);
          //ALSO
          option1 = 3;
      }

      case 3:
      {
          Do_Something (4);
          //ALSO
          option1 = 4;
      }

      case 4:
      {
          Do_Something (5);
          //ALSO
      }

	}
}

 

 

This is the last time I'm offering "advice" as it seems to only be going in one ear and immediately straight out the other.

Edited by Stabbey

Share this post


Link to post
  • 1

OP I really suggest you learn computer science concepts before attempting any programming. This is not meant as a criticism of you, but trying to even write basic code without knowledge of these things will be very difficult. You don't even necessarily need to learn another programming language, just do some reading up on basic programming concepts. Your posts have demonstrated a lack of understanding of concepts such as program branching and data types which are some of the most basic concepts you need to know.

Share this post


Link to post
  • 1

As others have pointed out, you clearly don't know even the basics of programming yet. In fact, your lack of awareness integers even existing kind of reminds me of how I was only able to truly learn at least some coding after I was literally walking down the street one day, and came to the eureka moment of realizing that a variable is a value that stores a number. Before that no number of tutorials, examples, and explanations by others were able to help me at all. Your situation sounds pretty similar to mine.

 

So to join the dogpile, I'd also recommend that you try to listen to the help everyone else is trying to give you here. And don't bother using LLMs like ChatGPT (GPT-3.5) to either give you instructions on writing ACS, or straight up writing actual ACS. The amount of information on the internet on these obscure Doom scripting languages is very little for any LLM to have any proper info on them. You could perhaps use ChatGPT to get the basics from a language people actually use like C or something, but first of all, the free ChatGPT is 3.5 and it's pretty shit, while the actually functional GPT-4 is paywalled, and every other LLM is currently pretty dogshit in comparison*, second, you'd still probably just be better off just reading a premade guide, there's literally decades of them for normal programming languages, and for ACS you can find an entire playlist guide here.

 

 

*Frankly I'm not interested in any of these AI models until they can actually run locally as open source software, not as proprietary black boxes on some data center somewhere. Until then they are as good as useless, especially with how much these companies lobotomize them.

Share this post


Link to post
  • 1
26 minutes ago, Skemech said:

Bro where did this come from? I've never used chatgpt to aid in acs script writing lmao 😭

Part of it is coming from the fact this is the usual reason for people to ask questions similar to yours, but most of it is coming from the fact that you said "ya pretty much" when I straight-up asked you whether this is the case.

Share this post


Link to post
  • 0
18 minutes ago, LoatharMDPhD said:

// Does Not Compute...

damnit, there's really nothing that goes beyond 2 factors?

Share this post


Link to post
  • 0

WAIT I THINK I JUST THOUGHT OF A VERY ROUND ABOUT WAY OF DOING IT!!!!!!!!!!!

 

=====================================================================

bool option1 = 0;
bool option2 = 0;

script 1 (void)
{
	if (option1 == 0)
	{
		Do_Something (1);
		//ALSO
		option1 = 1;
	}

	if (option1 == 1)
	{
		if (option2 == 0)
		{
			//blah blah blah so on, and so on
		}
	}
}

==========================

 

Would this not technically work? I haven't tested it yet, I'm about to though... finger fucking crossed

Share this post


Link to post
  • 0

// You're thinking too hard, and or trying to force something using a particular method while easier ways exist. at least that's what i'm inferring.

// what if, you just assign an integer instead of a superposition dichotomy?

Share this post


Link to post
  • 0

I really have to wonder exactly where the confusion is coming from to provoke these sorts of questions. @Skemech, are you trying to get code examples/coding help from ChatGPT or some similar LLM-based "AI assistant" before asking here? Because LLMs are just autocomplete on steroids and no more legitimate than any other results obtained through steroid abuse. Their output on any technical or knowledge-based topic is often completely bogus and will seriously impede any attempt to actually learn about the subject.

Share this post


Link to post
  • 0
3 minutes ago, Foxpup said:

I really have to wonder exactly where the confusion is coming from to provoke these sorts of questions. @Skemech, are you trying to get code examples/coding help from ChatGPT or some similar LLM-based "AI assistant" before asking here?

ya pretty much. Like I'm trying to make fnaf in doom. "if" it's night 1, only bonnie should roam the pizzeria, and he should move slower. So the "if (random (1, 15) = 15)" or whatever needs to be bigger. If the "random" is larger than it'll happen less often... Oh, but if it's night 2, his ai needs to "thing_activate" (The thing_activate activates actor movers). So on and so fourth... like this project, though simple sounding in my head, once I actually start talking about it, jesus, if this is possible to make, it will take a while to fully accomplish...

Share this post


Link to post
  • 0
10 minutes ago, LoatharMDPhD said:

// You're thinking too hard, and or trying to force something using a particular method while easier ways exist. at least that's what i'm inferring.

// what if, you just assign an integer instead of a superposition dichotomy?

because "int" didn't seem to work (In this specific circumstance), it really did much the same. also the "ROUND ABOUT WAY" also didn't work...

Share this post


Link to post
  • 0
23 minutes ago, Skemech said:

ya pretty much.

Please, please, stop before you hurt yourself. Please forget that these "AI assistants" exist, or better yet, pretend they're a conspiracy invented by the technocrati to prevent outsiders such as yourself from ever learning to code, because that's what they may as well be at this point. Your code doesn't work and never will because it's not really code, it's just a collection of meaningless symbols thrown together in a way that vaguely resembles a computer program by a glorified autocomplete system that doesn't even have any conception of meaning and isn't designed to. You really need to learn the fundamentals of computer programming from an actually educational source, not an AI.

 

And to think some people say AI is going to take our jobs.

Share this post


Link to post
  • 0

Wait, no I'm not taking chat gpt's outputs, if that's what you thought. I'm saying what I'm (trying to) write in acs, is (very basic af) ai. A metric shit ton of "If" statements boil down to one single action, over and over

Share this post


Link to post
  • 0
6 minutes ago, Skemech said:

Wait, no I'm not taking chat gpt's outputs, if that's what you thought. I'm saying what I'm (trying to) write in acs, is (very basic af) ai. A metric shit ton of "If" statements boil down to one single action, over and over

Again, you really need to learn the concepts of computer science before writing any more code. I assume the extent of your programming knowledge comes from reading the ZDoom Wiki or whatever, which assumes you already have a basic understanding of programming. The code you have posted so far demonstrates that you're kinda just writing code without actually understanding what it's supposed to do; most of it is nonsense. I'm not saying this to try and bring you down; if anything it's the opposite because seeing people learn programming for the first time is really cool to me. But the way you're approaching it right now will not be very successful for you in the future. I won't point out what is wrong with your code in particular because I think without knowing the basic fundamentals it will only lead to more confusion for you.

Share this post


Link to post
  • 0
13 minutes ago, Foxpup said:

Please, please, stop before you hurt yourself. Please forget that these "AI assistants" exist, or better yet, pretend they're a conspiracy invented by the technocrati to prevent outsiders such as yourself from ever learning to code, because that's what they may as well be at this point. Your code doesn't work and never will because it's not really code, it's just a collection of meaningless symbols thrown together in a way that vaguely resembles a computer program by a glorified autocomplete system that doesn't even have any conception of meaning and isn't designed to. You really need to learn the fundamentals of computer programming from an actually educational source, not an AI.

 

And to think some people say AI is going to take our jobs.

yeah man im a scrub at code, took VB6 18 years ago... i got things to learn myself..

mcode.jpg

Share this post


Link to post
  • 0
7 minutes ago, Individualised said:

Again, you really need to learn the concepts of computer science before writing any more code. I assume the extent of your programming knowledge comes from reading the ZDoom Wiki or whatever, 

 

Mostly from chubzdoomer. some is from the zdoom wiki, but god most of it doesn't make any sense on zdoom. I'll try and find some yt vids on coding.

Share this post


Link to post
  • 0

It sounds like you're looking for a 2D array, which is discussed in this tutuorial , by @Chubzdoomer

 

The first dimension of your array will be what day it is for example, the 2nd dimension is what to do on each of those days.

Then you can create events that change which (or randomly which) apply by changing the entries in the array.

Share this post


Link to post
  • 0
4 hours ago, Skemech said:

damnit, there's really nothing that goes beyond 2 factors?

The answer provided above displays a method using more than 2 factors (1 through 5 to be exact).

Lines in ACS script beginning with "//" do not compute into the actual script, like notes about what the script does or entries to make them easier to search if you have a large amount of numbered scripts / scripts with similar names.

 

Using an int instead of bool allows you to use a numbered series instead of an ON/OFF.

BOOL is literally OFF (0), or ON (1).

 

Int can be any non-decimal number.

 

Sorry if I'm misunderstanding the conversation and best of luck on your project!

Share this post


Link to post
  • 0

@Skemech I agree with the others and strongly recommend brushing up on general programming before tackling this problem. There are online code tutorials that ask you to code a simple program, then you run it in the browser and it checks your inputs and outputs for correctness. This will reinforce the foundational programming idioms such as loops, conditionals, and data types you need to program in ACS.

 

You need to learn the basics then build on them. Crawl, walk, then run. Socks go on before shoes. I mean this in the most respectful way possible and I hope you can master the basics before returning to this project, at which time you will be better equipped to make the Doom map you want and have it not be a frustrating experience.

Share this post


Link to post
  • 0

OK I'll pitch in here...

 

I think you are talking about the concept of an ENUM - a finite, fixed list of values.

Spoiler

obviously there is an infinite number of ints - well, limited by the computer capabilities, but still plenty more than you would need...

 

Now, ACS doesn't support ENUMs natively, but you can simulate it with an array.

 

You can still determine your action by using an int (the array index), but you can limit to your fixed list:

str actions[5]={
    "ACTION_ONE",
    "ACTION_TWO",
    "ACTION_THREE",
    "ACTION_FOUR",
    "ACTION_FIVE"
};

script 100 ENTER{
    // note: zero-indexed
    log(s:actions[0]);
    log(s:actions[1]);
    log(s:actions[2]);
    log(s:actions[3]);
    log(s:actions[4]);
    
    // All these are not present in the array, 
    // but handily, will default to index zero, which means
    // that you can have the first action as a default/fallback
    log(s:actions[5]);
    log(s:actions[88]);
    log(s:actions["v"]);
}

 

If you want to trigger the eventual action with an int, you can return an int from your ENUM analogue (which defaults to ZERO in this case if unknown index passed, as above example):

int actions[5]={
	1,
	2,
	3,
	4,
	5
};

script 100 ENTER{
	// note: zero-indexed
	log(i:actions[0]);
	log(i:actions[1]);
	log(i:actions[2]);
	log(i:actions[3]);
	log(i:actions[4]);
	
	// All these are not present
	log(i:actions[5]);  // --> returns ZERO in the not found cases, but the principle is the same
	log(i:actions[88]);
	log(i:actions["v"]);
}

So this approach does indeed - I think - give what you want as a "bool plus" of a fixed list of more than binary values. They are still ultimately ints of course, but doing something like this means that you can build in the range of values that you can use.

 

Suggest you do a LOT of reading and tinker about with ACS before plunging into something complex.

 

But as others have said, you will get the best out of ACS if you learn something about programming concepts

Edited by smeghammer : typo

Share this post


Link to post
  • 0

Also you can use a switch/case construct rather than a bunch of if clauses. This has the added benefit that you can build in your possible options to the cases. Note also the default case which will handle any unknown input option.

 

Regarding your code example at the top, you should build the input variable checking into your do_something() script/function. Checking beforehand and then passing a different argument is actually redundant because you will still need to check the value of the argument again in the function in order to route to the correct eventual action.

 

 I'll do a real example later

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×