I was about to waste years, then I read this...

Discussions about Coding and Scripting
Post Reply
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

I was about to waste years, then I read this...

Post by PrinceOfFunky »

After an year trying to understand why the duck I get a bunch of errors when trying to access to, an already declared, dynamic array, I read the following sentence here: http://www.oldunreal.com/wiki/index.php ... Realscript

Code: Select all

· Array<type>

There is some good news and some bad news here.  The good news is variable length arrays are supported using the Array specifier.

e.g.

            var Array<Wookie> AllWookies;

var Array<int> BunchOfInts;

 

The bad news is that they aren’t fully implemented in UnrealScript (as of UT420).   This means you can declare them, but you can’t access them.  This is one of those gems of entirely useless information referred to in the introduction. 
The last part left me like a mix of these emoticons: :shock: :x :mad2: :nonono: :wth: :???: :ironic: :tu: :lol: :agree1: (The emoticons that seem agreeing with what it says, it's cause I went a bit crazy when I read it lol)
"Your stuff is known to be buggy and unfinished/not properly tested"
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: I was about to waste years, then I read this...

Post by Higor »

What array are you trying to read?
I may have an answer...
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: I was about to waste years, then I read this...

Post by PrinceOfFunky »

Higor wrote:What array are you trying to read?
I may have an answer...
A dynamic one, an example of operation I was performing on a dynamic array is this one:
https://www.ut99.org/viewtopic.php?f=15&t=6426
"Your stuff is known to be buggy and unfinished/not properly tested"
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: I was about to waste years, then I read this...

Post by Higor »

I think we're not understanding each other well...

- Is the array a part of your code?
- Do you really NEED a dynamic array?
- Is said code running on: server? server-only? client? uwindow(global)? map?
- Are you willing to install a native engine addon?

Also...
- Have you every used a static array with a 'top' index?
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: I was about to waste years, then I read this...

Post by JackGriffin »

Higor, Funky and I had an extended back-and-forth via PM over this and he never really would do anything but ask the same question over and over. I just gave up. He's a nice guy but really, REALLY focused on this singular question.
So long, and thanks for all the fish
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: I was about to waste years, then I read this...

Post by PrinceOfFunky »

JackGriffin wrote:Higor, Funky and I had an extended back-and-forth via PM over this and he never really would do anything but ask the same question over and over. I just gave up. He's a nice guy but really, REALLY focused on this singular question.
Thank you :) actually I do need it but I had to solve it using a static one even if will not help on certain situations, and ill write them answering to Higor.
Higor wrote:I think we're not understanding each other well...

- Is the array a part of your code?
- Do you really NEED a dynamic array?
- Is said code running on: server? server-only? client? uwindow(global)? map?
- Are you willing to install a native engine addon?

Also...
- Have you every used a static array with a 'top' index?
- Yes the array is part of my code.
- If not, I wouldn't of ask it .o.
- Server only (I know dynamic arrays are not replicated)
- No :/

- Yes I did and I'm doing it now cause I'm not using a dynamic array sadly.

I need a dynamic array cause I'm creating a race code where players that gets inside the match, when the race is already started, can still race with a race policy obviously, but the race code implements an array of how much participants are actually into the race, I know I could of use a static array and set it to a big number like 32 but obviously a dynamic array would be much better without any wasting of space.
"Your stuff is known to be buggy and unfinished/not properly tested"
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: I was about to waste years, then I read this...

Post by Higor »

When the term "waste of space" was brought up, i thought of 5000 elements.
Since a native addon is out of question, then you need to go with either:
- Reasonably big static array.
- Chained list.
- Static hashing.

UT devs used chained lists in pawns and navigation points, big static array in GameReplicationInfo when implementing these into UnrealScript.
Static hashing hasn't been done in any mod I know of... except UTES scoreboards (and I wrote that code lmao).

So, what are you making an array of?
Are there simple values/references, or multi-element structs?
In case of structs... are there specific operations atomically performed on said structs?

Knowing how it'll work and what will be done on these will greatly influence the design of said code, and a good design will get rid of a big amount of headaches.
Hey, 9 out of 10 modders get this part wrong, so if you have doubts, share!
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: I was about to waste years, then I read this...

Post by PrinceOfFunky »

Higor wrote:When the term "waste of space" was brought up, i thought of 5000 elements.
Since a native addon is out of question, then you need to go with either:
- Reasonably big static array.
- Chained list.
- Static hashing.

UT devs used chained lists in pawns and navigation points, big static array in GameReplicationInfo when implementing these into UnrealScript.
Static hashing hasn't been done in any mod I know of... except UTES scoreboards (and I wrote that code lmao).

So, what are you making an array of?
Are there simple values/references, or multi-element structs?
In case of structs... are there specific operations atomically performed on said structs?

