Comments on "Script functions documentation"

Discussion in 'Server and Client Scripting' started by Mystra, Sep 8, 2010.

Thread Status:
Not open for further replies.
  1. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    What if the tier is allowed instead of banned ?
     
  2. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    I can haz human readable version of your suggestion?
     
  3. NeO

    NeO BR Scripter

    Joined:
    May 26, 2010
    Messages:
    50
    Likes Received:
    0
    Talking to me?

    i thought it was a little obvious ..
    i'm suggesting 5 functions: moveType(moveNum, gen), getBannedPokes(tier), getRestrictedPokes(tier),getBannedMoves(tier), getBannedItems(tier)

    :)
     
  4. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    It was too much letters at first. I'll see at that later, when I'll fix my branch (>_>)
     
  5. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Suggestion:

    sys.teamPokeShine(id,slot)
    returns false, true, or a script warning if id is undefined or slot num is out of range(< 0 | > 5)
     
  6. kupo

    kupo Member

    Joined:
    Feb 10, 2011
    Messages:
    63
    Likes Received:
    0
    Suggestion:

    tempChangeAuth(playerId, newAuth)

    changes the auth of the player to the new auth for the duration of the server session (useful if someone auths ips via login/logout so that they don't continue to remain auth after server crash - if a password isn't set, someone could steal their name after next startup)

    sys.teamPokeHappiness(id, slot);
    sys.setTeamPokeEV(id, slot, stat, newValue);

    The other two missing pokemon functions for retrieving/loading of a team.
     
  7. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    EDIT: oh, reading… whatever. I'll see when I have time. These change/set functions got quite out of hand or maybe it's just me. As for setting EVs I don't know whether it might interference with anything, need to ask coyotte.

    Temporary changing auth is not possible AFAIK.
     
  8. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Temporary changing auth is possible with scripts already (use sessions and make sure to changeauth on player disconnect), and adding that to the server would require either hacking it or making big changes I think.
     
  9. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    And pray server will not crash :}
     
  10. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    List all temporary auth into a file then and revoke them in server startup if they still have auth.

    Ok, it starts to seem like a bigger hack than modifying server code :P
     
  11. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Nag coyotte for that :P
     
  12. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    createDir(name), deleteDir(name)

    Im sure someone else already requested it. And i seriously need it, many people complain about making folders / don't know how to create them... ._.
    OPO scripts need it too, kinda, for mafia themes folder.
     
  13. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    No :\
     
  14. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Aw ._.

    Oh and, I use the /scripts folder then for all the files? (I know its next version >_>)
     
  15. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    I haven't compiled new version so I don't know how it's done (@_@) Anyway, instead of creating directories you can always you filename prefixes. blahblah_my_cool_config.ini, etc. Also, removing directories… this is going to do very "cool" things %) You can call sys.system() to do that, though. File system access wasn't quite good idea anyway %)
     
  16. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Thats not a good idea when you have 30 mafia themes.
     
  17. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    30 files is nothing to a file system.
     
  18. Seiki

    Seiki :derp:

    Joined:
    Aug 20, 2011
    Messages:
    117
    Likes Received:
    0
    Suggestion: sys.moveType(moveNum);
    ._. Its useful in some ways. I dunno :x
     
  19. Kalashnikov

    Kalashnikov Despite the code quality

    Joined:
    Apr 4, 2011
    Messages:
    434
    Likes Received:
    0
    Maybe it'd be better to implement something like sys.move(num) which returns an object with move info (name, power, accuracy, type, etc...)?
     
  20. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Wouldn't that change some scripts using it?
    sys.moveInfo(num) - returns an array with all of [num]'s move data
    ?
     
  21. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Script changes are to be expected later anyway: cojotte will change messaging functions. Anyway, I thought of change that to object, but don't really want to break everything now. And having 2 ways to do the same thing isn't exactly appealing %) We should have planned API first, but since it wasn't done…
     
  22. Kalashnikov

    Kalashnikov Despite the code quality

    Joined:
    Apr 4, 2011
    Messages:
    434
    Likes Received:
    0
    But... There's no such thing as .moveInfo()
    And I hope by array you meant associative array/dictionary?
    Nothing implements this functionality as of now, the only thing that we can get is the name.
     
  23. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
  24. Seiki

    Seiki :derp:

    Joined:
    Aug 20, 2011
    Messages:
    117
    Likes Received:
    0
    I dunno. But :/
    That sounds good I guess? :x
     
  25. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Added: sys.moveType(move_num, gen) and sys.teamPokeShine(player_id, slot).

    sys.moveType() returns type_num (integer). Use sys.type(type_num) to get string representation. It will return ??? type for unknown moves.
     
  26. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    The list is missing:
    - sys.proxyIp
    - sys.dbAll

    sys.hiddenPowerType first argument is generation.

    sys.dbAuths returns undefined sometimes, so i rewrote it in my script..
    sys.numPlayers returns some odd number sometimes, like -6, so i had to rewrite it >>_>
     
  27. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
  28. Kalashnikov

    Kalashnikov Despite the code quality

    Joined:
    Apr 4, 2011
    Messages:
    434
    Likes Received:
    0
    Regarding functions that change player's team:
    • ID - changePokeNum(player_id, pokeSlot, pokeNum)
    • Form - not supported
    • Gender - changePokeGender(player_id, slot, gender)
    • Nature - changePokeNature(playerId, pokeSlot, natureNum) not mentioned in docs, but mentioned here, so, does it exist?
    • Item - changePokeItem(player_id, pokeSlot, itemnum)
    • Ability - changePokeAbility(player_id, slot, ability_num)
    • Moves - changePokeMove(player_id, pokeSlot, moveSlot, movenum)
    • Happiness - changePokeHappiness(player_id, slot, new_value)
    • IVs - not supported
    • EVs - not supported
      Well, one of those functions apparently masks by the name setTeamPokeDV(player_id, slot, stat, newValue), but what is DV? And why it has 'set' prefix instead of 'change' like other functions?
    So, basically all those functions are pretty messy, can we get them fixed and have missing functions added? Since with some of them missing it's impossible to spoil player's teams make any kind of scripted game... Also as a suggestion, functions for EVs, IVs and maybe moves can take array as an argument to change everything at once.
     
  29. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Form – change poke itself, it goes like that.

    No idea. Blame cojo.

    Write your own JS wrapper function for that.
     
  30. Kalashnikov

    Kalashnikov Despite the code quality

    Joined:
    Apr 4, 2011
    Messages:
    434
    Likes Received:
    0
    No, by form I meant alternatiive form, e.g. id: 479, form: 1 - Water Rotom, id 479, form: 3 - Flying Rotom...

    And on the second thought, will this work?
    Code (cpp):
    1.  
    2. void ScriptEngine::changeTeamPokeIV(int id, int slot, int stat, int newValue)
    3. {
    4.     this->setTeamPokeDV(id, slot, stat, newValue);
    5.     return;
    6. }
    7.  
    8. void ScriptEngine::changeTeamPokeEV(int id, int slot, int stat, int newValue)
    9. {
    10.     if(loggedIn(id) && slot >=0 && slot <=5 && stat >=0 && stat <= 5 && newValue >= 0 && newValue < 255) {
    11.         myserver->player(id)->team().poke(slot).evs()[stat] = newValue;
    12.     }
    13. }
    14.  
    But can't the summ of EVs exceed 512 here? Is there a way check it (aside from summing manually, duh)?
     
  31. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Water Rotom etc. all have different names. Use sys.pokeNum("poke name here"). While it is a number it stores both pokemon number and form(e) number.

    You should ask coyotte about this issue. Alternatively, you can make it so you can only change all EVs at once.
     
  32. Kalashnikov

    Kalashnikov Despite the code quality

    Joined:
    Apr 4, 2011
    Messages:
    434
    Likes Received:
    0
    Suggesting FindBattle event that fires when user clicks Find Battle button. Would be usefull for stopping battles initialized with it since the only way to stop them now is to use beforeBattleMatchup, which fires only when the actual battle starts.
    I couldn't get any further than making unstoppable beforeFindBattle.
     
  33. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    EDIT: oh, that. Dunno…
     
  34. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Suggestions:

    • sys.reloadConfig() - reloads config. useful if you changed it by file.
    • sys.changeDescription(text) - changes server description and updates. *
    • sys.getDescription() - gets it. *
    • sys.changeServerName(name) - changes server name and updates it. *
    • sys.getServerName() - Gets server name from config. *
    • sys.changeChannelName(chanId) - changes a channels name and updates it for the server. If chanId is 0, then changes in the config and saves. **
    *: Possible with scripts and reloadConfig... But still.
    **: Possible with scripts and reloadConfig if chanId is 0.
     
  35. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    >sys.changeServerName(name)
    >sys.changeDescription(text)
    Prone to abuse.

    >sys.getDescription() - gets it. *
    Useless.

    >sys.reloadConfig()
    Might be useful, but PO was not made with that in mind… Way too much changes IMO.

    >sys.getServerName()
    Should be easy to do, I guess.

    >sys.changeChannelName(chanId)
    Why would you need it?
     
  36. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Mainly to change the main channel name.


    Oh and, I have a question:
    Trusted IPs support rangeIPs?
     
  37. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    It supports many IPs separated by commas.
     
  38. Arceus

    Arceus Member

    Joined:
    May 20, 2010
    Messages:
    238
    Likes Received:
    0
    Am I not interpretting something correctly or is there no way to grab just one specific line from a file? I believe it would be useful because then commands could easily be created that can grab the moves power, priority, accuracy, etc.

    All I know how to do righ now is
    PHP:
    1.  var fileinfo = sys.getFileContent("db/moves/5G/power.txt");
    2. sendChanMessage(src, "FileBot: " + fileinfo);
     
  39. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    lol, no. Just parse it yourself. Reading all file and returning only 1 string of it is horribly inefficient and if there will be a function for that… it will be used. Which is bad.
     
  40. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Just read the lines into memory and then reference later.

    Code (text):
    1.  
    2. init : function() {
    3. ...
    4. moves_5G_power = sys.getFileContent("db/moves/5G/power.txt").split("\n");
    5. ...
    6. }
    7.  
    8. beforeChatMessage : function() {
    9. ..
    10. sendChanMessage(src, "MoveBot: " + moves_5G_power[move_nro]);  
    11. ...
    12. }
    13.  
     
Thread Status:
Not open for further replies.