IdleRPG Dialog

Moderator: GeekShed.Net Staff

IdleRPG Dialog

Postby GrimReaper » Mon May 10, 2010 12:46 pm

Code: Select all
menu channel,status,menubar {
  -
  IdleRPG:diaidlerpg
}

dialog idlerpg_dia {
  title "IdleRPG Dialog By GrimReaper"
  size -1 -1 150 150
  option dbu
  button "Ok", 3, 35 127 37 12, ok
  button "Cancel", 4, 81 127 37 12, ok
  text "Char Name:", 5, 3 4 29 8
  edit "", 6, 36 3 77 10
  button "Search", 7, 116 2 31 12
  box "Character Details", 8, 3 16 144 107
  text "Player Owner:", 9, 7 25 36 8
  edit "", 10, 47 24 95 10, read
  text "Player Info:", 11, 7 37 29 8
  edit "", 12, 47 36 95 10, read
  text "Player Class:", 13, 7 49 31 8
  edit "", 14, 47 48 95 10, read
  text "Player Level:", 15, 7 61 31 8
  edit "", 16, 47 60 95 10, read
  text "Next Level:", 17, 7 73 28 8
  edit "", 18, 47 72 95 10, read
  text "Player Status:", 19, 7 85 34 8
  edit "", 20, 47 84 95 10, read
  text "Total Idle Time:", 21, 7 97 37 8
  edit "", 22, 47 96 95 10, read
  text "Alignment:", 23, 7 109 25 8
  edit "", 24, 47 108 95 10, read
  link "http://idlerpg.geekshed.net/", 26, 43 140 70 8, center
  menu "File", 1
  item "Clear All", 2, 1
  item "Exit", 25, 1, ok
}

on *:DIALOG:idlerpg_dia:init:*: {
  if (!%IdleRPGnick) {
    set %IdleRPGnick $$?="Please enter your IdleRPG's Char name:"
    did -a $dname 6 %IdleRPGnick
  }
  else {
    did -a $dname 6 %IdleRPGnick
  }
}

on *:DIALOG:idlerpg_dia:menu:2,25: {
  if ($did == 2) {
    did -r $dname 10,12,14,16,18,20,22,24
  }
}

on *:DIALOG:idlerpg_dia:sclick:26: {
  run http://idlerpg.geekshed.net/
}

on *:DIALOG:idlerpg_dia:sclick:3,4: {
  dialog -x idlerpg_dia idlerpg_dia
}

on *:DIALOG:idlerpg_dia:sclick:7: {
  if (!$did(6).text) { noop $input(Please enter a Char Name to search.,uwo,Error!) }
  else {
    did -r $dname 10,12,14,16,18,20,22,24
    set -u5 %idlerpgcharname $did($dname,6).text
    sockopen IdleRPG idlerpg.GeekShed.net 80
  }
}

