Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tier 1 -- a type can only store static content. Are there any workarounds?

Author
Message
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 16th May 2019 09:50
What I mean is, I can't set a type entry to have dynamic content like this:

baddie[100].attack = random(20,60)

It stores the random value, but then it's frozen at whatever value came up when it was defined.

So, any hack, solutions, workarounds, anything?
xtremi
5
Years of Service
User Offline
Joined: 26th Aug 2018
Location:
Posted: 16th May 2019 10:25
What do you mean?
If you call:
baddie[100].attack = random(20,60)

multiple times, the value will change, won't it?
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 16th May 2019 11:16
Yes, but I don't want to call it multiple times. I want it to be a single definition so that I can later refer to baddie[100].attack and get a random value between 20 and 60.
xtremi
5
Years of Service
User Offline
Joined: 26th Aug 2018
Location:
Posted: 16th May 2019 12:49 Edited at: 16th May 2019 12:49
Well, that's not possible, but you could wrap that into a function?

Depends on how you want to use this attack, but what about something like this?

basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 16th May 2019 14:30
yeah, I can get a long way with this. Thanks! Passing types into functions is something I have wanted to get into for a while!
xtremi
5
Years of Service
User Offline
Joined: 26th Aug 2018
Location:
Posted: 16th May 2019 15:01
Yes, it's very useful. Just make sure you use "ref as" in the function, so that you don't copy the object of the type, but use the actual one you are passing.
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th May 2019 04:16
#constant hits = random(20, 60)

Every time you use "hits" it'll be a different number. Unfortunately, I don't know how to assign the function to anything other than a constant.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Xaby
FPSC Reloaded TGC Backer
16
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 17th May 2019 10:06
@Phaelax

that is a funny thing. It is like a shortcut for a function
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 17th May 2019 11:07
Wow! Serious question: Is this a bug or a feature?
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 17th May 2019 11:44
#constant this that

The preprocessor just looks through your code and replaces this with that

So you could use:

#constant DoSomeStuff SetVirtualResolution(1024,768)
#constant DoThis Print("hello everyone")

then in your code just write:
DoSomeStuff
DoThis

and it will set the resolution and print some text....simples

Not a bug at all really, just a feature that is in the language
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 18th May 2019 01:31 Edited at: 18th May 2019 03:08
you can do all sorts of fun stuff with constants:

http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 18th May 2019 02:37
Awesome Ortu. That is helpful on so many levels!
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st May 2019 04:47
While neat, I think it makes code a little harder to read.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2024-03-29 15:07:33
Your offset time is: 2024-03-29 15:07:33