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 Studio Chat / [SOLVED] Data Type

Author
Message
TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 12th Sep 2021 08:38
Suppose [ name$="surojit"] [ score=150 ] here $name = string and score = integer
I want to know any function that show or return the datatype , suppose I pass name$ and it's return string
Thankyou

The author of this post has marked a post as an answer.

Go to answer

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Sep 2021 09:36 Edited at: 12th Sep 2021 09:39
If i understand you correctly;

The data type should look like this


The function might look like


Calling the function would look like
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 12th Sep 2021 13:24
There are no type checking functions in AppGameKit and as there are no multitype arguments allowed then I don't really see a use for any, your code should be aware of variable data types because agk is pretty strict unlike Lua for example where type(), isstring(), isnumber(), isboolean() etc are very much needed because the language is typeless.
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 12th Sep 2021 14:14
@PartTimeCoder yes you are right . actually I use 2 edit box where user put values in integer and that can be Zero too , so I could not understand , If some one do not put anything and I chk with val(geteditboxtext(roomNo$)) and if roomNo$="Room Number" and not roomNo$="24" then it's return zero(0) because val() with string return zero(0) . So I thought how to solve it .
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 12th Sep 2021 15:36 Edited at: 12th Sep 2021 15:40
Index your rooms from 1+ and use 0 as your error indicator, so if nothing entered or not a number val() returns zero and its an error else its a valid room number.

Edit: if you absolutely have to use a room index of zero, like no other way round it, then just offset the index from the player input, as far as the player is concerned rooms range from 1 to 25, minus the result of val() (if its above zero) and send to the code using o to 24 index range.
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 12th Sep 2021 18:15
No no it's my bad that I am using Room Number as example .
But the original is


here the FeeCoins and PrizeCoins are in string But if the admin forget to change the fee or Prize or both in number then it's return Zero when I use val()
That is the problems .
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Sep 2021 21:13
The fromJSON() function will only update members of a type that appear in the JSON string
TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 13th Sep 2021 02:24
This post has been marked by the post author as the answer.
Thankyou to all , I solve the problems in core php on server . I am not change anything in application but when Admin start creating a game then I check the data type in php with gettype() function . And if I get datatype string then I return a value with error code and if I get Integer then I create the Room .
Zappo
Valued Member
19
Years of Service
User Offline
Joined: 27th Oct 2004
Location: In the post
Posted: 13th Sep 2021 11:48
I know you have sorted this another way, but if I understand correctly and you want to check that the input value is an integer from within AppGameKit you could use something like:

This checks if the input string (once converted to an integer) is the same as the string that was input. It should return true if the input is a valid integer (including zero) and false if it was anything else.
TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 13th Sep 2021 18:04 Edited at: 13th Sep 2021 18:05
@Zappo many many Thankyou .
I just think that if string not converted then it's return Zero and ( Zero also return Zero after converted ). so I was confused
Thank-you once again .

This is from my side for you . If you already know then ignore else it's help full to you ( Amazon Web Server free 1year hosting, you can use for app game kit game server)
https://youtu.be/M77nTz1anEk

Login to post a reply

Server time is: 2024-03-29 15:26:56
Your offset time is: 2024-03-29 15:26:56