Knowing how it'll work and what will be done on these will greatly influence the design of said code, and a good design will get rid of a big amount of headaches.
Hey, 9 out of 10 modders get this part wrong, so if you have doubts, share!
Yeah that's what I was saying... I can't use dynamic arrays(with a non-modified Unreal Engine 2.0 obviously).
And that's why I said I'm gonna use a big static array, plus I would like to use structs from another class to another class but I've this problem about "DependsOn()" too: viewtopic.php?f=15&t=6432
"Your stuff is known to be buggy and unfinished/not properly tested"
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: I was about to waste years, then I read this...

Post by JackGriffin »

Please listen to Higor. He's one of about five people around who know more than just about everyone else.

You are creating too many roadblocks for yourself by making things way harder than they need to be. As Higor said the things you want to do can be accomplished way easier by not insisting on using such sensitive and obtuse function calls. If all the modders before you decided against using something then it's a good indicator that it's either problematic or broken.

BTW, DependsOn() is never going to compile for you. http://wiki.beyondunreal.com/Legacy:Class_Syntax :
(Leave the wiki alone Gus)
dependsOn(ClassName)

Only works in Unreal Engine 2.0 and later...
So long, and thanks for all the fish
User avatar
sektor2111
Godlike
Posts: 6411
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: I was about to waste years, then I read this...

Post by sektor2111 »

UScript sometimes has more than a solution to solve certain thing. If you are locked on something hard which might have flaws rather than using other way won't help you ever. WHY you did not simply try to do what you want in a different way - alternate solution ?
Title is funny - wasting years :loool: ? People became more skiled and wise each year passing. Losing years trying to draw on water is proving a requirement of mental sanity check, get over yourself by staying locked on a UNI forumula and see alternatives, options are probably more than you can think about.

Edit: I recall that my first failure related to whatever array deal was solved using an Iterator - slower but functional flawless. I'm not bother too much by seing why if something doesn't work - I add logs. If logs doesn't speak or are speaking bad things, I'm switching method.
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: I was about to waste years, then I read this...

Post by Higor »

If you take a look at this you'll realize there's much more methods to use... it's a matter of knowing how these 'structs' are going to be used.
You could totally turn these structs into actors and have them chained listed (or hashed if speed is something you need).

viewtopic.php?f=15&t=6189

SiegeIV uses a crapton of these struct-to-actors to dynamize everything.
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: I was about to waste years, then I read this...

Post by PrinceOfFunky »

JackGriffin wrote:Please listen to Higor. He's one of about five people around who know more than just about everyone else.

You are creating too many roadblocks for yourself by making things way harder than they need to be. As Higor said the things you want to do can be accomplished way easier by not insisting on using such sensitive and obtuse function calls. If all the modders before you decided against using something then it's a good indicator that it's either problematic or broken.

BTW, DependsOn() is never going to compile for you. http://wiki.beyondunreal.com/Legacy:Class_Syntax :
(Leave the wiki alone Gus)
dependsOn(ClassName)

Only works in Unreal Engine 2.0 and later...
Man I swear......... I though Unreal Tournament was made with Unreal Engine 2..... OMG so all the times I saw Unreal Engine 2 and I tried using that function or whatever, that's why they never worked o.o... f.
sektor2111 wrote:UScript sometimes has more than a solution to solve certain thing. If you are locked on something hard which might have flaws rather than using other way won't help you ever. WHY you did not simply try to do what you want in a different way - alternate solution ?
Title is funny - wasting years :loool: ? People became more skiled and wise each year passing. Losing years trying to draw on water is proving a requirement of mental sanity check, get over yourself by staying locked on a UNI forumula and see alternatives, options are probably more than you can think about.

Edit: I recall that my first failure related to whatever array deal was solved using an Iterator - slower but functional flawless. I'm not bother too much by seing why if something doesn't work - I add logs. If logs doesn't speak or are speaking bad things, I'm switching method.
Well I just wanted know everything about arrays to implement the best one, and when I want do something I try my best :sad2:
anyway if you meant "University" with UNI, I passed the 2 exams today :D even if they were at the same time... it's a long and unbelievable story to know how I went to both the exams XD, anyway, actually, I've the second part of one of these exams to pass and it is in 2 days .o.

Oh and, it's not only with UnrealScript, you can find more than a solution with every language programming, after all, that's what we are... Problem solvers :D
Higor wrote:If you take a look at this you'll realize there's much more methods to use... it's a matter of knowing how these 'structs' are going to be used.
You could totally turn these structs into actors and have them chained listed (or hashed if speed is something you need).

viewtopic.php?f=15&t=6189

SiegeIV uses a crapton of these struct-to-actors to dynamize everything.
Well I'm new on Unreal Script actually, ty anyway I appreciated it :3
"Your stuff is known to be buggy and unfinished/not properly tested"
Post Reply