Welcome, Guest! Login | Register
Some script question
Info
Report
17 Posts

Hello guys. I finally have some free times to mess with this engine again.
Recently, I'm playing with angelscript and I'm struggling to get the value if the object was enabled or disabled, because I'm trying to make an IF statement with a condition where the object is enabled or disabled.

In Visual Studio, we simply type if(Object.Enabled == true), but I'm unable to figure this out in angelscript.
Help will be appreciated! Sorry for my English.
Created on: 6 days ago
Info
Report
45 Posts

Quote from: kompaktive


In Visual Studio, we simply type if(Object.Enabled == true), but I'm unable to figure this out in angelscript.

You mean any modern OOP programming language. And you can't kinda do that. Use a separate boolean variable.
Created on: 6 days ago
Info
Report
17 Posts

Bummer.
Another question:
1. How to stop a script. I want to run the script only 1 time, while the engine runs the script in a loop about 75 times/second.
I was trying to make a random AI behavior using iFloatRand() but turns out that the script keep randomizing the number in 75 times/sec. I had tried using return; but no luck.
Created on: 6 days ago
Info
Report
45 Posts

There's a function named iScriptStop() ,  not sure if i wrote it correctly.
Created on: 5 days ago
Edited on: 5 days ago
Info
Report
17 Posts

Quote from: Athanatos

There's a function named iScriptStop() ,  not sure if i wrote it correctly.

It did stop the script itself. Thank you very much!
Created on: 5 days ago
Info
Report
237 Posts

to your "enabled" question..
3drad has a few options per object, so it depends on what specifically you need to know..

An object can be:
hidden or shown
active or disabled
set to display or not at startup ( depends on the object )
plus there are a number of other settings that can be set or unset or adjusted.. again, it depends on the
object.

Some of these may not be directly tested for their current "state" but most of these states can be changed run time from script.
Created on: 4 days ago
Info
Report
17 Posts

Quote from: TinSoldier

to your "enabled" question..
3drad has a few options per object, so it depends on what specifically you need to know..

An object can be:
hidden or shown
active or disabled
set to display or not at startup ( depends on the object )
plus there are a number of other settings that can be set or unset or adjusted.. again, it depends on the
object.

Some of these may not be directly tested for their current "state" but most of these states can be changed run time from script.


What I was trying to do is using the object state as the condition. IF the object is ENABLED, then do this. IF the object is disabled, then do that. It's somewhat similar to boolean, but then how do you transfer a boolean variable inside the script into another script?
Created on: 3 days ago
Info
Report
237 Posts

The best way to do that is instead use a global variable and set it as needed for the state and then check the global variable instead..  this wont always work for all objects.. test test and test again.

When you have an issue, it sometimes would be better to show your script piece and ask for help getting it to do something or work a certain way..

Just asking a question often doesn't really describe the problem well enough.

Also DON'T post a HUGE piece of script an expect somebody to go through all of it just to fix some small part of it ...
Created on: 3 days ago
Info
Report
17 Posts

Thanks for the heads-up. Currently, I can offer only a question without any physical script because I haven't done that. I was wondering if it was actually possible to take the object status (enabled, disabled, started, stopped) and using it as a boolean.

I understand to use a global variable, but what I don't understand is how to change that variable when something is enabled?
And global variable can't be used to (or assigned from) another script, right?
Created on: 2 days ago
Info
Report
237 Posts

Global variables means they can be used through out your script. local variables are defined and used in side your main{} or function script pieces only.

That said.

There are 2 ways to pass varible data between scripts using either VAL1 to VAL_9, or you can save varible values inside the net array variables even if your project isn't networked, those variables still work and can be accessed by all scripts acting as a global project variables.

The script help files and the angle code website gives example usages as well.

EDIT: also if you connect the same object too 2 or more different scripts, it's values can also be read or changed by any one of those connected scripts.. so that can be another way to pass data between scripts.
Created on: 2 days ago
Edited on: 2 days ago
Sponsored