on *:sockopen:IdleRPG*: {
  if ($sockerr) { did -a idlerpg_dia 10 Error: Couldn't connect to retrieve the specified data. }
  else {
    sockwrite -nt $sockname GET $+(/playerview.php?player=,%idlerpgcharname) HTTP/1.0
    sockwrite -nt $sockname Host: idlerpg.geekshed.net $+ $crlf $+ $crlf
  }
}

on *:sockread:IdleRPG*: {
  sockread %IdleRPG
  if (<h1>Player Info</h1> isin %IdleRPG) && (<p><b>User:</b> isin %IdleRPG) {
    set -u9 %IdleRPGinfo $remove($htmlfree(%IdleRPG),Player,Info)
  }
  elseif (<b>Class:</b> isin %IdleRPG) {
    set -u9 %IdleRPGclass $htmlfree(%IdleRPG)
  }
  elseif (<b>Host:</b> isin %IdleRPG) {
    set -u9 %IdleRPGowner $gettok($htmlfree(%IdleRPG),1,33)
  }
  elseif (<b>Level:</b> isin %IdleRPG) {
    set -u9 %IdleRPGlevel $htmlfree(%IdleRPG)
  }
  elseif (<b>Next level:</b> isin %IdleRPG) {
    set -u9 %IdleRPGnextlevel $htmlfree(%IdleRPG)
  }
  elseif (<b>Status:</b> isin %IdleRPG) {
    set -u9 %IdleRPGstatus $htmlfree(%IdleRPG)
  }
  elseif (<b>Total time idled:</b> isin %IdleRPG) {
    set -u9 %IdleRPGidled $htmlfree(%IdleRPG)
  }
  elseif (<b>Alignment:</b> isin %IdleRPG) {
    set -u9 %IdleRPGalignment $htmlfree(%IdleRPG)
  }
  elseif (<h1>Player Info</h1><h1>Error</h1> isin %IdleRPG) {
    set -u9 %IdleRPGerror Error: No such user.
  }
}

on *:sockclose:IdleRPG*: {
  if (%IdleRPGerror != $null) { did -a idlerpg_dia 10 %IdleRPGerror | HALT }
  elseif (%IdleRPGerror == $null) {
    did -a idlerpg_dia 12 $remove(%IdleRPGinfo,User $+ $chr(58))
    did -a idlerpg_dia 14 $remove(%IdleRPGclass,Class $+ $chr(58))
    did -a idlerpg_dia 10 $remove(%IdleRPGowner,Host $+ $chr(58))
    did -a idlerpg_dia 16 $remove(%IdleRPGlevel,Level $+ $chr(58))
    did -a idlerpg_dia 18 $remove(%IdleRPGnextlevel,Next,Level $+ $chr(58))
    did -a idlerpg_dia 20 $remove(%IdleRPGstatus,Status $+ $chr(58))
    did -a idlerpg_dia 22 $remove(%IdleRPGidled,Total,time,idled $+ $chr(58))
    did -a idlerpg_dia 24 $remove(%IdleRPGalignment,Alignment $+ $chr(58))
  }
}

alias -l diaidlerpg {
  if ($network == GeekShed) {
    if (!$dialog(idlerpg_dia)) { dialog -m idlerpg_dia idlerpg_dia }
    else { noop $input(IdleRPG Statistics are already opened.,uwo,Error!) }
  }
  else {
    noop $input(The IdleRPG Dialog is for GeekShed Only!,uwo,Error!)
  }
}

alias htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ) | return %x }


I've been getting into Dialog script's recently, do I thought I'd give the IdleRPG game a go with Dialogs.

It appears to work, if you notice any problem's with it. Please don't hesitate to reply or pop into my channel on GeekShed, #hell

Update: Sorted out the text boxes to align properly, Added a link to the bottom of the Dialog to go to the IdleRPG page.

Updated Again: Idea from Artellos, to gather the Owner's nick and place it into the Dialog. I will /try/ to get it so you can use the owner's name in the search and it'll look for the details to that Char eventually.

Updated 9th July 2010: Added an on INIT event to automatically add your Character's name into the edit box on start.

I forgot to add the $htmlfree alias so have added it to the bottom of the script. Apologies for this.
I have a screenshot of it working.

Screenie: Image
Last edited by GrimReaper on Fri Jul 09, 2010 10:30 pm, edited 3 times in total.
GrimReaper
 
Posts: 73
Joined: Wed Oct 28, 2009 4:34 pm
Location: In your router, Resetting your connection.

Re: IdleRPG Dialog

Postby Ford » Sat May 29, 2010 3:34 am

You have come a long way man :)
Hey, why all the variables and the on sockclose event?
Why not just send the info to the dialog as soon as you get it from the socket?
Ford
 
Posts: 48
Joined: Wed Oct 28, 2009 1:01 am

Re: IdleRPG Dialog

Postby GrimReaper » Fri Jul 09, 2010 10:31 pm

Ford wrote:You have come a long way man :)
Hey, why all the variables and the on sockclose event?
Why not just send the info to the dialog as soon as you get it from the socket?


I will be adding the Idea you gave later on Ford. as I didn't realise I could do that till you said so.. I haven't had time to sort it lately.. but will get around to it soon. :)
GrimReaper
 
Posts: 73
Joined: Wed Oct 28, 2009 4:34 pm
Location: In your router, Resetting your connection.


Return to Script help

Who is online

Users browsing this forum: No registered users and 12 guests

cron