Player Naming System (updated)

This forum is meant for people to share their knowledge by writing their own tutorials for Adventure Maker.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Postby laserman » Thu Apr 17, 2008 3:31 pm

Ok. I've done everything the way you pointed out. In detail, here's what I've done....

The frame called blox has the code:
i=Action.GetMergedTextIndex
Text(i).Caption=Name
under "frame" properties.

The hotspot on that same frame has the following code:
Name=InputBox("Type your name", "Name")

I have set the "Runtime frames merging" to:
"blox Solid01"
Solid01 -no frame"

In the Solid01 frame properties I have the following code:
text(1).caption=Name
I have also placed a textbox with the text: "Name" in it, placed in the position I want.

Under VBS Variables I have "Name" set as a variant.

When I run the project, I see a "0" where the hotspot is (which is not a problem). I click it and it asks for the "name", so I enter it. It still shows the "0" after I click on Ok.

I'm at a loss as to what I am doing wrong since I also checked spelling and punctuation. I understand that I am being a pain and I apologize, but I would really like to solve this. If it works for you, then I can only assume one other thing, and that being that what you have given me is not compatible with my version: 3.4.0.

Would a book on VB perhaps help me understand the VB script better?
I certainly do not want to wear out my welcome here as this is the friendliest forum I have ever belonged to.
laserman
Member
 
Posts: 16
Joined: Fri Mar 21, 2008 6:06 pm

Postby Chromegloss55 » Sat Apr 19, 2008 4:33 pm

I don't exactly understand but I think I could help. Send a copy of the AM Project Folder to chromegloss@hotmail.com and I'll see if I can fix the problem.

Chromegloss
_________________
wwi recession
Last edited by Chromegloss55 on Tue Feb 24, 2009 3:14 pm, edited 1 time in total.
Chromegloss55
Forum Master
 
Posts: 630
Joined: Sat Nov 03, 2007 2:49 pm
Location: God Knows!

Postby Lyberodoggy » Sun Apr 20, 2008 7:28 am

Yes, I know about that problem. The Engine gets your command but waits untill the form is reloaded to take action.

To solve this there are two ways:
Either typing this command in the hotspot that asks for the player's name:
Code: Select all
Action.GotoFrame "blox"

*Note that the refresh commands of AM don't work usually for this situation
or add another frame that will ask for the player's name before entering the "blox" frame. This one would solve the "0" text problem too...
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby laserman » Mon Apr 21, 2008 4:45 pm

Thank you so very much. That solved the problem.
:D
laserman
Member
 
Posts: 16
Joined: Fri Mar 21, 2008 6:06 pm

Postby Lyberodoggy » Mon Apr 21, 2008 6:03 pm

You are welcome..
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Chromegloss55 » Tue Apr 22, 2008 7:27 pm

Guess you didn't need me then... :D

(Dang... I like being needed. :cry: )
_________________
how long did the great depression last
Last edited by Chromegloss55 on Tue Feb 24, 2009 3:14 pm, edited 1 time in total.
Chromegloss55
Forum Master
 
Posts: 630
Joined: Sat Nov 03, 2007 2:49 pm
Location: God Knows!

Postby Lyberodoggy » Wed Apr 23, 2008 7:32 am

Hehe I understand you fully Chromegloss :P
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Ron_Emad2 » Wed Apr 23, 2008 8:50 am

this is very good
i want use it in my project
your IQ very good Lyberodoggy
Hello
I from iran
i cant speak english correctly
please forgive me
User avatar
Ron_Emad2
Active Member
 
Posts: 85
Joined: Fri Oct 13, 2006 12:08 pm
Location: Iran-Kashan

Postby Lyberodoggy » Wed Apr 23, 2008 10:37 am

Thanks!
Of course you can use the code... That's why it is given open-source.
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Ron_Emad2 » Wed Apr 23, 2008 12:06 pm

i dont understand your mean dear Lyberodoggy
That's why it is given open-source. ???
you speak with me ? :shock:
Hello
I from iran
i cant speak english correctly
please forgive me
User avatar
Ron_Emad2
Active Member
 
Posts: 85
Joined: Fri Oct 13, 2006 12:08 pm
Location: Iran-Kashan

Postby Lyberodoggy » Wed Apr 23, 2008 12:10 pm

Open-source means that everyone can see the code and use it. It's not an offence.
What I mean is that the code is free to use for everyone.
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Ron_Emad2 » Wed Apr 23, 2008 3:04 pm

