By events you mean "onCurioFind()", for example? If so, why would you do it?Paradoxs wrote: Events
Prime will still have events in the next release, but I am debating removing them entirely, feedback would be helpful in the making of this decision.
-
lacucaracha
- Posts: 171
- Joined: Thu Dec 05, 2013 4:50 pm
Re: Prime - Amber tweaks and Scripting API
-
Paradoxs
- Posts: 294
- Joined: Tue Aug 25, 2015 7:16 am
Re: Prime - Amber tweaks and Scripting API
Because it forces a task to be made and checked. You usually have one or the other.Instead of OnCurioFound(); (Which only fires once per object I believe, still looking into that) You would have scanForCurios(); which would return a list of map objects that are curiosities. with their location on the map.lacucaracha wrote:By events you mean "onCurioFind()", for example? If so, why would you do it?Paradoxs wrote: Events
Prime will still have events in the next release, but I am debating removing them entirely, feedback would be helpful in the making of this decision.
I havent decided on removing it yet, and if people really want me to keep it I'll make Prime check the script for what events your looking for and only firing those events.
-
lacucaracha
- Posts: 171
- Joined: Thu Dec 05, 2013 4:50 pm
Re: Prime - Amber tweaks and Scripting API
Hmm, i see. But that would cause some problems, cause we would have to always call scanForPlayers() to check if there are new players on the screen, and not a single method doing it.Paradoxs wrote:Because it forces a task to be made and checked. You usually have one or the other.Instead of OnCurioFound(); (Which only fires once per object I believe, still looking into that) You would have scanForCurios(); which would return a list of map objects that are curiosities. with their location on the map.lacucaracha wrote:By events you mean "onCurioFind()", for example? If so, why would you do it?Paradoxs wrote: Events
Prime will still have events in the next release, but I am debating removing them entirely, feedback would be helpful in the making of this decision.
I havent decided on removing it yet, and if people really want me to keep it I'll make Prime check the script for what events your looking for and only firing those events.
The code would look much worse, and maybe even less eficient.
-
Paradoxs
- Posts: 294
- Joined: Tue Aug 25, 2015 7:16 am
Re: Prime - Amber tweaks and Scripting API
Right now as it stands though if I have a script that wont complete the main function until it reaches the Docks for example or a mining spot, it wont check for new players at all. They will have been added to a task and that task will be ran just before the main call. Giving functions in my eyes gives you complete control over your script, you could replace sleep with:lacucaracha wrote:
Hmm, i see. But that would cause some problems, cause we would have to always call scanForPlayers() to check if there are new players on the screen, and not a single method doing it.
The code would look much worse, and maybe even less eficient.
Code: Select all
function wait(Miliseconds){
if(ScanForPlayers())
FoundPlayerFunctionYouMade();
if(ScanForAnimals())
FoundAnimalFunctionYouMade();
sleep(MiliSeconds);
-
LostJustice
- Posts: 691
- Joined: Sun Mar 25, 2012 3:57 am
Re: Prime - Amber tweaks and Scripting API
I currently get all map objects and iterate through them, do said action, and then remove the list. Then rinse and repeat. I do not even use the event system because it does occur once per object. I wouldn't mind a scan implementation because that is basically what I use right now and seems to be highly efficient. Also if you need a programming perspective, the game window is consistently updating causing changes which need to be accounted for. Events only fire if a condition has happened but not twice and not if the condition is still a threat (aka a hostile creature or player). I am all for the scan method only if you have a way to get a list of objects by name though or id or w/e.Paradoxs wrote:Right now as it stands though if I have a script that wont complete the main function until it reaches the Docks for example or a mining spot, it wont check for new players at all. They will have been added to a task and that task will be ran just before the main call. Giving functions in my eyes gives you complete control over your script, you could replace sleep with:lacucaracha wrote:
Hmm, i see. But that would cause some problems, cause we would have to always call scanForPlayers() to check if there are new players on the screen, and not a single method doing it.
The code would look much worse, and maybe even less eficient.But like i said, I won't remove them completely unless no one seems to mind, I will be adding generic Scanning Functions that do the job the events do normally. I'll just have prime do a quick scan for OnCurio() and what not so that they can be ignored if you want and used if you want.Code: Select all
function wait(Miliseconds){ if(ScanForPlayers()) FoundPlayerFunctionYouMade(); if(ScanForAnimals()) FoundAnimalFunctionYouMade(); sleep(MiliSeconds);

-
Paradoxs
- Posts: 294
- Joined: Tue Aug 25, 2015 7:16 am
Re: Prime - Amber tweaks and Scripting API
LostJustice wrote:I currently get all map objects and iterate through them, do said action, and then remove the list. Then rinse and repeat. I do not even use the event system because it does occur once per object. I wouldn't mind a scan implementation because that is basically what I use right now and seems to be highly efficient. Also if you need a programming perspective, the game window is consistently updating causing changes which need to be accounted for. Events only fire if a condition has happened but not twice and not if the condition is still a threat (aka a hostile creature or player). I am all for the scan method only if you have a way to get a list of objects by name though or id or w/e.Paradoxs wrote:Right now as it stands though if I have a script that wont complete the main function until it reaches the Docks for example or a mining spot, it wont check for new players at all. They will have been added to a task and that task will be ran just before the main call. Giving functions in my eyes gives you complete control over your script, you could replace sleep with:lacucaracha wrote:
Hmm, i see. But that would cause some problems, cause we would have to always call scanForPlayers() to check if there are new players on the screen, and not a single method doing it.
The code would look much worse, and maybe even less eficient.But like i said, I won't remove them completely unless no one seems to mind, I will be adding generic Scanning Functions that do the job the events do normally. I'll just have prime do a quick scan for OnCurio() and what not so that they can be ignored if you want and used if you want.Code: Select all
function wait(Miliseconds){ if(ScanForPlayers()) FoundPlayerFunctionYouMade(); if(ScanForAnimals()) FoundAnimalFunctionYouMade(); sleep(MiliSeconds);
Don't worry that is certainly a feature. the new implementation of how Prime handles itself should also make things a bit easier. The next update changes quite a bit concerning functions but will set the staple for how functions will be running from here on out. Namely functions now return javascript objects, and "all" will now return false instead of systems where -1 = false and junk like we have now. (All in quotes because I'm sure I missed a one or two)
The scan function and the state of events wont be decided for a little bit, but you are right, the fact that seeing say, an enemy player one makes you go blind to them forever is exactly the problem I have with the event system in the first place, and I dont think there is an easy way to fix it.
-
LostJustice
- Posts: 691
- Joined: Sun Mar 25, 2012 3:57 am
Re: Prime - Amber tweaks and Scripting API
Paradoxs wrote:LostJustice wrote:I currently get all map objects and iterate through them, do said action, and then remove the list. Then rinse and repeat. I do not even use the event system because it does occur once per object. I wouldn't mind a scan implementation because that is basically what I use right now and seems to be highly efficient. Also if you need a programming perspective, the game window is consistently updating causing changes which need to be accounted for. Events only fire if a condition has happened but not twice and not if the condition is still a threat (aka a hostile creature or player). I am all for the scan method only if you have a way to get a list of objects by name though or id or w/e.Paradoxs wrote: ~Snip.
Don't worry that is certainly a feature. the new implementation of how Prime handles itself should also make things a bit easier. The next update changes quite a bit concerning functions but will set the staple for how functions will be running from here on out. Namely functions now return javascript objects, and "all" will now return false instead of systems where -1 = false and junk like we have now. (All in quotes because I'm sure I missed a one or two)
The scan function and the state of events wont be decided for a little bit, but you are right, the fact that seeing say, an enemy player one makes you go blind to them forever is exactly the problem I have with the event system in the first place, and I dont think there is an easy way to fix it.
Code: Select all
function findHostileCreatures()
{
var mapObjects = Game.getAllMapObjects();
for (i = 0; i < mapObjects.length; i++) {
if(mapObjects[i].name == 'bear' || mapObjects[i].name == 'lynx' || mapObjects[i].name == 'badger' || mapObjects[i].name == 'boar' || mapObjects[i].name == 'palisadeseg')
{
java.lang.System.out.print("Found a hostile creature!!\n");
java.lang.System.out.print("Adding it to the list of creatures!\n");
creatureList.push(mapObjects[i]);
java.lang.System.out.print("Creature List Length is now: "+creatureList.length+"\n");
}
}
}
-
Paradoxs
- Posts: 294
- Joined: Tue Aug 25, 2015 7:16 am
Prime - Version 0.2 Release Notes
The latest release has fixes the MapObjects issue and any other issue
to Compare arrays of mapObjects or Items use:
Version 0.2 Notes
Notice: 0.2 Changes a lot about the API, from function names, and Prime interfaces. I suggest you read these notes or re-view the Readme
New Features
Changes to script Requirements
Changes to reserved Variables and Functions
All Prime functions are now reserved, due to removing the Game object they are now directly usable and conflict-causing functions
New Prime Interfaces
These are objects that prime will return and how you can use them
Removed Functions
New Functions
[/size]
to Compare arrays of mapObjects or Items use:
Code: Select all
var List = getMapObjects();
var list2 = getMapObjects();
if(list.equals(list2))
print("We are equal!");
Notice: 0.2 Changes a lot about the API, from function names, and Prime interfaces. I suggest you read these notes or re-view the Readme
New Features
- loadLib(FileName)
loadLib(FileName) has been added. Scripts will load the contents of a lib file when ran into its own source file.Code: Select all
loadLib("test.js"); loadLib("Examples/TestLib.js");
Changes to script Requirements
- LoadGame()
LoadGame has been removed. Scripts no longer require you call it
Changes to reserved Variables and Functions
- Game,_scplayx, _scplayx
Have been removed. You can now freely give variables these names.
Channel
A reserved interface for specifying Chat Channels (see SendChat)
MouseButton
A reserved interface for specifying Mouse Buttons (see pfClick)
All Prime functions are now reserved, due to removing the Game object they are now directly usable and conflict-causing functions
New Prime Interfaces
These are objects that prime will return and how you can use them
- Item
Item has three properties Name, FullName and Coords (Currently Broken)MapObjectCode: Select all
print(getItem()[0].FullName);
MapObject has three properties Name, Fullname, Id, CoordsAttentionInfoCode: Select all
print(getMapObject()[0].Name);
AttentionInfo stores attention details grabbed with getAttention, it has two properties Total, and UsedHealthInfoCode: Select all
print(getAttention().Total);
AttentionInfo stores attention details grabbed with getHealth, it has two properties SHP, and HHPCode: Select all
print(getHealth().HHP);
Removed Functions
- WaitTillStopped
Became waitToFinish
studyCurio
Became study
dropItemFromHandToWindow
Became dropTo
getInvItems
Became getItems, functions very differently, see new functions below or view Readme
getPlayerCoords
Became getCoords
Pick
Became pickItem
travelToHearthFire
Became hearth
mapRightClick
Functionality replaced, see pfClick
getMapObjects
Functionality changed to be more dyanmic see readme or new functions below
getAllMapObjects
getMapObjects covers this
getMapObjectsByFullName
getMapObjects covers this
getCharAttentionInfo
Became getAttention
getHP
Became getHealth
sendAreaChatMessage
sendChat covers this
sendPartyChatMessage
sendChat covers this
sendVillageChatMessage
sendChat covers this
sendPrivateChatMessage
sendChat covers this
useMenuAction
Became useActionMenu
chooseFlowerMenuOption
Became chooseOption
New Functions
- isStudying(CuriosityName)
Returns true if player is studying item, otherwise returns false.
hasItem(ItemName)
Returns true if playerhas item, otherwise returns false.
getItem(Item)
Takes a Item name and returns a Item object from inside player inventory that match returns empty array otherwise.
getItems(Item)
Take a Item name and returns a list of Item objects from inside player inventory that match. If not item is passed returns a list of all inventory items. returns empty array otherwise
drink(Container)
Takes a item name and drinks from that object specifically
setSpeed(Speed)
Takes a number from 0 to 3, 0 being crawl and 3 being sprint. returns true if speed is set, returns false otherwise.
sendChat(Message, Channels, Who)
sendChat is dynamic, requires Message, others can be left out. If Message is passed Channel defaults to Channel.AreaYou can choose to pass a Channel, these areCode: Select all
sendChat("Hey bessie");- Channel.Area
- Channel.Party
- Channel.Village
- Channel.Private
getMapObjects(Name, Fullname)
getMapObjects doesn't require any of its parameters to be passed, if left empty it will return a list of MapObjects containing all map objectsif you pass name, you can pinpoint the name of an object such as "rowboat"Code: Select all
var Map = getMapObjects();
passing any value to Fullname (true, "faf" 56 ecr) will cause the map to interpret Name as a FullName returning a list
returns an array, empty if none are found
pfClick(Object, Button, Shift)
Only Object has to be specified.
if Button is not passed it will left click the MapObject
MouseButtons- MouseButton.Left
- MouseButton.Right
[/size]
-
LostJustice
- Posts: 691
- Joined: Sun Mar 25, 2012 3:57 am
Re: Prime - Amber tweaks and Scripting API
I like the update. Definitely a thumbs up for it. Updated my script and things are working a lot better now.

-
Paradoxs
- Posts: 294
- Joined: Tue Aug 25, 2015 7:16 am
Re: Prime - Amber tweaks and Scripting API
I'm glad to hear it! I'm currently working on a number of things to improve it as I go. It still doesn't do everything I personally would like it but I think we have a good start. Keep me updated with requests and suggestions. Theres still a ton of work to do before we hit Version 1.0 on both the scripting API side and the general client tweaks and changesLostJustice wrote:I like the update. Definitely a thumbs up for it. Updated my script and things are working a lot better now.
I should also have noted all objects have a special print function.
So if you say do
Code: Select all
print(getAttention());you'll see a print-out that will give you actual information, making debugging and reporting easier[object object]