Oh Lyberodoggy
i Know your mean :wink:
i love share this becuse i love every one can build
adventure game .it is best for me and ...
with thanks about code
emad :oops:
Hello
I from iran
i cant speak english correctly
please forgive me
User avatar
Ron_Emad2
Active Member
 
Posts: 85
Joined: Fri Oct 13, 2006 12:08 pm
Location: Iran-Kashan

Postby Ikonz101 » Sat Oct 10, 2009 11:51 am

I got the scoreboard tutorial to work out perfectly. One problem is that when you have a highscore of say 800 then you have a highscore of say 100 after that it doesn't place the highscore of 100 under the highscore of 800. It just places the scores in order without reading the number value. Is there a code to fix this?

Thanks
Ikonz101

Example:

This is how it shows the scores:

Ikonz101: 100
Ikonz101: 800
Ikonz101: 1000

Should Show:

Ikonz101: 1000
Ikonz101: 800
Ikonz101: 100

Edit: I also found out that you can just edit the .INI file to put whatever score you want. Is there a way to protect this or fix this problem?
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby reneuend » Sat Oct 10, 2009 1:43 pm

How are the scores being displayed? is it using text(index).caption for each score? If so, does it automatically line them up vertically for you, or are you coding this?

I haven't seen the code, but since it is using an INI file, I think I can safely guess that it is using a loop to display the scores in text() objects.

If so, then the counter in the loop is probably the index for the text() objects.

And if that is true, then all you need to do is start from the highest index and count down to the last one. This will require knowing either how many scores you have to begin with, or having some way to count them first before you start the loop.

Sorry, I need more info. before I can answer this one. Was this a plugin? if so, what is it called?

As for hiding the scores in the INI file, here is a simple suggestion:

1. rename the INI file to something totally different, like "registry_keys.ini"
2. use an encryption/decryption routine to hide what the values really are.
(I can send you a routine that will do this for you)
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2731
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Ikonz101 » Sat Oct 10, 2009 6:53 pm

The code or tutorial I am using is in this thread. Here is the url of the tutorial:

http://www.adventuremaker.com/phpBB2/viewtopic.php?t=3580&start=0 It is called scoreboards.rar with the description of (Fixed once again! Added Clear scoreboard & Multi-line scoreboard!!!) The 4th one down. I am using that exact code. Yes the scores are being displayed through text(index).caption. Yes it does line them up automatically. Yes it is also using a loop. No it isn't a plugin just a tutorial that shows how to display and save your highscores. Would you please send me the routine that would be greatly appreciated.

Thank You
Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby Lyberodoggy » Sat Oct 10, 2009 11:45 pm

I can't understand my code, this could take a while...

EDIT: here you go:
Code: Select all
entries=INIKey
Text(1).Caption=Scoreboard
Execute "dim myarray("+cstr(entries)+")"
Execute "dim myarray2("+cstr(entries)+")"
Do
scorearray=split(Action.ReadINI("ScoreBoard.ini",1,entries),":")
Myarray(entries)=converttonumber(scorearray(1))
entries=entries-1
Loop While entries>0
entries=INIKey
Do
highest=0
for counter=0 to Inikey
if myarray(highest)<myarray(counter) then
highest=counter
end if
myarray2(entries)=myarray(highest)
myarray(highest)=-1
next
entries=entries-1
Loop while entries>0


myarray2 now contains the scores descending

This should work. However I 've not tested it. It might contain some minor syntax problems with the Execute commands, which I can easily fix if they appear and it could generate a big loop, which could cause the engine to call the infinite loop message.
Last edited by Lyberodoggy on Mon Oct 12, 2009 10:03 pm, edited 2 times in total.
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby reneuend » Sun Oct 11, 2009 1:16 am

Would you please send me the routine that would be greatly appreciated.

Thank You
Ikonz101


I can't find it. :(

I'll try to recreate it.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2731
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Ikonz101 » Sun Oct 11, 2009 1:43 am

I get a "loop without do" error. Don't know what this means but I will keep the code in there until it can be fixed.


I can't find it. Sad

I'll try to recreate it.


That's fine whenever you can get to it.

Thank You
Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby Lyberodoggy » Mon Oct 12, 2009 1:09 pm

My bad, one "next" command was missing. Now it should work
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Ikonz101 » Mon Oct 12, 2009 8:45 pm

I get a new error message:

Type Mismatch: '[string:"dim myarray("]'

Thanks For The Fix on the first one though.

Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby Lyberodoggy » Mon Oct 12, 2009 10:03 pm

Oh! I 'm too clumsy with my code recently... :( fixed once again hope it's gonna work now...
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Ikonz101 » Tue Oct 13, 2009 2:00 am

Its alright man :D I thank you for taking the time to help me out. Bad news again :( I get this error now:

Illegal assignment: 'counter'

I already have a variable called counter for my countdown timer. So I don't know if that is what is causing the error.

Thanks Again
Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby reneuend » Tue Oct 13, 2009 4:44 am

illegal assignment generally means you are trying to put the wrong data type in a variable. Like an integer into a variant type or the other way around.

--------------

I can't find my encryption code and the ones on the internet would require building a plugin, which I will do if you don't mind using a plugin for your encryption.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2731
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Ikonz101 » Tue Oct 13, 2009 5:47 am

Yeah a plugin would be fine. As long as I can encrypt the .ini file. Thank You
reneuend.

Lyberodoggy is the lastest error "illegal assignment" on my end or your end? How would I fix this?

Thank You
Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby Lyberodoggy » Tue Oct 13, 2009 11:55 am

Just change the "counter" variable name in my code. Illegal assignment occurs usually when using same name with different variables
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Ikonz101 » Tue Oct 13, 2009 2:55 pm

Now the text isn't appearing in the highscore board. It shows up in the .ini file but not on the frame itself.

Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby reneuend » Tue Oct 13, 2009 4:21 pm

It sounds like you changed the name of the variable that was used for the highscore board. Be very careful when changing variable names, it can have a profound effect where ever it used to be used.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2731
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Ikonz101 » Tue Oct 13, 2009 7:09 pm

I changed the "counter" variable to the variable name "numbers". But I am not sure that is what I am suppose. For some reason the text isn't appearing now.

Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby Ikonz101 » Tue Oct 13, 2009 11:07 pm

This code works perfectly right here:

entries=INIKey
Text(1).Caption=Scoreboard
Do
Text(1).Caption=Text(1).Caption+Action.ReadINI("ScoreBoard.ini",1,entries)+vblf
entries=entries-1
Loop While entries>0

This is from the scoreboard tutorial. But I notice once the code below was removed the text no longer appeared on the frame (but when I put the code back in shows it perfectly but not in order):

Text(1).Caption=Text(1).Caption+Action.ReadINI("ScoreBoard.ini",1,entries)+vblf

So if anyone could combine both the code above and the code below then it should work perfectly but I am not having any luck.

entries=INIKey
Text(1).Caption=Scoreboard
Execute "dim myarray("+cstr(entries)+")"
Execute "dim myarray2("+cstr(entries)+")"
Do
scorearray=split(Action.ReadINI("ScoreBoard.ini",1,entries),":")
Myarray(entries)=converttonumber(scorearray(1))
entries=entries-1
Loop While entries>0
entries=INIKey
Do
highest=0
for counter=0 to Inikey
if myarray(highest)<myarray(counter) then
highest=counter
end if
myarray2(entries)=myarray(highest)
myarray(highest)=-1
next
entries=entries-1
Loop while entries>0
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby Lyberodoggy » Wed Oct 14, 2009 5:32 pm

Yeah, the code I gave you puts the scores in order. It doesn't display them. That's because I didn't know how to get the names. (edit: this was fixed)

To display the scores:

if INIKey>0 then
entries=INIKey
Text(1).Caption=Scoreboard
Execute "dim myarray("+cstr(entries)+")"
Execute "dim myarray2("+cstr(entries)+")"
Do
scorearray=split(Action.ReadINI("ScoreBoard.ini",1,entries),":")
Myarray(entries)=converttonumber(scorearray(1))
entries=entries-1
Loop While entries>0
entries=INIKey
Do
highest=0
for counter=0 to Inikey
if myarray(highest)<myarray(counter) then
highest=counter
end if
next
myarray2(entries)=myarray(highest)
Text(1).Caption=Text(1).Caption+Action.ReadINI("ScoreBoard.ini",1,highest)+vblf
myarray(highest)=-1
entries=entries-1
Loop while entries>0
end if

A solution to the problem I mentioned would be to change the whole system to use the Index as the player identifier, the key then being the score and the value being the display name. I wouldn't recommend that though.
Also note that the "next" command was misplaced. It is now fixed and checked. It works perfectly if you just need to display the scores. now I need to find a way to display the names too...


EDIT: Finally the code can display both scores and names.
If two players have the same score, the one who got it first is the first to display.

Thanks for helping to make this tutorial even better :)
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

PreviousNext

Return to Post Your Own Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron